@camstack/addon-provider-homematic 1.2.129 → 1.2.131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +3555 -126
  2. package/dist/addon.mjs +3555 -126
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -8,7 +8,7 @@ let http = require("http");
8
8
  let crypto$1 = require("crypto");
9
9
  let fs_promises = require("fs/promises");
10
10
  let path = require("path");
11
- //#region ../types/dist/event-category-B_0XEcLF.mjs
11
+ //#region ../types/dist/event-category-DaIZi00R.mjs
12
12
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
13
13
  EventCategory["SystemBoot"] = "system.boot";
14
14
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -87,6 +87,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
87
87
  */
88
88
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
89
89
  /**
90
+ * A keychain value was stored or removed (D787). Carries the ref, its
91
+ * owner and the new version — NEVER the value. A process holding the ref
92
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
93
+ * Telemetry (D8): a process that misses it still revalidates by version.
94
+ */
95
+ EventCategory["KeychainChanged"] = "keychain.changed";
96
+ /**
90
97
  * Addon recovered from a previous failure. Emitted when an addon
91
98
  * transitions from `failed` back to `healthy` (typically via the
92
99
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5379,7 +5386,7 @@ var ZodIssueCode = {
5379
5386
  var ZodFirstPartyTypeKind;
5380
5387
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5381
5388
  //#endregion
5382
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5389
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5383
5390
  /**
5384
5391
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5385
5392
  * window to float samples (D455).
@@ -5458,6 +5465,97 @@ function buildAlawTable() {
5458
5465
  }
5459
5466
  buildUlawTable();
5460
5467
  buildAlawTable();
5468
+ /** Is this field's stored value a credential? */
5469
+ function isSecretConfigField(field) {
5470
+ if (field.type === "password") return true;
5471
+ return "secret" in field && field.secret === true;
5472
+ }
5473
+ /**
5474
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5475
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5476
+ */
5477
+ function isKeychainStoredField(field) {
5478
+ if (!isSecretConfigField(field)) return false;
5479
+ if (field.type === "textarea" && field.isJson === true) return false;
5480
+ return !("storage" in field && field.storage === "inline");
5481
+ }
5482
+ /**
5483
+ * What a settings blob holds where a secret used to be.
5484
+ *
5485
+ * A keychain-stored field never holds its value. It holds a self-describing
5486
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5487
+ * code can mistake it for a credential and no form can send it to a camera as
5488
+ * a password. The empty state is `null` / absent, never `''`.
5489
+ *
5490
+ * The same shapes travel to and from the admin UI:
5491
+ *
5492
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5493
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5494
+ * value is set, never the value.
5495
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5496
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5497
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5498
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5499
+ * treating it as "clear" is how a save destroyed a stored credential before.
5500
+ *
5501
+ * Pure and browser-safe.
5502
+ */
5503
+ var SECRET_CLEAR = { $secretClear: true };
5504
+ /** The `'***'` token D634 redaction writes for non-admins. */
5505
+ var LEGACY_DEVICE_REDACTION = "***";
5506
+ function isRecord$2(value) {
5507
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5508
+ }
5509
+ function makeSecretMarker(ref) {
5510
+ return {
5511
+ $secret: ref,
5512
+ v: 1
5513
+ };
5514
+ }
5515
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5516
+ function isSecretMarker(value) {
5517
+ if (!isRecord$2(value)) return false;
5518
+ const ref = value["$secret"];
5519
+ return typeof ref === "string" && ref.length > 0;
5520
+ }
5521
+ function isSecretClear(value) {
5522
+ return isRecord$2(value) && value["$secretClear"] === true;
5523
+ }
5524
+ /**
5525
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5526
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5527
+ * survives this function.
5528
+ */
5529
+ function toSecretFieldView(stored) {
5530
+ if (isSecretMarker(stored)) return {
5531
+ $secret: stored.$secret,
5532
+ v: 1,
5533
+ set: true
5534
+ };
5535
+ if (typeof stored === "string" && stored.length > 0) return {
5536
+ $secret: null,
5537
+ v: 1,
5538
+ set: true,
5539
+ inline: true
5540
+ };
5541
+ return null;
5542
+ }
5543
+ /**
5544
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5545
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5546
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5547
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5548
+ */
5549
+ function classifySecretWrite(incoming) {
5550
+ if (isSecretClear(incoming)) return { kind: "clear" };
5551
+ if (typeof incoming !== "string") return { kind: "keep" };
5552
+ if (incoming.length === 0) return { kind: "keep" };
5553
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5554
+ return {
5555
+ kind: "set",
5556
+ value: incoming
5557
+ };
5558
+ }
5461
5559
  Object.fromEntries([
5462
5560
  {
5463
5561
  id: "overview",
@@ -5629,33 +5727,19 @@ Object.fromEntries([
5629
5727
  function isValuelessField(field) {
5630
5728
  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";
5631
5729
  }
5632
- /**
5633
- * Merge a `ConfigUISchema` with a raw `values` record into a
5634
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5635
- * before returning to the admin UI. Groups are walked recursively.
5636
- *
5637
- * For each leaf field:
5638
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5639
- * - other fields get `value = values[key] ?? field.default ?? null`
5640
- *
5641
- * Unknown keys in `values` (keys not declared in the schema) are silently
5642
- * ignored — they don't contribute to the output. Missing keys fall back to
5643
- * the schema default or `null`. This mirrors the old backend behaviour where
5644
- * `FormBuilder` rendered `values[key] ?? field.default`.
5645
- */
5646
- function hydrateSchema(schema, values) {
5730
+ function hydrateSchema(schema, values, options = {}) {
5647
5731
  return {
5648
5732
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5649
5733
  sections: schema.sections.map((section) => ({
5650
5734
  ...section,
5651
- fields: section.fields.map((field) => hydrateField(field, values))
5735
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5652
5736
  }))
5653
5737
  };
5654
5738
  }
5655
- function hydrateField(field, values) {
5739
+ function hydrateField(field, values, options) {
5656
5740
  if (isValuelessField(field)) return field;
5657
5741
  if (field.type === "group") {
5658
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5742
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5659
5743
  return {
5660
5744
  ...field,
5661
5745
  fields: hydratedChildren
@@ -5664,7 +5748,7 @@ function hydrateField(field, values) {
5664
5748
  if (field.type === "sub-tabs") {
5665
5749
  const hydratedTabs = field.tabs.map((tab) => ({
5666
5750
  ...tab,
5667
- fields: tab.fields.map((child) => hydrateField(child, values))
5751
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5668
5752
  }));
5669
5753
  return {
5670
5754
  ...field,
@@ -5674,6 +5758,33 @@ function hydrateField(field, values) {
5674
5758
  const key = field.key;
5675
5759
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5676
5760
  const defaultValue = field.default;
5761
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5762
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5763
+ ...field,
5764
+ value: toSecretFieldView(storedValue)
5765
+ };
5766
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5767
+ ...field,
5768
+ value: null
5769
+ };
5770
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5771
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5772
+ if (secretItemKeys.length > 0) {
5773
+ const rows = storedValue.map((row) => {
5774
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5775
+ const out = { ...row };
5776
+ for (const k of secretItemKeys) {
5777
+ const v = Reflect.get(row, k);
5778
+ if (asView(v)) out[k] = toSecretFieldView(v);
5779
+ }
5780
+ return out;
5781
+ });
5782
+ return {
5783
+ ...field,
5784
+ value: rows
5785
+ };
5786
+ }
5787
+ }
5677
5788
  if (field.multiple) {
5678
5789
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5679
5790
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5916,6 +6027,778 @@ function projectStore(store, perNodeKeys, nodeId) {
5916
6027
  }
5917
6028
  return out;
5918
6029
  }
6030
+ var GLOBAL_SCOPE = { kind: "global" };
6031
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6032
+ function globalSecretScope() {
6033
+ return GLOBAL_SCOPE;
6034
+ }
6035
+ function encodeSegment(value) {
6036
+ return encodeURIComponent(value);
6037
+ }
6038
+ function decodeSegment(value) {
6039
+ try {
6040
+ return decodeURIComponent(value);
6041
+ } catch {
6042
+ return null;
6043
+ }
6044
+ }
6045
+ /**
6046
+ * The field path of a value inside an array item, addressed by the item's id:
6047
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6048
+ * `providers[authentik].clientSecret`.
6049
+ */
6050
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6051
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6052
+ }
6053
+ function parseScope(segments) {
6054
+ switch (segments[0]) {
6055
+ case "global": return {
6056
+ scope: GLOBAL_SCOPE,
6057
+ used: 1
6058
+ };
6059
+ case "node": {
6060
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6061
+ return nodeId === null || nodeId.length === 0 ? null : {
6062
+ scope: {
6063
+ kind: "node",
6064
+ nodeId
6065
+ },
6066
+ used: 2
6067
+ };
6068
+ }
6069
+ case "device": {
6070
+ const raw = segments[1];
6071
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6072
+ return {
6073
+ scope: {
6074
+ kind: "device",
6075
+ deviceId: Number(raw)
6076
+ },
6077
+ used: 2
6078
+ };
6079
+ }
6080
+ case "integration": {
6081
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6082
+ return id === null || id.length === 0 ? null : {
6083
+ scope: {
6084
+ kind: "integration",
6085
+ integrationId: id
6086
+ },
6087
+ used: 2
6088
+ };
6089
+ }
6090
+ case "row": {
6091
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6092
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6093
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6094
+ return {
6095
+ scope: {
6096
+ kind: "row",
6097
+ collection,
6098
+ rowId
6099
+ },
6100
+ used: 3
6101
+ };
6102
+ }
6103
+ default: return null;
6104
+ }
6105
+ }
6106
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6107
+ function parseSecretRef(ref) {
6108
+ if (!ref.startsWith("secret://")) return null;
6109
+ const segments = ref.slice(9).split("/");
6110
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6111
+ if (owner === null || owner.length === 0) return null;
6112
+ const parsed = parseScope(segments.slice(1));
6113
+ if (parsed === null) return null;
6114
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6115
+ if (fieldPath.length === 0) return null;
6116
+ return {
6117
+ owner,
6118
+ scope: parsed.scope,
6119
+ fieldPath
6120
+ };
6121
+ }
6122
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6123
+ var KeychainWriteRefusedError = class extends Error {
6124
+ fieldPath;
6125
+ constructor(fieldPath, cause) {
6126
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6127
+ this.fieldPath = fieldPath;
6128
+ this.name = "KeychainWriteRefusedError";
6129
+ }
6130
+ };
6131
+ var KEEP = { kind: "keep" };
6132
+ function isRecord$1(value) {
6133
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6134
+ }
6135
+ function defaultMintId() {
6136
+ return globalThis.crypto.randomUUID();
6137
+ }
6138
+ /** Every marker ref anywhere under `value`. */
6139
+ function collectSecretMarkerRefs(value, out = []) {
6140
+ if (isSecretMarker(value)) {
6141
+ out.push(value.$secret);
6142
+ return out;
6143
+ }
6144
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6145
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6146
+ return out;
6147
+ }
6148
+ async function storedValueEquals(secrets, marker, candidate) {
6149
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6150
+ return resolved?.kind === "value" && resolved.value === candidate;
6151
+ }
6152
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6153
+ const intent = classifySecretWrite(incoming);
6154
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6155
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6156
+ if (intent.kind === "keep") return KEEP;
6157
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6158
+ if (intent.kind === "clear") {
6159
+ if (storedIsOurs) ctx.deletes.push(ref);
6160
+ return {
6161
+ kind: "value",
6162
+ value: null
6163
+ };
6164
+ }
6165
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6166
+ kind: "value",
6167
+ value: stored
6168
+ };
6169
+ try {
6170
+ await ctx.secrets.put(ref, intent.value);
6171
+ } catch (err) {
6172
+ throw new KeychainWriteRefusedError(fieldPath, err);
6173
+ }
6174
+ return {
6175
+ kind: "value",
6176
+ value: makeSecretMarker(ref)
6177
+ };
6178
+ }
6179
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6180
+ function applyMember(out, key, result, storedParent) {
6181
+ if (result.kind === "value") {
6182
+ out[key] = result.value;
6183
+ return;
6184
+ }
6185
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6186
+ else delete out[key];
6187
+ }
6188
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6189
+ const out = { ...incoming };
6190
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6191
+ return out;
6192
+ }
6193
+ function rowId(row, idKey) {
6194
+ const raw = row[idKey];
6195
+ if (typeof raw === "string" && raw.length > 0) return raw;
6196
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6197
+ return null;
6198
+ }
6199
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6200
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6201
+ if (!Array.isArray(incoming)) {
6202
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6203
+ return {
6204
+ kind: "value",
6205
+ value: incoming
6206
+ };
6207
+ }
6208
+ const storedById = /* @__PURE__ */ new Map();
6209
+ for (const row of storedRows) {
6210
+ const id = rowId(row, node.idKey);
6211
+ if (id !== null) storedById.set(id, row);
6212
+ }
6213
+ const kept = /* @__PURE__ */ new Set();
6214
+ const rows = [];
6215
+ for (const row of incoming) {
6216
+ if (!isRecord$1(row)) {
6217
+ rows.push(row);
6218
+ continue;
6219
+ }
6220
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6221
+ kept.add(id);
6222
+ const withId = {
6223
+ ...row,
6224
+ [node.idKey]: row[node.idKey] ?? id
6225
+ };
6226
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6227
+ const storedRow = storedById.get(id) ?? {};
6228
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6229
+ }
6230
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6231
+ return {
6232
+ kind: "value",
6233
+ value: rows
6234
+ };
6235
+ }
6236
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6237
+ switch (node.kind) {
6238
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6239
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6240
+ case "object": {
6241
+ if (!isRecord$1(incoming)) {
6242
+ if (incoming === void 0) return KEEP;
6243
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6244
+ return {
6245
+ kind: "value",
6246
+ value: incoming
6247
+ };
6248
+ }
6249
+ const storedObj = isRecord$1(stored) ? stored : {};
6250
+ return {
6251
+ kind: "value",
6252
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6253
+ };
6254
+ }
6255
+ }
6256
+ }
6257
+ /** Split a perNode-scoped key (`key@nodeId`). */
6258
+ function splitNodeKey(key) {
6259
+ const at = key.indexOf("@");
6260
+ return at <= 0 ? {
6261
+ base: key,
6262
+ nodeId: null
6263
+ } : {
6264
+ base: key.slice(0, at),
6265
+ nodeId: key.slice(at + 1)
6266
+ };
6267
+ }
6268
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6269
+ async function transformSecretWrite(input) {
6270
+ const deletes = [];
6271
+ const base = {
6272
+ secrets: input.secrets,
6273
+ mintId: input.mintId ?? defaultMintId,
6274
+ deletes,
6275
+ operatorWrite: input.operatorWrite === true
6276
+ };
6277
+ const out = {};
6278
+ for (const [key, incoming] of Object.entries(input.patch)) {
6279
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6280
+ const node = input.tree.get(baseKey);
6281
+ if (node === void 0) {
6282
+ out[key] = incoming;
6283
+ continue;
6284
+ }
6285
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6286
+ kind: "node",
6287
+ nodeId
6288
+ } : input.scope ?? globalSecretScope();
6289
+ const result = await writeNode({
6290
+ ...base,
6291
+ scope
6292
+ }, node, incoming, input.stored[key], baseKey);
6293
+ if (result.kind === "value") out[key] = result.value;
6294
+ }
6295
+ return {
6296
+ patch: out,
6297
+ afterWrite: async () => {
6298
+ if (deletes.length === 0) return { orphaned: [] };
6299
+ try {
6300
+ await input.secrets.delete([...new Set(deletes)]);
6301
+ return { orphaned: [] };
6302
+ } catch {
6303
+ return { orphaned: [...new Set(deletes)] };
6304
+ }
6305
+ }
6306
+ };
6307
+ }
6308
+ /** Is `ref` one of `owner`'s refs? */
6309
+ function isSecretRefOwnedBy(ref, owner) {
6310
+ return parseSecretRef(ref)?.owner === owner;
6311
+ }
6312
+ /**
6313
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6314
+ * reference when there is no marker (no allocation, no keychain call).
6315
+ */
6316
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6317
+ const keepMarker = options.unresolved === "keep-marker";
6318
+ const owner = options.ownedBy;
6319
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6320
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6321
+ if (refs.length === 0) return {
6322
+ value,
6323
+ unresolved: []
6324
+ };
6325
+ const answers = await secrets.resolve(refs);
6326
+ const unresolved = [];
6327
+ for (const ref of new Set(refs)) {
6328
+ const answer = answers[ref];
6329
+ if (answer === void 0) unresolved.push({
6330
+ ref,
6331
+ reason: "not-initialized"
6332
+ });
6333
+ else if (answer.kind === "unavailable") unresolved.push({
6334
+ ref,
6335
+ reason: answer.reason
6336
+ });
6337
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6338
+ ref,
6339
+ reason: answer.kind
6340
+ });
6341
+ }
6342
+ const substitute = (v) => {
6343
+ if (isSecretMarker(v)) {
6344
+ if (!inScope(v.$secret)) return {
6345
+ keep: true,
6346
+ value: v
6347
+ };
6348
+ const answer = answers[v.$secret];
6349
+ if (answer?.kind === "value") return {
6350
+ keep: true,
6351
+ value: answer.value
6352
+ };
6353
+ return keepMarker ? {
6354
+ keep: true,
6355
+ value: v
6356
+ } : {
6357
+ keep: false,
6358
+ value: void 0
6359
+ };
6360
+ }
6361
+ if (Array.isArray(v)) {
6362
+ const items = [];
6363
+ for (const item of v) {
6364
+ const s = substitute(item);
6365
+ if (s.keep) items.push(s.value);
6366
+ }
6367
+ return {
6368
+ keep: true,
6369
+ value: items
6370
+ };
6371
+ }
6372
+ if (isRecord$1(v)) {
6373
+ const out = {};
6374
+ for (const [k, child] of Object.entries(v)) {
6375
+ const s = substitute(child);
6376
+ if (s.keep) out[k] = s.value;
6377
+ }
6378
+ return {
6379
+ keep: true,
6380
+ value: out
6381
+ };
6382
+ }
6383
+ return {
6384
+ keep: true,
6385
+ value: v
6386
+ };
6387
+ };
6388
+ return {
6389
+ value: substitute(value).value,
6390
+ unresolved
6391
+ };
6392
+ }
6393
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6394
+ var SecretOverwriteRefusedError = class extends Error {
6395
+ ref;
6396
+ reason;
6397
+ constructor(ref, reason) {
6398
+ 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.`);
6399
+ this.ref = ref;
6400
+ this.reason = reason;
6401
+ this.name = "SecretOverwriteRefusedError";
6402
+ }
6403
+ };
6404
+ function isRecord$3(value) {
6405
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6406
+ }
6407
+ function resolvedValue(pass, marker) {
6408
+ const answer = pass.answers[marker.$secret];
6409
+ return answer?.kind === "value" ? answer.value : null;
6410
+ }
6411
+ async function atMarker(pass, incoming, stored) {
6412
+ if (incoming === null) return stored;
6413
+ if (typeof incoming !== "string") return incoming;
6414
+ if (incoming === resolvedValue(pass, stored)) return stored;
6415
+ const intent = classifySecretWrite(incoming);
6416
+ if (intent.kind !== "set") return stored;
6417
+ const ref = stored.$secret;
6418
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6419
+ const answer = pass.answers[ref];
6420
+ 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);
6421
+ try {
6422
+ await pass.secrets.put(ref, intent.value);
6423
+ } catch (err) {
6424
+ throw new KeychainWriteRefusedError(ref, err);
6425
+ }
6426
+ pass.changedRefs.push(ref);
6427
+ return stored;
6428
+ }
6429
+ function inArray(pass, incoming, stored) {
6430
+ return incoming.map((item, index) => {
6431
+ const twin = stored[index];
6432
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6433
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
6434
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6435
+ return item;
6436
+ });
6437
+ }
6438
+ function inArrayRow(pass, incoming, stored) {
6439
+ const out = { ...incoming };
6440
+ for (const [key, value] of Object.entries(incoming)) {
6441
+ const twin = stored[key];
6442
+ if (isSecretMarker(twin)) {
6443
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6444
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
6445
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6446
+ }
6447
+ return out;
6448
+ }
6449
+ async function walk(pass, incoming, stored) {
6450
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6451
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6452
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
6453
+ const out = { ...incoming };
6454
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6455
+ return out;
6456
+ }
6457
+ /** Restore markers a write-back carries as values. See the file doc. */
6458
+ async function restoreUnchangedSecrets(input) {
6459
+ const refs = [];
6460
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6461
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6462
+ if (owned.length === 0) return {
6463
+ patch: input.patch,
6464
+ changedRefs: []
6465
+ };
6466
+ const pass = {
6467
+ secrets: input.secrets,
6468
+ answers: await input.secrets.resolve([...new Set(owned)]),
6469
+ operatorWrite: input.operatorWrite,
6470
+ changedRefs: []
6471
+ };
6472
+ const out = {};
6473
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6474
+ return {
6475
+ patch: out,
6476
+ changedRefs: pass.changedRefs
6477
+ };
6478
+ }
6479
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6480
+ function isJsonEqual(a, b) {
6481
+ if (Object.is(a, b)) return true;
6482
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6483
+ if (isRecord$3(a) && isRecord$3(b)) {
6484
+ const keys = Object.keys(a);
6485
+ if (keys.length !== Object.keys(b).length) return false;
6486
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6487
+ }
6488
+ return false;
6489
+ }
6490
+ /** The patch without the keys whose value already equals the stored one. */
6491
+ function dropUnchangedKeys(patch, stored) {
6492
+ const out = {};
6493
+ for (const [key, value] of Object.entries(patch)) {
6494
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6495
+ out[key] = value;
6496
+ }
6497
+ return out;
6498
+ }
6499
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6500
+ function markerKeysOf(blob, owner) {
6501
+ const keys = /* @__PURE__ */ new Set();
6502
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6503
+ return keys;
6504
+ }
6505
+ function nodeFromStored(value, owner) {
6506
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6507
+ if (!isRecord$3(value)) return null;
6508
+ const children = /* @__PURE__ */ new Map();
6509
+ for (const [key, child] of Object.entries(value)) {
6510
+ const node = nodeFromStored(child, owner);
6511
+ if (node !== null) children.set(key, node);
6512
+ }
6513
+ return children.size > 0 ? {
6514
+ kind: "object",
6515
+ children
6516
+ } : null;
6517
+ }
6518
+ /**
6519
+ * The declared secret tree, widened by every place the STORED blob holds a
6520
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6521
+ * never declared: Wyze before b4906cec6) still gets the save path's
6522
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6523
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6524
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6525
+ * builtin that keeps another addon's marker (device-manager) never takes it
6526
+ * over.
6527
+ */
6528
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6529
+ const added = /* @__PURE__ */ new Map();
6530
+ for (const key of keys) {
6531
+ const at = key.indexOf("@");
6532
+ const base = at > 0 ? key.slice(0, at) : key;
6533
+ if (declared.has(base) || added.has(base)) continue;
6534
+ const node = nodeFromStored(stored[key], owner);
6535
+ if (node !== null) added.set(base, node);
6536
+ }
6537
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6538
+ }
6539
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6540
+ async function readStoredAddonBlob(raw) {
6541
+ const threeWay = raw.readAddonStoreResult;
6542
+ if (threeWay === void 0) return raw.readAddonStore();
6543
+ const result = await threeWay.call(raw);
6544
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6545
+ return result.kind === "missing" ? {} : result.value;
6546
+ }
6547
+ function touchesTree(tree, patch) {
6548
+ if (tree.size === 0) return false;
6549
+ for (const key of Object.keys(patch)) {
6550
+ const at = key.indexOf("@");
6551
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6552
+ }
6553
+ return false;
6554
+ }
6555
+ /**
6556
+ * Which top-level keys of each store held markers when last seen. `undefined`
6557
+ * for a store not seen yet: its first write reads it, to be safe.
6558
+ */
6559
+ var MarkerKeyIndex = class {
6560
+ owner;
6561
+ byStore = /* @__PURE__ */ new Map();
6562
+ constructor(owner) {
6563
+ this.owner = owner;
6564
+ }
6565
+ seen(store, blob) {
6566
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6567
+ }
6568
+ wrote(store, patch) {
6569
+ const keys = this.byStore.get(store);
6570
+ if (keys === void 0) return;
6571
+ const now = markerKeysOf(patch, this.owner);
6572
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6573
+ else keys.delete(key);
6574
+ }
6575
+ mayHoldMarkers(store, patch) {
6576
+ const keys = this.byStore.get(store);
6577
+ if (keys === void 0) return true;
6578
+ return Object.keys(patch).some((key) => keys.has(key));
6579
+ }
6580
+ };
6581
+ function createHandle(raw, opts) {
6582
+ const chains = /* @__PURE__ */ new Map();
6583
+ const serialize = (key, fn) => {
6584
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6585
+ const tail = next.catch(() => void 0);
6586
+ chains.set(key, tail);
6587
+ tail.then(() => {
6588
+ if (chains.get(key) === tail) chains.delete(key);
6589
+ });
6590
+ return next;
6591
+ };
6592
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6593
+ const resolveRead = async (store, blob) => {
6594
+ index.seen(store, blob);
6595
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6596
+ unresolved: "keep-marker",
6597
+ ownedBy: opts.secrets.owner
6598
+ });
6599
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6600
+ return value;
6601
+ };
6602
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6603
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6604
+ await rawWrite(patch);
6605
+ index.wrote(store, patch);
6606
+ return { changed: true };
6607
+ }
6608
+ return serialize(store, async () => {
6609
+ const stored = await readStored();
6610
+ index.seen(store, stored);
6611
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6612
+ const restored = await restoreUnchangedSecrets({
6613
+ patch,
6614
+ stored,
6615
+ secrets: opts.secrets,
6616
+ operatorWrite
6617
+ });
6618
+ const result = await transformSecretWrite({
6619
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6620
+ secrets: opts.secrets,
6621
+ patch: restored.patch,
6622
+ stored,
6623
+ ...scope !== void 0 ? { scope } : {},
6624
+ operatorWrite
6625
+ });
6626
+ const effective = dropUnchangedKeys(result.patch, stored);
6627
+ const wroteBlob = Object.keys(effective).length > 0;
6628
+ if (wroteBlob) {
6629
+ await rawWrite(effective);
6630
+ index.wrote(store, effective);
6631
+ }
6632
+ const { orphaned } = await result.afterWrite();
6633
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6634
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6635
+ });
6636
+ };
6637
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6638
+ const readAddonStoreResult = raw.readAddonStoreResult;
6639
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6640
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6641
+ const overrides = {
6642
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6643
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6644
+ const result = await readAddonStoreResult.call(raw);
6645
+ return result.kind === "value" ? {
6646
+ kind: "value",
6647
+ value: await resolveRead("addon", result.value)
6648
+ } : result;
6649
+ } } : {},
6650
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6651
+ const result = await readAddonStoreKeyResult.call(raw, key);
6652
+ if (result.kind !== "present") return result;
6653
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6654
+ unresolved: "keep-marker",
6655
+ ownedBy: opts.secrets.owner
6656
+ });
6657
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6658
+ return {
6659
+ kind: "present",
6660
+ value: value[key]
6661
+ };
6662
+ } } : {},
6663
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6664
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6665
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6666
+ const out = /* @__PURE__ */ new Map();
6667
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6668
+ return out;
6669
+ } } : {},
6670
+ writeAddonStore: async (patch) => {
6671
+ await writeAddon(patch);
6672
+ },
6673
+ writeDeviceStore: async (deviceId, patch) => {
6674
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6675
+ kind: "device",
6676
+ deviceId
6677
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6678
+ }
6679
+ };
6680
+ return {
6681
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6682
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6683
+ const value = Reflect.get(target, prop, receiver);
6684
+ return typeof value === "function" ? value.bind(target) : value;
6685
+ } }),
6686
+ raw: {
6687
+ readAddonStore: async () => {
6688
+ const blob = await raw.readAddonStore();
6689
+ index.seen("addon", blob);
6690
+ return blob;
6691
+ },
6692
+ readDeviceStore: async (deviceId) => {
6693
+ const blob = await raw.readDeviceStore(deviceId);
6694
+ index.seen(`device:${deviceId}`, blob);
6695
+ return blob;
6696
+ }
6697
+ },
6698
+ writeAddonStore: writeAddon
6699
+ };
6700
+ }
6701
+ /** The context the addon sees, plus the private raw view and write outcome. */
6702
+ function createSecretAwareContext(context, opts) {
6703
+ const raw = context.settings;
6704
+ if (raw === void 0) return {
6705
+ context,
6706
+ handle: null
6707
+ };
6708
+ const handle = createHandle(raw, opts);
6709
+ return {
6710
+ context: new Proxy(context, { get(target, prop, receiver) {
6711
+ if (prop === "settings") return handle.settings;
6712
+ return Reflect.get(target, prop, receiver);
6713
+ } }),
6714
+ handle
6715
+ };
6716
+ }
6717
+ var LEAF = { kind: "leaf" };
6718
+ var DEFAULT_ITEM_ID_KEY = "id";
6719
+ function collectFields(fields, out) {
6720
+ for (const field of fields) {
6721
+ if (field.type === "group") {
6722
+ collectFields(field.fields, out);
6723
+ continue;
6724
+ }
6725
+ if (field.type === "sub-tabs") {
6726
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6727
+ continue;
6728
+ }
6729
+ if (field.type === "editable-array") {
6730
+ const item = /* @__PURE__ */ new Map();
6731
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6732
+ if (item.size > 0) out.set(field.key, {
6733
+ kind: "array",
6734
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6735
+ item
6736
+ });
6737
+ continue;
6738
+ }
6739
+ if (!("key" in field) || typeof field.key !== "string") continue;
6740
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6741
+ }
6742
+ }
6743
+ /** The secret tree a settings schema declares. */
6744
+ function secretTreeFromSchema(schema) {
6745
+ const out = /* @__PURE__ */ new Map();
6746
+ if (schema === null) return out;
6747
+ for (const section of schema.sections) collectFields(section.fields, out);
6748
+ return out;
6749
+ }
6750
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6751
+ function parseSecretStatePath(path) {
6752
+ const segments = [];
6753
+ for (const raw of path.split(".")) {
6754
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6755
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6756
+ segments.push(m[2] !== void 0 ? {
6757
+ key: m[1],
6758
+ idKey: m[2]
6759
+ } : { key: m[1] });
6760
+ }
6761
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6762
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6763
+ return segments;
6764
+ }
6765
+ function insert(into, segments) {
6766
+ const [head, ...rest] = segments;
6767
+ if (head === void 0) return;
6768
+ if (rest.length === 0) {
6769
+ into.set(head.key, LEAF);
6770
+ return;
6771
+ }
6772
+ const existing = into.get(head.key);
6773
+ if (head.idKey !== void 0) {
6774
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6775
+ insert(item, rest);
6776
+ into.set(head.key, {
6777
+ kind: "array",
6778
+ idKey: head.idKey,
6779
+ item
6780
+ });
6781
+ return;
6782
+ }
6783
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6784
+ insert(children, rest);
6785
+ into.set(head.key, {
6786
+ kind: "object",
6787
+ children
6788
+ });
6789
+ }
6790
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6791
+ function mergeSecretStatePaths(tree, paths) {
6792
+ if (paths.length === 0) return tree;
6793
+ const out = new Map(tree);
6794
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6795
+ return out;
6796
+ }
6797
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6798
+ var SECRET_RETRY_FIRST_MS = 5e3;
6799
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6800
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6801
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5919
6802
  /**
5920
6803
  * Base class for CamStack addons. Eliminates settings boilerplate:
5921
6804
  *
@@ -5985,6 +6868,33 @@ var BaseAddon = class {
5985
6868
  settingsStoreReady = false;
5986
6869
  /** Default config values. Provided via constructor. */
5987
6870
  defaults;
6871
+ /**
6872
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6873
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6874
+ * Stored in the keychain exactly like a `password` field. Syntax:
6875
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6876
+ * (`key[<id field>]` addresses array items by id, never by index).
6877
+ */
6878
+ secretStatePaths = [];
6879
+ _addonSecretTree = null;
6880
+ _deviceSecretTree = null;
6881
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6882
+ _configSecretRefs = /* @__PURE__ */ new Set();
6883
+ _unresolvedSecrets = [];
6884
+ _secretRetryTimer = null;
6885
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6886
+ _secretChangeTimer = null;
6887
+ _secretChangeUnsub = null;
6888
+ /** >0 while an OPERATOR's settings write is being applied. */
6889
+ _operatorWriteDepth = 0;
6890
+ /**
6891
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6892
+ * to the marker-bearing blobs and stays private to this class: the form
6893
+ * hydrate and config resolution need markers, addon code never does.
6894
+ */
6895
+ _secretSettings = null;
6896
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6897
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
5988
6898
  constructor(defaults) {
5989
6899
  this.defaults = defaults;
5990
6900
  this._config = { ...defaults };
@@ -6020,8 +6930,26 @@ var BaseAddon = class {
6020
6930
  return this._config;
6021
6931
  }
6022
6932
  async initialize(context) {
6023
- this._ctx = context;
6933
+ const secrets = context.secrets;
6934
+ if (secrets !== void 0) {
6935
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6936
+ secrets,
6937
+ addonTree: () => this.addonSecretTree(),
6938
+ deviceTree: () => this.deviceSecretTree(),
6939
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6940
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6941
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6942
+ });
6943
+ this._ctx = wrapped;
6944
+ this._secretSettings = handle;
6945
+ } else {
6946
+ this._ctx = context;
6947
+ this._secretSettings = null;
6948
+ }
6024
6949
  await this.resolveConfig();
6950
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6951
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6952
+ });
6025
6953
  const result = await this.onInitialize();
6026
6954
  this.emitLifecycle(EventCategory.AddonStarted);
6027
6955
  const normalized = normalizeAddonInitResult(result);
@@ -6054,6 +6982,12 @@ var BaseAddon = class {
6054
6982
  */
6055
6983
  async onHubReachable() {}
6056
6984
  async shutdown() {
6985
+ this._secretChangeUnsub?.();
6986
+ this._secretChangeUnsub = null;
6987
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
6988
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
6989
+ this._secretRetryTimer = null;
6990
+ this._secretChangeTimer = null;
6057
6991
  this.emitLifecycle(EventCategory.AddonStopped);
6058
6992
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6059
6993
  await this.onShutdown();
@@ -6128,11 +7062,8 @@ var BaseAddon = class {
6128
7062
  async getGlobalSettings(overlay, cap, nodeId) {
6129
7063
  const schema = this.globalSettingsSchema(cap);
6130
7064
  if (!schema) return { sections: [] };
6131
- const projected = await this.resolveGlobalStore(nodeId, cap);
6132
- return hydrateSchema(schema, overlay ? {
6133
- ...projected,
6134
- ...overlay
6135
- } : projected);
7065
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7066
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6136
7067
  }
6137
7068
  /**
6138
7069
  * The integration-level view of this addon's settings: exactly the sections
@@ -6177,11 +7108,11 @@ var BaseAddon = class {
6177
7108
  });
6178
7109
  }
6179
7110
  if (sections.length === 0) return null;
6180
- const projected = await this.resolveGlobalStore(nodeId);
7111
+ const projected = await this.readRawProjectedStore(nodeId);
6181
7112
  return hydrateSchema({
6182
7113
  ...schema,
6183
7114
  sections
6184
- }, projected);
7115
+ }, projected, { inlineSecretsAsViews: true });
6185
7116
  }
6186
7117
  /**
6187
7118
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6194,12 +7125,50 @@ var BaseAddon = class {
6194
7125
  * the store for custom option logic (option narrowing, value snapping) to
6195
7126
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6196
7127
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7128
+ *
7129
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7130
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7131
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7132
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7133
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7134
+ * resolved blob back is a no-op for every unchanged secret.
6197
7135
  */
6198
7136
  async resolveGlobalStore(nodeId, cap) {
6199
7137
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7138
+ return this.projectForNode(raw, nodeId, cap);
7139
+ }
7140
+ projectForNode(store, nodeId, cap) {
6200
7141
  const keys = this.perNodeKeys(cap);
6201
7142
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6202
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7143
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7144
+ }
7145
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7146
+ async readRawProjectedStore(nodeId, cap) {
7147
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7148
+ return this.projectForNode(raw, nodeId, cap);
7149
+ }
7150
+ /**
7151
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7152
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7153
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7154
+ * its value.
7155
+ */
7156
+ async overlayKeepingMarkers(stored, overlay) {
7157
+ const secrets = this._ctx?.secrets;
7158
+ const merged = {
7159
+ ...stored,
7160
+ ...overlay
7161
+ };
7162
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7163
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7164
+ unresolved: "keep-marker",
7165
+ ownedBy: secrets.owner
7166
+ });
7167
+ for (const key of Object.keys(overlay)) {
7168
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7169
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7170
+ }
7171
+ return merged;
6203
7172
  }
6204
7173
  /**
6205
7174
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6235,18 +7204,58 @@ var BaseAddon = class {
6235
7204
  value: result.value[key]
6236
7205
  };
6237
7206
  }
7207
+ /**
7208
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7209
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7210
+ * the operator sends is stored as sent even when it equals a pre-keychain
7211
+ * inline value: the operator re-entering a password is a change, an addon
7212
+ * writing back what it read is not (D787).
7213
+ */
7214
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7215
+ this._operatorWriteDepth++;
7216
+ try {
7217
+ await this.applyGlobalPatch(patch, nodeId);
7218
+ } finally {
7219
+ this._operatorWriteDepth--;
7220
+ }
7221
+ }
6238
7222
  async updateGlobalSettings(patch, nodeId) {
7223
+ await this.applyGlobalPatch(patch, nodeId);
7224
+ }
7225
+ /**
7226
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7227
+ *
7228
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7229
+ * what a defaults fallback writes back, and it must never destroy a
7230
+ * credential), so code that means "forget this token" says so here. Without
7231
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7232
+ */
7233
+ async clearSecrets(keys, nodeId) {
7234
+ const tree = this.addonSecretTree();
7235
+ const keychain = this._ctx?.secrets !== void 0;
7236
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7237
+ const patch = {};
7238
+ for (const key of keys) {
7239
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7240
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7241
+ }
7242
+ await this.applyGlobalPatch(patch, nodeId);
7243
+ }
7244
+ async applyGlobalPatch(barePatch, nodeId) {
6239
7245
  const keys = this.perNodeKeys();
6240
7246
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6241
7247
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6242
- const barePatch = patch;
6243
7248
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6244
- await this._ctx?.settings?.writeAddonStore(scoped);
7249
+ const handle = this._secretSettings;
7250
+ if (handle !== null) {
7251
+ const { changed } = await handle.writeAddonStore(scoped);
7252
+ if (!changed) return;
7253
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6245
7254
  if (target !== localNode) return;
6246
7255
  await this.resolveConfig();
6247
7256
  await this.onConfigChanged();
6248
7257
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6249
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7258
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6250
7259
  }
6251
7260
  /**
6252
7261
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6271,7 +7280,7 @@ var BaseAddon = class {
6271
7280
  * time to return its response before the addon is torn down and
6272
7281
  * re-initialised by `AddonRegistryService.restartAddon`.
6273
7282
  */
6274
- maybeAutoRestart(patch, schema) {
7283
+ maybeAutoRestart(patchKeys, schema) {
6275
7284
  if (!schema) return;
6276
7285
  const restartKeys = /* @__PURE__ */ new Set();
6277
7286
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6279,13 +7288,13 @@ var BaseAddon = class {
6279
7288
  if (field.requiresRestart) restartKeys.add(field.key);
6280
7289
  }
6281
7290
  if (restartKeys.size === 0) return;
6282
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7291
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6283
7292
  const ctx = this._ctx;
6284
7293
  if (!ctx) return;
6285
7294
  const addonId = ctx.id;
6286
7295
  setImmediate(() => {
6287
7296
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6288
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7297
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6289
7298
  }).catch((err) => {
6290
7299
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6291
7300
  });
@@ -6294,7 +7303,7 @@ var BaseAddon = class {
6294
7303
  async getDeviceSettings(deviceId) {
6295
7304
  const schema = this.deviceSettingsSchema();
6296
7305
  if (!schema) return { sections: [] };
6297
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7306
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6298
7307
  }
6299
7308
  async updateDeviceSettings(deviceId, patch) {
6300
7309
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6424,7 +7433,7 @@ var BaseAddon = class {
6424
7433
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6425
7434
  */
6426
7435
  async resolveConfig() {
6427
- const stored = await this.readAddonStoreWithRetry();
7436
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6428
7437
  const perNode = this.perNodeKeys();
6429
7438
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6430
7439
  const resolved = { ...this.defaults };
@@ -6449,7 +7458,7 @@ var BaseAddon = class {
6449
7458
  key,
6450
7459
  schema,
6451
7460
  fallback,
6452
- read: () => this.readAddonStoreWithRetry(),
7461
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6453
7462
  write: async (patch) => {
6454
7463
  await this._ctx?.settings?.writeAddonStore(patch);
6455
7464
  },
@@ -6466,7 +7475,7 @@ var BaseAddon = class {
6466
7475
  key,
6467
7476
  schema,
6468
7477
  fallback,
6469
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7478
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
6470
7479
  write: async (patch) => {
6471
7480
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6472
7481
  },
@@ -6478,6 +7487,87 @@ var BaseAddon = class {
6478
7487
  } })
6479
7488
  });
6480
7489
  }
7490
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7491
+ addonSecretTree() {
7492
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7493
+ return this._addonSecretTree;
7494
+ }
7495
+ deviceSecretTree() {
7496
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7497
+ return this._deviceSecretTree;
7498
+ }
7499
+ /**
7500
+ * Secrets of this addon's stored config that could not be resolved on the
7501
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7502
+ * an addon whose function needs one should report itself degraded rather
7503
+ * than start on an empty credential.
7504
+ */
7505
+ get unresolvedSecrets() {
7506
+ return this._unresolvedSecrets;
7507
+ }
7508
+ /**
7509
+ * Substitute every keychain marker in a stored blob with its value. With no
7510
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7511
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7512
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7513
+ * ever written back from here.
7514
+ */
7515
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7516
+ const secrets = this._ctx?.secrets;
7517
+ if (secrets === void 0) return blob;
7518
+ const refs = collectSecretMarkerRefs(blob);
7519
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7520
+ if (refs.length === 0) {
7521
+ if (trackForConfig) this._unresolvedSecrets = [];
7522
+ return blob;
7523
+ }
7524
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7525
+ if (trackForConfig) {
7526
+ this._unresolvedSecrets = unresolved;
7527
+ if (unresolved.length > 0) {
7528
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7529
+ ref: u.ref,
7530
+ reason: u.reason
7531
+ })) } });
7532
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7533
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7534
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7535
+ }
7536
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7537
+ }
7538
+ return value;
7539
+ }
7540
+ /**
7541
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7542
+ * keychain the context's own view is already raw.
7543
+ */
7544
+ rawSettings() {
7545
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7546
+ }
7547
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7548
+ logUnresolvedRead(unresolved) {
7549
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7550
+ if (fresh.length === 0) return;
7551
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7552
+ 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) => ({
7553
+ ref: u.ref,
7554
+ reason: u.reason
7555
+ })) } });
7556
+ }
7557
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7558
+ scheduleSecretReresolve(delayMs) {
7559
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7560
+ if (this[timerOf] !== null) return;
7561
+ const timer = setTimeout(() => {
7562
+ this[timerOf] = null;
7563
+ if (this._ctx === null) return;
7564
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7565
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7566
+ });
7567
+ }, delayMs);
7568
+ timer.unref?.();
7569
+ this[timerOf] = timer;
7570
+ }
6481
7571
  /**
6482
7572
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6483
7573
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -6490,7 +7580,7 @@ var BaseAddon = class {
6490
7580
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
6491
7581
  */
6492
7582
  async readAddonStoreWithRetry() {
6493
- const settings = this._ctx?.settings;
7583
+ const settings = this.rawSettings();
6494
7584
  if (!settings) return {};
6495
7585
  const delaysMs = [
6496
7586
  150,
@@ -7053,6 +8143,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7053
8143
  kind: "mutation",
7054
8144
  auth: "admin"
7055
8145
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
8146
+ function defOf(schema) {
8147
+ return schema._zod?.def ?? {};
8148
+ }
8149
+ function declaredHere(schema) {
8150
+ return globalRegistry.get(schema)?.secret === true;
8151
+ }
8152
+ /** Wrapper kinds whose `innerType` is the field itself. */
8153
+ var WRAPPERS = new Set([
8154
+ "optional",
8155
+ "nullable",
8156
+ "default",
8157
+ "prefault",
8158
+ "catch",
8159
+ "readonly",
8160
+ "nonoptional"
8161
+ ]);
8162
+ /**
8163
+ * The schema layers that make up ONE field: the schema itself and every
8164
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8165
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8166
+ * `.transform` on `in`).
8167
+ */
8168
+ function layersOf(schema) {
8169
+ const out = [];
8170
+ const queue = [schema];
8171
+ while (queue.length > 0) {
8172
+ const s = queue.shift();
8173
+ if (!s || out.includes(s)) continue;
8174
+ out.push(s);
8175
+ const def = defOf(s);
8176
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8177
+ if (def.type === "pipe") {
8178
+ if (def.in) queue.push(def.in);
8179
+ if (def.out) queue.push(def.out);
8180
+ }
8181
+ }
8182
+ return out;
8183
+ }
8184
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8185
+ function isZodSecret(schema) {
8186
+ return layersOf(schema).some(declaredHere);
8187
+ }
8188
+ /**
8189
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8190
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8191
+ * object or array is reported as one path and not descended into — everything
8192
+ * under it is secret.
8193
+ */
8194
+ function collectZodSecretPaths(schema, prefix = "") {
8195
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8196
+ const paths = [];
8197
+ for (const layer of layersOf(schema)) {
8198
+ const def = defOf(layer);
8199
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8200
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8201
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8202
+ else if (def.type === "intersection") {
8203
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8204
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8205
+ }
8206
+ }
8207
+ return [...new Set(paths)];
8208
+ }
7056
8209
  //#endregion
7057
8210
  //#region ../types/dist/err-msg-DX6i_MY4.mjs
7058
8211
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
@@ -8730,6 +9883,278 @@ var CameraSwitchGroupSchema = object({
8730
9883
  fetchedAt: number()
8731
9884
  });
8732
9885
  /**
9886
+ * The trainer contract — what the hub hands the cloud trainer and what it
9887
+ * gets back (cloud training, D805+).
9888
+ *
9889
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9890
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9891
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9892
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9893
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9894
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9895
+ * change there, in the same piece of work.
9896
+ *
9897
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9898
+ * orchestrator fills every field of a job spec explicitly.
9899
+ */
9900
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9901
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9902
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9903
+ var TrainingExportSchema = _enum([
9904
+ "onnx",
9905
+ "openvino-fp16",
9906
+ "openvino-int8",
9907
+ "coreml-fp16"
9908
+ ]);
9909
+ var FloorsSchema = record(string(), number().min(0).max(1));
9910
+ object({
9911
+ schema: literal(TRAINING_JOB_SCHEMA),
9912
+ jobKey: string().uuid(),
9913
+ target: object({
9914
+ kind: literal("detector"),
9915
+ step: literal("object-detection")
9916
+ }),
9917
+ base: object({
9918
+ modelId: string().min(1),
9919
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9920
+ weights: string().min(1),
9921
+ imgsz: number().int().positive()
9922
+ }),
9923
+ baseline: object({
9924
+ modelId: string().min(1),
9925
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9926
+ onnxUrl: string().url(),
9927
+ imgsz: number().int().positive(),
9928
+ floors: FloorsSchema
9929
+ }),
9930
+ dataset: object({
9931
+ versionId: string().min(1),
9932
+ annotationHash: string(),
9933
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9934
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9935
+ }),
9936
+ split: object({
9937
+ holdoutCameras: array(number().int()),
9938
+ /** When no camera is held out: the last N days of every camera. */
9939
+ holdoutLastDays: number().int().nonnegative(),
9940
+ valFraction: number().min(0).max(.5),
9941
+ seed: number().int()
9942
+ }),
9943
+ hyper: object({
9944
+ epochs: number().int().positive(),
9945
+ batch: number().int().positive(),
9946
+ lr0: number().positive(),
9947
+ /** Layers frozen from the start of the backbone; 0 = none. */
9948
+ freeze: number().int().nonnegative(),
9949
+ patience: number().int().nonnegative(),
9950
+ seed: number().int()
9951
+ }),
9952
+ replay: object({
9953
+ source: literal("coco2017"),
9954
+ count: number().int().nonnegative()
9955
+ }),
9956
+ exports: array(TrainingExportSchema).min(1),
9957
+ calibration: object({ maxFrames: number().int().positive() }),
9958
+ floors: object({
9959
+ minSupport: number().int().positive(),
9960
+ clamp: number().min(0).max(1)
9961
+ }),
9962
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9963
+ catalog: object({
9964
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9965
+ name: string().min(1).max(160)
9966
+ })
9967
+ });
9968
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9969
+ var TrainingResultFileSchema = object({
9970
+ path: string().min(1),
9971
+ bytes: number().int().nonnegative(),
9972
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9973
+ format: _enum([
9974
+ "onnx",
9975
+ "openvino",
9976
+ "coreml",
9977
+ "pt"
9978
+ ]),
9979
+ variant: _enum(["base", "int8"])
9980
+ });
9981
+ var DraftFormatSchema = object({
9982
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9983
+ url: string().min(1),
9984
+ sizeMB: number().nonnegative(),
9985
+ isDirectory: boolean().optional(),
9986
+ files: array(string()).optional(),
9987
+ runtimes: array(literal("python")).optional(),
9988
+ revision: string().min(1)
9989
+ });
9990
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9991
+ var TrainingCatalogDraftSchema = object({
9992
+ id: string().min(1),
9993
+ name: string().min(1),
9994
+ description: string(),
9995
+ labels: array(unknown()),
9996
+ inputSize: object({
9997
+ width: number().int().positive(),
9998
+ height: number().int().positive()
9999
+ }),
10000
+ preprocessMode: literal("letterbox"),
10001
+ defaultClassFloors: FloorsSchema,
10002
+ formats: object({
10003
+ onnx: DraftFormatSchema.optional(),
10004
+ openvino: DraftFormatSchema.optional(),
10005
+ coreml: DraftFormatSchema.optional()
10006
+ })
10007
+ });
10008
+ /** One class of one model's holdout report (the eval harness's summary). */
10009
+ var TrainingEvalClassSchema = object({
10010
+ positives: number().int(),
10011
+ floor: number().nullable(),
10012
+ tp: number().int(),
10013
+ fp: number().int(),
10014
+ fn: number().int(),
10015
+ precision: number().nullable(),
10016
+ recall: number().nullable(),
10017
+ ap50: number().nullable(),
10018
+ recallByCamera: record(string(), number().nullable()).optional(),
10019
+ recallByLight: record(string(), number().nullable()).optional(),
10020
+ fpByCamera: record(string(), number()).optional(),
10021
+ smallFound: number().int().optional(),
10022
+ smallTotal: number().int().optional()
10023
+ }).passthrough();
10024
+ var TrainingEvalReportSchema = object({
10025
+ frames: number().int(),
10026
+ classes: record(string(), TrainingEvalClassSchema)
10027
+ }).passthrough();
10028
+ /**
10029
+ * A succeeded result carries every block; a failed one carries the error and
10030
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10031
+ * orchestrator checks the blocks it needs before it trusts a success.
10032
+ */
10033
+ var TrainingResultSchema = object({
10034
+ schema: literal(TRAINING_RESULT_SCHEMA),
10035
+ jobKey: string(),
10036
+ status: _enum(["succeeded", "failed"]),
10037
+ error: object({
10038
+ stage: string(),
10039
+ code: string(),
10040
+ message: string()
10041
+ }).nullable(),
10042
+ trainer: object({
10043
+ version: string(),
10044
+ revision: string()
10045
+ }),
10046
+ toolchain: record(string(), string().nullable()),
10047
+ dataset: object({
10048
+ versionId: string(),
10049
+ annotationHash: string(),
10050
+ sha256: string(),
10051
+ frames: object({
10052
+ train: number().int(),
10053
+ val: number().int(),
10054
+ holdout: number().int()
10055
+ }),
10056
+ holdoutCameras: array(number().int()),
10057
+ replayImages: number().int()
10058
+ }).optional(),
10059
+ training: object({
10060
+ epochsRun: number().int(),
10061
+ bestEpoch: number().int(),
10062
+ bestMap50: number(),
10063
+ bestMap50_95: number(),
10064
+ seconds: number()
10065
+ }).optional(),
10066
+ evaluation: object({
10067
+ holdoutFrames: number().int(),
10068
+ baseline: TrainingEvalReportSchema.nullable(),
10069
+ candidate: TrainingEvalReportSchema.nullable(),
10070
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10071
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10072
+ map50: record(string(), number().nullable())
10073
+ }).optional(),
10074
+ floors: object({
10075
+ baseline: FloorsSchema,
10076
+ candidate: FloorsSchema,
10077
+ candidateInt8: FloorsSchema.nullable(),
10078
+ notes: array(string())
10079
+ }).optional(),
10080
+ int8: object({
10081
+ kept: boolean(),
10082
+ map50Fp16: number().nullable(),
10083
+ map50Int8: number().nullable(),
10084
+ reason: string().nullable()
10085
+ }).optional(),
10086
+ exportsDropped: array(object({
10087
+ export: string(),
10088
+ reason: string()
10089
+ })).optional(),
10090
+ files: array(TrainingResultFileSchema).optional(),
10091
+ bundle: object({
10092
+ path: literal("bundle.tar"),
10093
+ bytes: number().int().nonnegative(),
10094
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10095
+ }).nullable().optional(),
10096
+ catalogDraft: object({
10097
+ base: TrainingCatalogDraftSchema,
10098
+ int8: TrainingCatalogDraftSchema.nullable()
10099
+ }).nullable().optional(),
10100
+ licence: string()
10101
+ });
10102
+ var TrainingStageSchema = _enum([
10103
+ "prepare",
10104
+ "replay",
10105
+ "train",
10106
+ "eval",
10107
+ "export",
10108
+ "package"
10109
+ ]);
10110
+ var EventBase = {
10111
+ v: literal(1),
10112
+ ts: number()
10113
+ };
10114
+ discriminatedUnion("type", [
10115
+ object({
10116
+ ...EventBase,
10117
+ type: literal("stage"),
10118
+ stage: TrainingStageSchema
10119
+ }),
10120
+ object({
10121
+ ...EventBase,
10122
+ type: literal("epoch"),
10123
+ epoch: number().int(),
10124
+ epochs: number().int(),
10125
+ boxLoss: number().nullable().optional(),
10126
+ map50: number().nullable().optional(),
10127
+ map50_95: number().nullable().optional(),
10128
+ etaSec: number().nullable().optional()
10129
+ }),
10130
+ object({
10131
+ ...EventBase,
10132
+ type: literal("metric"),
10133
+ name: string(),
10134
+ value: number()
10135
+ }),
10136
+ object({
10137
+ ...EventBase,
10138
+ type: literal("artifact"),
10139
+ path: string(),
10140
+ bytes: number(),
10141
+ sha256: string()
10142
+ }),
10143
+ object({
10144
+ ...EventBase,
10145
+ type: literal("done"),
10146
+ status: _enum(["succeeded", "failed"]),
10147
+ resultSha256: string().nullable().optional()
10148
+ }),
10149
+ object({
10150
+ ...EventBase,
10151
+ type: literal("error"),
10152
+ stage: string(),
10153
+ code: string(),
10154
+ message: string()
10155
+ })
10156
+ ]);
10157
+ /**
8733
10158
  * What the gate decided about a birth, from the CALLER's point of view.
8734
10159
  *
8735
10160
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11057,7 +12482,9 @@ var AddonHttpRouteSchema = object({
11057
12482
  "authenticated",
11058
12483
  "admin"
11059
12484
  ]).optional(),
11060
- description: string().optional()
12485
+ description: string().optional(),
12486
+ /** The hub limits this route per client address before the handler runs. */
12487
+ rateLimit: _enum(["auth"]).optional()
11061
12488
  });
11062
12489
  /**
11063
12490
  * Cross-process route invocation envelope. The hub captures the
@@ -11762,6 +13189,37 @@ var BackupDestinationInfoSchema = object({
11762
13189
  lastError: string().optional()
11763
13190
  });
11764
13191
  /**
13192
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13193
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13194
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13195
+ * with it off — which restores without a key.
13196
+ */
13197
+ var BackupArchiveEncryptionSchema = object({
13198
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13199
+ scheme: string(),
13200
+ /** 16 hex — the backup key whose secret restores this archive. */
13201
+ keyId: string()
13202
+ });
13203
+ /**
13204
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13205
+ * one new archives are encrypted to, and the retired ones older archives
13206
+ * still need. The secret key is shown once, at `setupEncryption`.
13207
+ */
13208
+ var BackupEncryptionStatusSchema = object({
13209
+ enabled: boolean(),
13210
+ active: object({
13211
+ keyId: string(),
13212
+ publicKey: string(),
13213
+ createdAt: number()
13214
+ }).nullable(),
13215
+ /** Every key ever set up, newest first. */
13216
+ keys: array(object({
13217
+ keyId: string(),
13218
+ createdAt: number(),
13219
+ retiredAt: number().nullable()
13220
+ })).readonly()
13221
+ });
13222
+ /**
11765
13223
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
11766
13224
  * Same shape the destination drill-in renders. Sourced from the per-
11767
13225
  * location `manifests.json` (no per-archive tarball read required).
@@ -11773,7 +13231,9 @@ var BackupArchiveEntrySchema = object({
11773
13231
  sizeBytes: number(),
11774
13232
  label: string().optional(),
11775
13233
  /** Top-level locations included in the archive (db, addons, tls, …). */
11776
- locations: array(string()).readonly()
13234
+ locations: array(string()).readonly(),
13235
+ /** Present when the archive is encrypted; restore then needs that key. */
13236
+ encryption: BackupArchiveEncryptionSchema.optional()
11777
13237
  });
11778
13238
  var BackupEntrySchema = object({
11779
13239
  id: string(),
@@ -11782,7 +13242,8 @@ var BackupEntrySchema = object({
11782
13242
  label: string().optional(),
11783
13243
  createdAt: number(),
11784
13244
  sizeBytes: number(),
11785
- locations: array(string()).optional()
13245
+ locations: array(string()).optional(),
13246
+ encryption: BackupArchiveEncryptionSchema.optional()
11786
13247
  });
11787
13248
  var ArchiveEntrySchema = object({
11788
13249
  path: string(),
@@ -11971,10 +13432,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
11971
13432
  * this list and skips entries whose path doesn't start with
11972
13433
  * any of them.
11973
13434
  */
11974
- locations: array(string()).optional()
13435
+ locations: array(string()).optional(),
13436
+ /**
13437
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13438
+ * one). The archive is decrypted into the hub's private staging
13439
+ * before the restart; the key is not stored. A wrong or missing key
13440
+ * is refused before the archive is downloaded.
13441
+ */
13442
+ backupSecretKey: string().optional()
11975
13443
  }), _void(), {
11976
13444
  kind: "mutation",
11977
13445
  auth: "admin"
13446
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13447
+ keyId: string(),
13448
+ secretKey: string(),
13449
+ publicKey: string(),
13450
+ createdAt: number(),
13451
+ replacedKeyId: string().nullable()
13452
+ }), {
13453
+ kind: "mutation",
13454
+ auth: "admin"
13455
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13456
+ kind: "mutation",
13457
+ auth: "admin"
13458
+ }), method(object({ backupSecretKey: string() }), object({
13459
+ valid: boolean(),
13460
+ keyId: string().nullable(),
13461
+ /** The hub knows this key (active or retired). */
13462
+ known: boolean(),
13463
+ /** It is the key new archives are encrypted to. */
13464
+ active: boolean(),
13465
+ error: string().optional()
13466
+ }), {
13467
+ kind: "mutation",
13468
+ auth: "admin"
11978
13469
  }), method(object({
11979
13470
  destinationId: string(),
11980
13471
  backupId: string()
@@ -13749,7 +15240,60 @@ var CustomModelDescriptorSchema = object({
13749
15240
  stepId: string(),
13750
15241
  entry: ModelCatalogEntrySchema
13751
15242
  });
13752
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15243
+ /** One regular file of an imported bundle, as the producer measured it. */
15244
+ var ModelBundleFileSchema = object({
15245
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15246
+ path: string().min(1),
15247
+ bytes: number().int().nonnegative(),
15248
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15249
+ });
15250
+ var ImportModelBundleInputSchema = object({
15251
+ /** The registry provider that keeps the model (Model Studio). */
15252
+ addonId: string(),
15253
+ stepId: string().min(1),
15254
+ /**
15255
+ * The catalog rows to register, complete, every format URL already
15256
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15257
+ * bundle may carry several rows (a base and its INT8 variant).
15258
+ */
15259
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15260
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15261
+ bundle: object({
15262
+ ticket: PeerBytesTicketSchema,
15263
+ bytes: number().int().positive(),
15264
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15265
+ }),
15266
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15267
+ files: array(ModelBundleFileSchema).min(1).max(64),
15268
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15269
+ distribute: boolean()
15270
+ });
15271
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15272
+ kind: literal("imported"),
15273
+ modelIds: array(string()).readonly(),
15274
+ distributed: array(object({
15275
+ modelId: string(),
15276
+ nodeId: string(),
15277
+ format: _enum(MODEL_FORMATS),
15278
+ ok: boolean(),
15279
+ error: string().optional()
15280
+ })).readonly()
15281
+ }), object({
15282
+ kind: literal("refused"),
15283
+ reason: _enum([
15284
+ "transfer-failed",
15285
+ "checksum-mismatch",
15286
+ "bundle-mismatch",
15287
+ "invalid-entry",
15288
+ "id-taken"
15289
+ ]),
15290
+ detail: string()
15291
+ })]);
15292
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15293
+ kind: "mutation",
15294
+ auth: "admin",
15295
+ timeoutMs: 30 * 6e4
15296
+ });
13753
15297
  /**
13754
15298
  * Query filter for settings-store collections.
13755
15299
  */
@@ -14132,6 +15676,253 @@ id: union([string(), number()]) }), {
14132
15676
  kind: "mutation",
14133
15677
  auth: "admin"
14134
15678
  });
15679
+ /**
15680
+ * `keychain` — the hub's encrypted store of secret values (D787).
15681
+ *
15682
+ * Settings blobs never hold a secret: they hold a marker
15683
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15684
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15685
+ * is the OWNER's door to its own values: every method is owner-checked
15686
+ * against the CALLER, never against anything the caller claims.
15687
+ *
15688
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15689
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15690
+ * connection, the agent from its child's connection carried in
15691
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15692
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15693
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15694
+ * identity against BUGS and misrouting, not against a malicious addon (every
15695
+ * runner is the same OS user): see the threat model in
15696
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15697
+ *
15698
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15699
+ * parses the input, so a session can never supply it, and the internal mount
15700
+ * floors every method to admin anyway (D240).
15701
+ *
15702
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15703
+ */
15704
+ /** Why a value cannot be served right now. Never folded into "missing". */
15705
+ var KeychainUnavailableReasonSchema = _enum([
15706
+ "key-missing",
15707
+ "wrong-key",
15708
+ "key-file-unreadable",
15709
+ "store-unavailable",
15710
+ "not-initialized",
15711
+ "decrypt-failed"
15712
+ ]);
15713
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15714
+ state: literal("locked"),
15715
+ reason: KeychainUnavailableReasonSchema
15716
+ })]);
15717
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15718
+ object({
15719
+ kind: literal("value"),
15720
+ value: string(),
15721
+ version: number().int()
15722
+ }),
15723
+ object({ kind: literal("missing") }),
15724
+ object({
15725
+ kind: literal("unavailable"),
15726
+ reason: KeychainUnavailableReasonSchema
15727
+ }),
15728
+ object({ kind: literal("forbidden") })
15729
+ ]);
15730
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15731
+ /** Metadata of one stored value — never the value. */
15732
+ var KeychainSecretMetaSchema = object({
15733
+ ref: string(),
15734
+ owner: string(),
15735
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15736
+ scope: string(),
15737
+ fieldPath: string(),
15738
+ version: number().int(),
15739
+ createdAt: number(),
15740
+ updatedAt: number(),
15741
+ /** `addon:<id>` | `user:<id>` | `system`. */
15742
+ updatedBy: string(),
15743
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15744
+ lastReadAt: number().nullable()
15745
+ });
15746
+ var RefListSchema = array(string().min(1)).max(512);
15747
+ method(object({
15748
+ ref: string().min(1),
15749
+ value: string().min(1)
15750
+ }), object({
15751
+ ref: string(),
15752
+ version: number().int()
15753
+ }), {
15754
+ kind: "mutation",
15755
+ auth: "admin"
15756
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15757
+ kind: "mutation",
15758
+ auth: "admin"
15759
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15760
+ var KeychainKeySourceSchema = object({
15761
+ kind: _enum([
15762
+ "config-file",
15763
+ "previous-config-file",
15764
+ "platform",
15765
+ "default-file"
15766
+ ]),
15767
+ /** File sources only — a path is not a secret. */
15768
+ path: string().optional(),
15769
+ /**
15770
+ * True when a whole-volume backup of the data directory carries this key
15771
+ * next to the database it protects (the default file). The page warns.
15772
+ */
15773
+ sharesBackupWithDatabase: boolean()
15774
+ });
15775
+ /**
15776
+ * One keychain reset, as the Secrets page reports it until the operator
15777
+ * acknowledges it. Never a value: refs, counts and table names only.
15778
+ */
15779
+ var KeychainResetRecordSchema = object({
15780
+ id: string(),
15781
+ at: number(),
15782
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15783
+ actor: string(),
15784
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15785
+ lockedReason: string().nullable(),
15786
+ /** Values moved into the archive table (ciphertext under the lost key). */
15787
+ archived: number().int(),
15788
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15789
+ archivedCollection: string().nullable(),
15790
+ /**
15791
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15792
+ * so the archive can still be opened if the lost master key turns up.
15793
+ */
15794
+ archivedKeysCollection: string().nullable(),
15795
+ /**
15796
+ * `system-settings` keys whose marker the reset cleared — the cluster
15797
+ * secret's: a marker left pointing at an archived value would refuse every
15798
+ * agent forever (D797).
15799
+ */
15800
+ clearedSettingsKeys: array(string()).readonly(),
15801
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15802
+ acknowledgedAt: number().nullable()
15803
+ });
15804
+ var KeychainStatusSchema = object({
15805
+ keychain: KeychainStateSchema,
15806
+ /** The source of the master key in use; `null` while locked. */
15807
+ keySource: KeychainKeySourceSchema.nullable(),
15808
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15809
+ configuredSource: KeychainKeySourceSchema,
15810
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15811
+ fingerprint: string().nullable(),
15812
+ activeKeyId: string().nullable(),
15813
+ /**
15814
+ * The keychain unlocked with a NON-primary source: the configured primary
15815
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15816
+ */
15817
+ rotationPending: boolean(),
15818
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15819
+ retiredWraps: number().int(),
15820
+ recoveryKeyDownloadedAt: number().nullable(),
15821
+ secretCount: number().int(),
15822
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15823
+ lastReset: KeychainResetRecordSchema.nullable()
15824
+ });
15825
+ /**
15826
+ * Whether a stored value is still pointed at by its owner's settings.
15827
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15828
+ * never reported as an orphan (and never deleted as one).
15829
+ */
15830
+ var KeychainSecretUsageSchema = _enum([
15831
+ "in-use",
15832
+ "orphan",
15833
+ "unknown"
15834
+ ]);
15835
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15836
+ var KeychainAuditActionSchema = _enum([
15837
+ "put",
15838
+ "delete",
15839
+ "reveal",
15840
+ "rotate-master-key",
15841
+ "purge-retired-keys",
15842
+ "download-recovery-key",
15843
+ "delete-orphans",
15844
+ "reset",
15845
+ "acknowledge-reset",
15846
+ "initialize"
15847
+ ]);
15848
+ var KeychainAuditEntrySchema = object({
15849
+ id: string(),
15850
+ at: number(),
15851
+ action: KeychainAuditActionSchema,
15852
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15853
+ actor: string(),
15854
+ ref: string().nullable(),
15855
+ detail: string().nullable()
15856
+ });
15857
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15858
+ /**
15859
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15860
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15861
+ * never an orphan; it is generated on a fresh hub and replaced only through
15862
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15863
+ */
15864
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15865
+ 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({
15866
+ value: string(),
15867
+ version: number().int()
15868
+ }), {
15869
+ kind: "mutation",
15870
+ auth: "admin",
15871
+ caller: "required"
15872
+ }), method(object({
15873
+ name: SystemHeldSecretNameSchema,
15874
+ value: string().min(16)
15875
+ }), object({
15876
+ ref: string(),
15877
+ version: number().int()
15878
+ }), {
15879
+ kind: "mutation",
15880
+ auth: "admin",
15881
+ caller: "required"
15882
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15883
+ deleted: array(string()).readonly(),
15884
+ kept: array(object({
15885
+ ref: string(),
15886
+ usage: KeychainSecretUsageSchema
15887
+ })).readonly()
15888
+ }), {
15889
+ kind: "mutation",
15890
+ auth: "admin",
15891
+ caller: "required"
15892
+ }), method(object({}), object({
15893
+ fingerprint: string(),
15894
+ keySource: KeychainKeySourceSchema
15895
+ }), {
15896
+ kind: "mutation",
15897
+ auth: "admin",
15898
+ caller: "required"
15899
+ }), method(object({}), object({ purged: number().int() }), {
15900
+ kind: "mutation",
15901
+ auth: "admin",
15902
+ caller: "required"
15903
+ }), method(object({}), object({
15904
+ key: string(),
15905
+ fingerprint: string(),
15906
+ keySource: KeychainKeySourceSchema
15907
+ }), {
15908
+ kind: "mutation",
15909
+ auth: "admin",
15910
+ caller: "required"
15911
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15912
+ archivedCollection: string().nullable(),
15913
+ archived: number().int()
15914
+ }), {
15915
+ kind: "mutation",
15916
+ auth: "admin",
15917
+ caller: "required"
15918
+ }), method(object({}), object({
15919
+ reset: KeychainResetRecordSchema.nullable(),
15920
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15921
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15922
+ kind: "mutation",
15923
+ auth: "admin",
15924
+ caller: "required"
15925
+ });
14135
15926
  method(_void(), object({
14136
15927
  id: string(),
14137
15928
  name: string(),
@@ -15487,7 +17278,11 @@ var DeviceRegisterPayloadSchema = object({
15487
17278
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15488
17279
  var DevicePersistConfigPayloadSchema = object({
15489
17280
  deviceId: number(),
15490
- data: record(string(), unknown())
17281
+ data: record(string(), unknown()),
17282
+ /** The paths the device's schema declares secret (D783), when the caller
17283
+ * knows them — those values are kept in the keychain, not the blob (D787).
17284
+ * Absent: the paths the device last reported at `registerDevice` apply. */
17285
+ secretConfigPaths: array(string()).optional()
15491
17286
  });
15492
17287
  /** What a migration actually did, per switch. `unreachable` is a first-class
15493
17288
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -17090,7 +18885,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17090
18885
  * `login-method` — collection cap through which auth addons contribute
17091
18886
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17092
18887
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17093
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18888
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17094
18889
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17095
18890
  * procedure aggregates them for the unauthenticated login page.
17096
18891
  *
@@ -17098,8 +18893,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17098
18893
  *
17099
18894
  * - `redirect` — a declarative button. The login page renders a generic
17100
18895
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17101
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17102
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18896
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17103
18897
  * login page needs NO change.
17104
18898
  *
17105
18899
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17118,8 +18912,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17118
18912
  * decision.
17119
18913
  *
17120
18914
  * Every contribution carries a `stage`:
17121
- * - `primary` — shown on the first credentials screen (OIDC /
17122
- * magic-link buttons; a future usernameless passkey).
18915
+ * - `primary` — shown on the first credentials screen (OIDC
18916
+ * buttons; a usernameless passkey).
17123
18917
  * - `second-factor` — shown AFTER the password leg, gated on the
17124
18918
  * returned `factors` (passkey-as-2FA today).
17125
18919
  *
@@ -17146,7 +18940,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17146
18940
  * The provider names an external identity a signed-in user can link to
17147
18941
  * their own account (D782): `auth.listLinkableProviders` /
17148
18942
  * `beginExternalLink` offer exactly the redirect methods that set this,
17149
- * whatever their id. Absent / false — a login button only (magic-link).
18943
+ * whatever their id. Absent / false — a login button only.
17150
18944
  */
17151
18945
  linkable: boolean().optional()
17152
18946
  }),
@@ -21001,8 +22795,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21001
22795
  * `super_admin` — collapsed onto the single boolean because every
21002
22796
  * non-admin caller is governed by the same scope-check rules; the
21003
22797
  * distinction was only ever used to route role-specific procedures
21004
- * which we no longer have. Agents are admin sessions issued via
21005
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22798
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21006
22799
  * with `isAdmin: false` + an explicit scope list.
21007
22800
  */
21008
22801
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22504,8 +24297,23 @@ var RetrainMacroClassSchema = _enum([
22504
24297
  ]);
22505
24298
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22506
24299
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22507
- /** Did a human draw this box, or did the assist propose it? */
22508
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
24300
+ /**
24301
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
24302
+ * the operator confirms it; once saved it keeps its source as provenance.
24303
+ *
24304
+ * - `operator` — drawn by hand.
24305
+ * - `assist` — proposed by a detector run on the copy (the camera's own
24306
+ * model, or a larger teacher model).
24307
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
24308
+ * back from the track store (never a re-run).
24309
+ * - `llm` — proposed by a vision-capable LLM profile.
24310
+ */
24311
+ var RetrainAnnotationSourceSchema = _enum([
24312
+ "operator",
24313
+ "assist",
24314
+ "pipeline",
24315
+ "llm"
24316
+ ]);
22509
24317
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22510
24318
  var RetrainBboxSchema = object({
22511
24319
  x: number(),
@@ -22523,7 +24331,8 @@ var RetrainBboxSchema = object({
22523
24331
  */
22524
24332
  var RetrainAnnotationSchema = object({
22525
24333
  id: string(),
22526
- trackId: string(),
24334
+ /** The frame's track. Absent on a recording still, which has none. */
24335
+ trackId: string().optional(),
22527
24336
  deviceId: number(),
22528
24337
  /** The COPY in retrain storage — never the source track's media key. */
22529
24338
  mediaKey: string(),
@@ -22572,13 +24381,47 @@ var RetrainFrameCandidateSchema = object({
22572
24381
  * fail, whatever became of the original. */
22573
24382
  copied: boolean()
22574
24383
  });
24384
+ /**
24385
+ * One box the live pipeline drew on a copied frame — what a correction starts
24386
+ * from. Derived when the frame is listed, from the track store: the subject
24387
+ * box recorded on the source media row when there is one, else the track
24388
+ * position nearest the frame's capture time. Never stored as an annotation
24389
+ * until the operator confirms it.
24390
+ */
24391
+ var RetrainPipelineBoxSchema = object({
24392
+ /** Normalised `[0,1]` against the full frame. */
24393
+ bbox: RetrainBboxSchema,
24394
+ macroClass: RetrainMacroClassSchema,
24395
+ label: string().optional(),
24396
+ subLabel: string().optional(),
24397
+ /** The detection score of the position used, when it was recorded. */
24398
+ score: number().optional(),
24399
+ /** The root model that produced the track, when it was recorded. */
24400
+ modelId: string().optional(),
24401
+ trackId: string(),
24402
+ /** `subject-box`: recorded on this very frame. `position`: the track's
24403
+ * position nearest the capture time, `deltaMs` away. */
24404
+ basis: _enum(["subject-box", "position"]),
24405
+ deltaMs: number()
24406
+ });
24407
+ /**
24408
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
24409
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
24410
+ * track at all.
24411
+ */
24412
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22575
24413
  /** A frame the dataset OWNS: bytes copied at selection time. */
22576
24414
  var RetrainFrameSchema = object({
22577
24415
  frameId: string(),
22578
24416
  deviceId: number(),
22579
- trackId: string(),
22580
- /** Provenance only. It may already point at nothing — that is expected. */
22581
- sourceMediaId: number().int(),
24417
+ origin: RetrainFrameOriginSchema,
24418
+ /** The track it was copied from. Absent on a recording still. */
24419
+ trackId: string().optional(),
24420
+ /** Provenance only. It may already point at nothing — that is expected.
24421
+ * Absent on a recording still. */
24422
+ sourceMediaId: number().int().optional(),
24423
+ /** A recording still: the playhead instant it was taken at. */
24424
+ epochMs: number().optional(),
22582
24425
  sourceKind: MediaFileKindEnum,
22583
24426
  sizeBytes: number().int(),
22584
24427
  width: number().int(),
@@ -22589,7 +24432,12 @@ var RetrainFrameSchema = object({
22589
24432
  /** The operator's "every subject in this frame is boxed". Detector
22590
24433
  * evaluation keeps only complete frames: an unboxed subject would count as
22591
24434
  * a false positive. */
22592
- complete: boolean()
24435
+ complete: boolean(),
24436
+ /** The boxes the pipeline drew on this frame. Present on list answers;
24437
+ * empty when nothing the track store holds can be placed on it. */
24438
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
24439
+ /** The named collections this frame belongs to. Present on list answers. */
24440
+ collectionIds: array(string()).readonly().optional()
22593
24441
  });
22594
24442
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22595
24443
  var RetrainCopyRefusalSchema = _enum([
@@ -22620,6 +24468,11 @@ var RetrainFrameListSchema = object({
22620
24468
  var RetrainExportFilterSchema = object({
22621
24469
  deviceIds: array(number()).optional(),
22622
24470
  frameIds: array(string()).max(2e4).optional(),
24471
+ /** Only frames in at least one of these named collections. */
24472
+ collectionIds: array(string()).max(200).optional(),
24473
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24474
+ * unknown id selects nothing. */
24475
+ datasetVersionId: string().optional(),
22623
24476
  batchId: string().optional(),
22624
24477
  /** Only frames the operator marked complete (all subjects boxed). */
22625
24478
  completeOnly: boolean().optional()
@@ -22684,6 +24537,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22684
24537
  reason: string(),
22685
24538
  detail: string().optional()
22686
24539
  })]);
24540
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24541
+ var RetrainCollectionSchema = object({
24542
+ id: string(),
24543
+ name: string(),
24544
+ createdAt: number(),
24545
+ frameCount: number().int()
24546
+ });
24547
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24548
+ kind: literal("created"),
24549
+ collection: RetrainCollectionSchema
24550
+ }), object({
24551
+ kind: literal("refused"),
24552
+ reason: _enum(["empty-name", "duplicate-name"])
24553
+ })]);
24554
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24555
+ kind: literal("renamed"),
24556
+ collection: RetrainCollectionSchema
24557
+ }), object({
24558
+ kind: literal("refused"),
24559
+ reason: _enum([
24560
+ "empty-name",
24561
+ "duplicate-name",
24562
+ "unknown-collection"
24563
+ ])
24564
+ })]);
24565
+ /**
24566
+ * The outcome of adding the frame at a recording instant. Every refusal is
24567
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24568
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24569
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24570
+ */
24571
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24572
+ kind: literal("added"),
24573
+ collectionId: string(),
24574
+ frame: RetrainFrameSchema,
24575
+ /** The moment was already in the dataset; nothing was decoded. */
24576
+ reused: boolean()
24577
+ }), object({
24578
+ kind: literal("refused"),
24579
+ reason: _enum([
24580
+ "unknown-collection",
24581
+ "still-unavailable",
24582
+ "still-busy",
24583
+ "unreadable-image",
24584
+ "write-failed"
24585
+ ]),
24586
+ detail: string().optional()
24587
+ })]);
24588
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24589
+ var RetrainAssistProfileSchema = object({
24590
+ id: string(),
24591
+ name: string(),
24592
+ model: string(),
24593
+ kind: string(),
24594
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24595
+ * endpoint that is not on the local network). The page confirms each such
24596
+ * run, and the provider refuses one without `allowCloud`. */
24597
+ leavesHouse: boolean()
24598
+ });
24599
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24600
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24601
+ /** What the AI assist said about a box that was already on the canvas. */
24602
+ var RetrainLlmReviewSchema = object({
24603
+ /** The `ref` the page sent the box under. */
24604
+ ref: string(),
24605
+ verdict: _enum([
24606
+ "confirmed",
24607
+ "wrong-class",
24608
+ "not-an-object",
24609
+ "uncertain"
24610
+ ]),
24611
+ suggestedClass: RetrainMacroClassSchema.optional(),
24612
+ reason: string()
24613
+ });
24614
+ /**
24615
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24616
+ * model and its confidence) and reviews; items the model got wrong (a box off
24617
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24618
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24619
+ */
24620
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24621
+ kind: literal("proposed"),
24622
+ profileId: string(),
24623
+ model: string(),
24624
+ /** The frame was sent outside the house for this answer. */
24625
+ leftHouse: boolean(),
24626
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24627
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24628
+ rejected: number().int()
24629
+ }), object({
24630
+ kind: literal("refused"),
24631
+ reason: _enum([
24632
+ "unknown-frame",
24633
+ "unreadable-frame",
24634
+ "unknown-profile",
24635
+ "profile-disabled",
24636
+ "no-vision",
24637
+ "cloud-not-confirmed",
24638
+ "llm-error",
24639
+ "malformed-answer"
24640
+ ]),
24641
+ detail: string().optional()
24642
+ })]);
24643
+ /** What a dataset version is cut from. Every field narrows. */
24644
+ var RetrainDatasetSelectionSchema = object({
24645
+ deviceIds: array(number()).readonly().optional(),
24646
+ collectionIds: array(string()).max(200).readonly().optional(),
24647
+ frameIds: array(string()).max(2e4).readonly().optional()
24648
+ });
24649
+ /** The counts a dataset is judged by. */
24650
+ var RetrainDatasetStatsSchema = object({
24651
+ frames: number().int(),
24652
+ completeFrames: number().int(),
24653
+ /** `completeFrames / frames`, 0..1. */
24654
+ completeness: number(),
24655
+ /** Boxes to learn (model errors excluded). */
24656
+ subjects: number().int(),
24657
+ modelErrors: number().int(),
24658
+ /** Complete frames with no subject. */
24659
+ hardNegatives: number().int(),
24660
+ /** Subjects per class × camera × day/night. */
24661
+ cells: array(object({
24662
+ macroClass: string(),
24663
+ deviceId: number(),
24664
+ lighting: _enum([
24665
+ "day",
24666
+ "night",
24667
+ "unknown"
24668
+ ]),
24669
+ subjects: number().int(),
24670
+ frames: number().int()
24671
+ })).readonly(),
24672
+ cameras: array(object({
24673
+ deviceId: number(),
24674
+ frames: number().int(),
24675
+ completeFrames: number().int()
24676
+ })).readonly()
24677
+ });
24678
+ /** An immutable dataset version, without its frame list. */
24679
+ var RetrainDatasetVersionSchema = object({
24680
+ id: string(),
24681
+ name: string(),
24682
+ createdAt: number(),
24683
+ selection: RetrainDatasetSelectionSchema,
24684
+ layout: RetrainExportLayoutSchema,
24685
+ completeOnly: boolean(),
24686
+ frameCount: number().int(),
24687
+ /** sha256 of what the frames taught when the version was frozen. */
24688
+ annotationHash: string(),
24689
+ /** The export manifest schema the version was cut under. */
24690
+ manifestSchema: string(),
24691
+ stats: RetrainDatasetStatsSchema
24692
+ });
24693
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24694
+ kind: literal("created"),
24695
+ version: RetrainDatasetVersionSchema
24696
+ }), object({
24697
+ kind: literal("refused"),
24698
+ reason: _enum([
24699
+ "empty-name",
24700
+ "duplicate-name",
24701
+ "no-frames"
24702
+ ])
24703
+ })]);
22687
24704
  /** The outcome of a lifecycle move owned by the retrain page. */
22688
24705
  var RetrainTransitionResultSchema = object({
22689
24706
  trackId: string(),
@@ -23401,7 +25418,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23401
25418
  auth: "admin"
23402
25419
  }), method(object({
23403
25420
  deviceId: number(),
23404
- trackId: string(),
25421
+ trackId: string().optional(),
23405
25422
  frameId: string()
23406
25423
  }), object({
23407
25424
  removed: boolean(),
@@ -23418,7 +25435,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23418
25435
  auth: "admin"
23419
25436
  }), method(object({
23420
25437
  deviceId: number(),
23421
- trackId: string(),
25438
+ /** The frame's track, when it has one — checked against the frame. */
25439
+ trackId: string().optional(),
23422
25440
  frameId: string(),
23423
25441
  subject: RetrainAssistSubjectSchema,
23424
25442
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -23426,12 +25444,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23426
25444
  }), RetrainAssistResultSchema, {
23427
25445
  kind: "mutation",
23428
25446
  auth: "admin"
23429
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25447
+ }), method(object({
25448
+ trackId: string().optional(),
25449
+ frameIds: array(string()).max(2e3).optional()
25450
+ }), array(RetrainAnnotationSchema).readonly(), {
23430
25451
  kind: "query",
23431
25452
  auth: "admin"
23432
25453
  }), method(object({
23433
25454
  deviceId: number(),
23434
- trackId: string(),
25455
+ /** The frame's track, when it has one — checked against the frame. */
25456
+ trackId: string().optional(),
23435
25457
  frameId: string(),
23436
25458
  annotations: array(RetrainAnnotationDraftSchema)
23437
25459
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -23454,7 +25476,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23454
25476
  auth: "admin"
23455
25477
  }), method(object({
23456
25478
  deviceId: number(),
23457
- trackId: string(),
25479
+ trackId: string().optional(),
23458
25480
  frameId: string(),
23459
25481
  complete: boolean()
23460
25482
  }), RetrainFrameSchema, {
@@ -23468,6 +25490,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23468
25490
  kind: "mutation",
23469
25491
  auth: "admin",
23470
25492
  timeoutMs: 60 * 6e4
25493
+ }), method(object({
25494
+ filter: RetrainExportFilterSchema,
25495
+ layout: RetrainExportLayoutSchema
25496
+ }), object({
25497
+ ticket: PeerBytesTicketSchema,
25498
+ frames: number().int(),
25499
+ annotations: number().int()
25500
+ }), {
25501
+ kind: "mutation",
25502
+ auth: "admin",
25503
+ timeoutMs: 12e4
25504
+ }), method(object({
25505
+ selection: RetrainDatasetSelectionSchema,
25506
+ completeOnly: boolean().optional()
25507
+ }), RetrainDatasetStatsSchema, {
25508
+ kind: "query",
25509
+ auth: "admin"
25510
+ }), method(object({
25511
+ name: string().max(120),
25512
+ selection: RetrainDatasetSelectionSchema,
25513
+ layout: RetrainExportLayoutSchema,
25514
+ completeOnly: boolean()
25515
+ }), CreateRetrainDatasetVersionResultSchema, {
25516
+ kind: "mutation",
25517
+ auth: "admin",
25518
+ timeoutMs: 12e4
25519
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25520
+ kind: "query",
25521
+ auth: "admin"
25522
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25523
+ kind: "mutation",
25524
+ auth: "admin"
25525
+ }), method(object({ id: string() }), object({
25526
+ found: boolean(),
25527
+ annotationHash: string(),
25528
+ matches: boolean(),
25529
+ missingFrames: number().int()
25530
+ }), {
25531
+ kind: "query",
25532
+ auth: "admin",
25533
+ timeoutMs: 12e4
25534
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25535
+ kind: "query",
25536
+ auth: "admin"
25537
+ }), method(object({
25538
+ deviceId: number(),
25539
+ trackId: string().optional(),
25540
+ frameId: string(),
25541
+ profileId: string(),
25542
+ classes: array(RetrainMacroClassSchema).min(1),
25543
+ boxes: array(object({
25544
+ ref: string(),
25545
+ bbox: RetrainBboxSchema,
25546
+ macroClass: RetrainMacroClassSchema,
25547
+ label: string().optional()
25548
+ })).max(50),
25549
+ allowCloud: boolean()
25550
+ }), RetrainLlmAssistResultSchema, {
25551
+ kind: "mutation",
25552
+ auth: "admin",
25553
+ timeoutMs: 18e4
25554
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25555
+ kind: "mutation",
25556
+ auth: "admin"
25557
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25558
+ kind: "query",
25559
+ auth: "admin"
25560
+ }), method(object({
25561
+ id: string(),
25562
+ name: string().max(120)
25563
+ }), RetrainCollectionRenameResultSchema, {
25564
+ kind: "mutation",
25565
+ auth: "admin"
25566
+ }), method(object({ id: string() }), object({
25567
+ deleted: boolean(),
25568
+ removedFrames: number().int()
25569
+ }), {
25570
+ kind: "mutation",
25571
+ auth: "admin"
25572
+ }), method(object({
25573
+ collectionId: string(),
25574
+ deviceId: number(),
25575
+ epochMs: number()
25576
+ }), AddRetrainFrameFromRecordingResultSchema, {
25577
+ kind: "mutation",
25578
+ auth: "admin",
25579
+ timeoutMs: 6e4
25580
+ }), method(object({
25581
+ collectionId: string(),
25582
+ frameIds: array(string()).min(1).max(500)
25583
+ }), object({
25584
+ added: number().int(),
25585
+ alreadyMember: number().int(),
25586
+ unknownFrameIds: array(string()).readonly()
25587
+ }), {
25588
+ kind: "mutation",
25589
+ auth: "admin"
25590
+ }), method(object({
25591
+ collectionId: string(),
25592
+ frameId: string()
25593
+ }), object({
25594
+ removed: boolean(),
25595
+ deletedFrame: boolean()
25596
+ }), {
25597
+ kind: "mutation",
25598
+ auth: "admin"
25599
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
25600
+ kind: "query",
25601
+ auth: "admin"
23471
25602
  }), method(object({
23472
25603
  /** Which of the three event tables owns the row. */
23473
25604
  ownerType: EventOwnerTypeSchema,
@@ -24091,13 +26222,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
24091
26222
  object({
24092
26223
  kind: literal("no-family-build"),
24093
26224
  format: ModelFormatSchema$1
26225
+ }),
26226
+ object({
26227
+ kind: literal("kept-custom-pin"),
26228
+ modelId: string(),
26229
+ deviceKey: string()
24094
26230
  })
24095
26231
  ]);
26232
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
26233
+ var KeptReasonSchema = _enum(["custom-pin"]);
26234
+ /**
26235
+ * Where a choice's latency came from (D791): this node's own benchmark
26236
+ * result, or the hardware-class table. Measured on the node beats the table.
26237
+ */
26238
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
26239
+ kind: literal("node-benchmark"),
26240
+ resultId: string(),
26241
+ measuredAtMs: number()
26242
+ })]);
24096
26243
  var DeviceModelChoiceSchema = object({
24097
26244
  modelId: string(),
24098
26245
  p50Ms: number(),
24099
26246
  fps: number(),
24100
26247
  measured: boolean(),
26248
+ /** Absent on a plan from before D791 — read as the table. */
26249
+ source: LatencySourceSchema.optional(),
24101
26250
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
24102
26251
  capacitySessions: number(),
24103
26252
  personRecall: number()
@@ -24108,6 +26257,8 @@ var DeviceRecommendationSchema = object({
24108
26257
  enabled: boolean(),
24109
26258
  available: boolean(),
24110
26259
  chosen: DeviceModelChoiceSchema.nullable(),
26260
+ /** Present when the device is kept as is: Apply writes nothing on it. */
26261
+ kept: KeptReasonSchema.optional(),
24111
26262
  reasons: array(RecommendationReasonSchema).readonly()
24112
26263
  });
24113
26264
  var NodeRecommendationSchema = object({
@@ -24161,6 +26312,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
24161
26312
  kind: literal("coral-enabled"),
24162
26313
  nodeId: string(),
24163
26314
  deviceKey: string()
26315
+ }),
26316
+ object({
26317
+ kind: literal("custom-pin-kept"),
26318
+ nodeId: string(),
26319
+ deviceKey: string().nullable(),
26320
+ deviceId: number().nullable(),
26321
+ modelId: string()
26322
+ }),
26323
+ object({
26324
+ kind: literal("custom-registry-unreadable"),
26325
+ error: string()
24164
26326
  })
24165
26327
  ]);
24166
26328
  var AutoTuneOptionsSchema = object({
@@ -24339,13 +26501,14 @@ var SuggestSharesResultSchema = object({
24339
26501
  nodes: array(SuggestedNodeShareSchema).readonly()
24340
26502
  });
24341
26503
  /**
24342
- * Where the node and device shares come from (D750, D755).
24343
- * - `hardware` (default) — computed by the system from each node's static
24344
- * capacity (its accelerators at their Auto tune models, from the measured
24345
- * latency table), recomputed whenever a node or device joins, leaves, is
24346
- * switched on or off, or changes model. No load input.
24347
- * - `benchmark` — the same, from each node's measured capacity (node
24348
- * benchmark results); a node without results falls back to `hardware`.
26504
+ * Where the node and device shares come from (D750, D755, D791).
26505
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26506
+ * benchmark measured it; a node without fresh results is sized from
26507
+ * `hardware` and says so. Measured on the node beats the table.
26508
+ * - `hardware` — computed from each node's static capacity only (its
26509
+ * accelerators at their Auto tune models, from the latency table).
26510
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26511
+ * on or off, changes model, or a benchmark result is written. No load input.
24349
26512
  * - `manual` — the operator's stored sliders.
24350
26513
  * Either way a node or device that cannot take sessions gives its share to
24351
26514
  * the others in proportion; the stored values are never rewritten for that.
@@ -24394,6 +26557,362 @@ var EffectiveSharesSchema = object({
24394
26557
  nodeWeights: record(string(), number()),
24395
26558
  deviceWeights: record(string(), record(string(), number()))
24396
26559
  });
26560
+ /**
26561
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26562
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26563
+ * measuring runner reports, and the result rows Auto tune and the automatic
26564
+ * shares read.
26565
+ *
26566
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26567
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26568
+ * detection candidate, camera pins naming it are ignored so its sessions move
26569
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26570
+ * restart too (a persisted manifest, reconciled against the registry).
26571
+ *
26572
+ * Two measurements, both on the node, driven by its own runner (frames never
26573
+ * cross a process at frame rate, D9):
26574
+ * - `device` — one accelerator × one candidate detector, root only, open
26575
+ * loop: how many streams at the camera rate it carries inside the frame
26576
+ * interval;
26577
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26578
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26579
+ * clip: how many parallel sessions the node carries before latency, drops,
26580
+ * CPU, RAM or the event loop give out.
26581
+ */
26582
+ /** Defaults and bounds, one place. */
26583
+ var NODE_BENCHMARK_DEFAULTS = {
26584
+ fpsPerStream: 10,
26585
+ budgetMinutes: 45,
26586
+ minBudgetMinutes: 10,
26587
+ maxBudgetMinutes: 120,
26588
+ /** A result older than this no longer beats the table. */
26589
+ staleAfterDays: 30,
26590
+ /** Warm-in per ramp step (not accounted). */
26591
+ settleSec: 5,
26592
+ /** Accounted window per ramp step. */
26593
+ measureSec: 20,
26594
+ /** Longest the drain may take before the run is refused. */
26595
+ drainTimeoutSec: 120,
26596
+ /** Candidate models per device in one run. */
26597
+ maxModelsPerDevice: 6
26598
+ };
26599
+ /** The two measurements a run can make. */
26600
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26601
+ var NodeBenchmarkDevicePlanSchema = object({
26602
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26603
+ deviceKey: string().min(1),
26604
+ /**
26605
+ * Root detector candidates for the `device` measurement, in the order
26606
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26607
+ */
26608
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26609
+ });
26610
+ /** What the operator confirmed. */
26611
+ var NodeBenchmarkPlanSchema = object({
26612
+ nodeId: string().min(1),
26613
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26614
+ /** Which measurements run. At least one. */
26615
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26616
+ /**
26617
+ * Detail steps (catalog step ids under the root: faces, plates,
26618
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26619
+ * detector always runs.
26620
+ */
26621
+ steps: array(string().min(1)).default([]),
26622
+ /** Offered rate of one stream / session. */
26623
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26624
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26625
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26626
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26627
+ keepDownloadedModels: boolean().default(false),
26628
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26629
+ acceptInsufficientHeadroom: boolean().default(false)
26630
+ });
26631
+ var NodeBenchmarkRefusalSchema = object({
26632
+ kind: _enum([
26633
+ "benchmark-active",
26634
+ "node-offline",
26635
+ "unknown-device",
26636
+ "no-phase",
26637
+ "insufficient-headroom"
26638
+ ]),
26639
+ detail: string(),
26640
+ overridable: boolean()
26641
+ });
26642
+ /** A camera whose detection leaves the node for the run. */
26643
+ var NodeBenchmarkMovingCameraSchema = object({
26644
+ deviceId: number(),
26645
+ /** Placed on the node now (a standing attach or a running session). */
26646
+ placedOnNode: boolean(),
26647
+ /** A node pin naming this node, ignored for the run. */
26648
+ pinnedToNode: boolean()
26649
+ });
26650
+ /** A camera that cannot leave: no other node can obtain its frames. */
26651
+ var NodeBenchmarkStayingCameraSchema = object({
26652
+ deviceId: number(),
26653
+ reason: literal("only-frame-source")
26654
+ });
26655
+ var NodeBenchmarkPreflightSchema = object({
26656
+ nodeId: string(),
26657
+ online: boolean(),
26658
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26659
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26660
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26661
+ estimatedDurationMs: number(),
26662
+ /** The run ends and the cluster is restored at the latest after this long. */
26663
+ budgetMs: number(),
26664
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26665
+ steps: array(string()).readonly(),
26666
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26667
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26668
+ headroom: object({
26669
+ sessionsNow: number(),
26670
+ otherNodesCapacitySessions: number().nullable()
26671
+ }),
26672
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26673
+ canStart: boolean()
26674
+ });
26675
+ /** Where the measuring runner is. */
26676
+ var NodeBenchProgressSchema = object({
26677
+ phase: _enum([
26678
+ "preparing",
26679
+ "device",
26680
+ "pipeline",
26681
+ "cleanup"
26682
+ ]),
26683
+ deviceKey: string().nullable(),
26684
+ modelId: string().nullable(),
26685
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26686
+ load: number().nullable(),
26687
+ cellsDone: number(),
26688
+ cellsTotal: number(),
26689
+ message: string()
26690
+ });
26691
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26692
+ var NodeBenchLimitSchema = _enum([
26693
+ "p95",
26694
+ "drops",
26695
+ "errors",
26696
+ "stall",
26697
+ "cpu",
26698
+ "ram",
26699
+ "none"
26700
+ ]);
26701
+ var NodeBenchRampStepSchema = object({
26702
+ load: number(),
26703
+ pass: boolean(),
26704
+ p95Ms: number(),
26705
+ dropRatio: number(),
26706
+ /** Completed frames per second over the accounted window. */
26707
+ fps: number(),
26708
+ cpuPct: number().nullable(),
26709
+ ramFreePct: number().nullable(),
26710
+ failReasons: array(string()).readonly()
26711
+ });
26712
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26713
+ phase: literal("device"),
26714
+ deviceKey: string(),
26715
+ modelId: string(),
26716
+ /** Single-stream latency (the K = 1 step). */
26717
+ p50Ms: number(),
26718
+ p95Ms: number(),
26719
+ p99Ms: number(),
26720
+ /** Frames per second sustained at the last passing step. */
26721
+ fps: number(),
26722
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26723
+ kMax: number(),
26724
+ limitedBy: NodeBenchLimitSchema,
26725
+ /** First call (model load + warm-up). */
26726
+ warmupMs: number(),
26727
+ ramp: array(NodeBenchRampStepSchema).readonly()
26728
+ }), object({
26729
+ phase: literal("pipeline"),
26730
+ deviceKey: string(),
26731
+ modelId: string(),
26732
+ steps: array(string()).readonly(),
26733
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26734
+ maxSessions: number(),
26735
+ limitedBy: NodeBenchLimitSchema,
26736
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26737
+ stepsFired: array(string()).readonly(),
26738
+ warmupMs: number(),
26739
+ ramp: array(NodeBenchRampStepSchema).readonly()
26740
+ })]);
26741
+ /**
26742
+ * What a result was measured ON. A result whose fingerprint no longer matches
26743
+ * the node no longer beats the table.
26744
+ */
26745
+ var NodeBenchFingerprintSchema = object({
26746
+ pipelineVersion: string().nullable(),
26747
+ cpuModel: string().nullable(),
26748
+ ramGb: number().nullable(),
26749
+ os: string().nullable(),
26750
+ /** Per device: the pool the cells ran on (runtime + tuning). */
26751
+ pools: record(string(), object({
26752
+ runtime: string(),
26753
+ numWorkers: number(),
26754
+ concurrency: number(),
26755
+ batchMode: string()
26756
+ })).default({})
26757
+ });
26758
+ /** The frames the run used. */
26759
+ var NodeBenchClipSchema = object({
26760
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
26761
+ id: string(),
26762
+ revision: string().nullable(),
26763
+ frames: number(),
26764
+ width: number(),
26765
+ height: number()
26766
+ });
26767
+ var NodeBenchRunnerInputSchema = object({
26768
+ runId: string().min(1),
26769
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26770
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
26771
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
26772
+ steps: array(string()).default([]),
26773
+ fpsPerStream: number().int().min(1).max(30),
26774
+ /** The runner stops on its own past this instant, whatever the hub does. */
26775
+ deadlineAtMs: number(),
26776
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
26777
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
26778
+ keepDownloadedModels: boolean().default(false)
26779
+ });
26780
+ var NodeBenchRunnerStateSchema = _enum([
26781
+ "running",
26782
+ "done",
26783
+ "failed",
26784
+ "aborted"
26785
+ ]);
26786
+ var NodeBenchRunnerStatusSchema = object({
26787
+ runId: string(),
26788
+ nodeId: string(),
26789
+ state: NodeBenchRunnerStateSchema,
26790
+ progress: NodeBenchProgressSchema.nullable(),
26791
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
26792
+ cells: array(NodeBenchCellSchema).readonly(),
26793
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26794
+ clip: NodeBenchClipSchema.nullable(),
26795
+ /** Cameras seen running on the node during the run (they share its pools). */
26796
+ activeCameraIds: array(number()).readonly(),
26797
+ /** Models the run downloaded and then deleted (not installed before). */
26798
+ deletedModels: array(string()).readonly(),
26799
+ error: string().nullable(),
26800
+ startedAtMs: number(),
26801
+ finishedAtMs: number().nullable()
26802
+ });
26803
+ var NodeBenchmarkStateSchema = _enum([
26804
+ "draining",
26805
+ "measuring",
26806
+ "restoring",
26807
+ "done",
26808
+ "failed",
26809
+ "aborted"
26810
+ ]);
26811
+ /** Why a run ended. */
26812
+ var NodeBenchmarkEndReasonSchema = _enum([
26813
+ "completed",
26814
+ "operator-abort",
26815
+ "deadline",
26816
+ "node-lost",
26817
+ "runner-lost",
26818
+ "hub-restart",
26819
+ "drain-timeout",
26820
+ "failed"
26821
+ ]);
26822
+ var NodeBenchmarkRunSchema = object({
26823
+ runId: string(),
26824
+ nodeId: string(),
26825
+ state: NodeBenchmarkStateSchema,
26826
+ plan: NodeBenchmarkPlanSchema,
26827
+ startedAtMs: number(),
26828
+ deadlineAtMs: number(),
26829
+ finishedAtMs: number().nullable(),
26830
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26831
+ error: string().nullable(),
26832
+ /** Cameras moved off the node for the run. */
26833
+ moved: array(number()).readonly(),
26834
+ /** Cameras that stayed (their only frame source is the node). */
26835
+ staying: array(number()).readonly(),
26836
+ /** Something else ran on the node's pools during the run. */
26837
+ contaminated: boolean(),
26838
+ progress: NodeBenchProgressSchema.nullable(),
26839
+ resultIds: array(string()).readonly()
26840
+ });
26841
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26842
+ var NodeBenchmarkStatusSchema = object({
26843
+ /** The node the cluster is in benchmark mode for; null = none. */
26844
+ modeNodeId: string().nullable(),
26845
+ run: NodeBenchmarkRunSchema.nullable()
26846
+ });
26847
+ /**
26848
+ * One stored measurement — the only authority Auto tune and the automatic
26849
+ * shares read measured capacity from. Written by the orchestrator when a run
26850
+ * ends, never by anyone else.
26851
+ */
26852
+ var NodeBenchmarkResultSchema = object({
26853
+ id: string(),
26854
+ runId: string(),
26855
+ nodeId: string(),
26856
+ cell: NodeBenchCellSchema,
26857
+ fpsPerStream: number(),
26858
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26859
+ clip: NodeBenchClipSchema.nullable(),
26860
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26861
+ contaminated: boolean(),
26862
+ stayingCameras: array(number()).readonly(),
26863
+ /** The run ended early; the cell itself completed. */
26864
+ partialRun: boolean(),
26865
+ measuredAtMs: number()
26866
+ });
26867
+ var ListNodeBenchmarkResultsInputSchema = object({
26868
+ nodeId: string().optional(),
26869
+ deviceKey: string().optional()
26870
+ });
26871
+ /** A result with its standing today: does it still beat the table? */
26872
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26873
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26874
+ standing: _enum([
26875
+ "fresh",
26876
+ "stale",
26877
+ "superseded"
26878
+ ]),
26879
+ staleWhy: _enum([
26880
+ "age",
26881
+ "runtime",
26882
+ "pool-tuning"
26883
+ ]).nullable()
26884
+ });
26885
+ object({
26886
+ runId: string(),
26887
+ nodeId: string(),
26888
+ startedAtMs: number(),
26889
+ deadlineAtMs: number(),
26890
+ plan: NodeBenchmarkPlanSchema,
26891
+ moved: array(number()).readonly(),
26892
+ staying: array(number()).readonly()
26893
+ });
26894
+ /** Candidate detectors per device, for the plan editor. */
26895
+ var NodeBenchmarkCandidatesSchema = object({
26896
+ nodeId: string(),
26897
+ reachable: boolean(),
26898
+ devices: array(object({
26899
+ deviceKey: string(),
26900
+ enabled: boolean(),
26901
+ available: boolean(),
26902
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26903
+ suggested: array(string()).readonly(),
26904
+ /** Every root detector the device has a build for. */
26905
+ all: array(string()).readonly(),
26906
+ /** The model the device runs now, when pinned. */
26907
+ currentModelId: string().nullable()
26908
+ })).readonly(),
26909
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26910
+ steps: array(object({
26911
+ id: string(),
26912
+ name: string(),
26913
+ slot: string()
26914
+ })).readonly()
26915
+ });
24397
26916
  object({
24398
26917
  activeCameras: number(),
24399
26918
  throttledCameras: number(),
@@ -25522,7 +28041,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25522
28041
  }), ParkedTrackFrameSchema.nullable()), method(object({
25523
28042
  deviceId: number(),
25524
28043
  trackId: string()
25525
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
28044
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
28045
+ accepted: literal(true),
28046
+ runId: string()
28047
+ }), {
28048
+ kind: "mutation",
28049
+ auth: "admin"
28050
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28051
+ kind: "mutation",
28052
+ auth: "admin"
28053
+ });
25526
28054
  var CameraPipelineConfigSchema = object({
25527
28055
  engine: PipelineEngineChoiceSchema.optional(),
25528
28056
  steps: array(PipelineStepInputSchema).readonly(),
@@ -26161,6 +28689,21 @@ method(object({
26161
28689
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
26162
28690
  kind: "mutation",
26163
28691
  auth: "admin"
28692
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28693
+ kind: literal("started"),
28694
+ runId: string()
28695
+ }), object({
28696
+ kind: literal("refused"),
28697
+ preflight: NodeBenchmarkPreflightSchema
28698
+ })]), {
28699
+ kind: "mutation",
28700
+ auth: "admin"
28701
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28702
+ kind: "mutation",
28703
+ auth: "admin"
28704
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28705
+ kind: "mutation",
28706
+ auth: "admin"
26164
28707
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
26165
28708
  deviceId: number(),
26166
28709
  addonId: string(),
@@ -26566,8 +29109,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26566
29109
  * `smtp-provider` — pluggable email delivery surface.
26567
29110
  *
26568
29111
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26569
- * one for transactional / one for notifications). Consumers (magic-link,
26570
- * notifier addons, …) walk the collection and pick the first
29112
+ * one for transactional / one for notifications). Consumers (notifier
29113
+ * addons, …) walk the collection and pick the first
26571
29114
  * ready provider OR target a specific addonId.
26572
29115
  *
26573
29116
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -26746,7 +29289,7 @@ targets: array(object({
26746
29289
  })));
26747
29290
  /**
26748
29291
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
26749
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29292
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
26750
29293
  * carrying the post-callback claims before redirecting back to
26751
29294
  * `/api/auth/sso/finish`.
26752
29295
  *
@@ -26809,7 +29352,14 @@ var SsoBridgeClaimsSchema = object({
26809
29352
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
26810
29353
  * subject is unique only per issuer, so a link is bound to it.
26811
29354
  */
26812
- issuer: string().optional()
29355
+ issuer: string().optional(),
29356
+ /**
29357
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29358
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29359
+ * request to present the matching cookie — a login bridge is useless in
29360
+ * any other browser.
29361
+ */
29362
+ browserBinding: string().optional()
26813
29363
  });
26814
29364
  method(object({
26815
29365
  claims: SsoBridgeClaimsSchema,
@@ -32268,6 +34818,9 @@ var CreateIntegrationInputSchema = object({
32268
34818
  enabled: boolean().optional(),
32269
34819
  info: record(string(), unknown()).optional(),
32270
34820
  settings: record(string(), unknown()).optional(),
34821
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
34822
+ * the keychain, not the table (D787). */
34823
+ secretKeys: array(string()).optional(),
32271
34824
  skipRestart: boolean().optional()
32272
34825
  });
32273
34826
  var UpdateIntegrationInputSchema = object({
@@ -32291,7 +34844,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
32291
34844
  auth: "admin"
32292
34845
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
32293
34846
  id: string(),
32294
- settings: record(string(), unknown())
34847
+ settings: record(string(), unknown()),
34848
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
34849
+ secretKeys: array(string()).optional()
32295
34850
  }), object({ success: boolean() }), {
32296
34851
  kind: "mutation",
32297
34852
  auth: "admin"
@@ -39063,16 +41618,6 @@ var ApiKeySummarySchema = object({
39063
41618
  createdAt: number(),
39064
41619
  lastUsedAt: number().optional()
39065
41620
  });
39066
- var CreateApiKeyInputSchema = object({
39067
- label: string(),
39068
- isAdmin: boolean().default(false),
39069
- allowedProviders: union([array(string()), literal("*")]).optional(),
39070
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
39071
- });
39072
- var CreateApiKeyResultSchema = object({
39073
- token: string(),
39074
- record: ApiKeySummarySchema
39075
- });
39076
41621
  var ScopedTokenSummarySchema = object({
39077
41622
  id: string(),
39078
41623
  userId: string(),
@@ -39171,17 +41716,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39171
41716
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
39172
41717
  kind: "mutation",
39173
41718
  access: "view"
39174
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
39175
- kind: "mutation",
39176
- auth: "admin",
39177
- access: "create"
39178
- }), method(object({ id: string() }), object({ success: literal(true) }), {
41719
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
39179
41720
  kind: "mutation",
39180
41721
  auth: "admin",
39181
41722
  access: "delete"
39182
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
39183
- kind: "mutation",
39184
- access: "view"
39185
41723
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
39186
41724
  kind: "mutation",
39187
41725
  auth: "admin",
@@ -39255,15 +41793,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39255
41793
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
39256
41794
  userId: string(),
39257
41795
  issuer: string()
39258
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
39259
- userId: string(),
39260
- issuer: string().min(1),
39261
- label: string().optional()
39262
- }), object({ success: literal(true) }), {
39263
- kind: "mutation",
39264
- auth: "admin",
39265
- access: "create"
39266
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41796
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39267
41797
  kind: "mutation",
39268
41798
  auth: "admin",
39269
41799
  access: "delete"
@@ -39968,6 +42498,451 @@ var zoneRulesCapability = {
39968
42498
  */
39969
42499
  durability: "restored"
39970
42500
  };
42501
+ /**
42502
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42503
+ *
42504
+ * A thin, mockable translation layer: it knows how to run a container with a
42505
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42506
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42507
+ * those are the `training` orchestrator's (D805). Every rule written there
42508
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42509
+ * manifest entry and nothing else.
42510
+ *
42511
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42512
+ * `notification-output` posture); `describe` concat-fans across providers.
42513
+ * Every method is `admin`: these spend money.
42514
+ *
42515
+ * Every cloud object a provider creates is tagged with the orchestrator's
42516
+ * `jobKey`, so a retried submit finds the job it already started instead of
42517
+ * starting a second GPU, and `listJobs` can find orphans.
42518
+ *
42519
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42520
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42521
+ * ticket the provider mints (D613).
42522
+ */
42523
+ var TrainingGpuOptionSchema = object({
42524
+ id: string(),
42525
+ label: string(),
42526
+ /** List price, USD per GPU-hour, before any region multiplier. */
42527
+ usdPerHour: number().nonnegative(),
42528
+ vramGb: number().nonnegative()
42529
+ });
42530
+ var TrainingRegionOptionSchema = object({
42531
+ /** `''` = any region (the provider's choice). */
42532
+ id: string(),
42533
+ label: string(),
42534
+ priceMultiplier: number().positive()
42535
+ });
42536
+ /**
42537
+ * The provider's per-account settings, as the orchestrator reads them. They
42538
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42539
+ * depend on the user's account), never hard-coded in the orchestrator.
42540
+ */
42541
+ var TrainingProviderDefaultsSchema = object({
42542
+ gpuType: string(),
42543
+ region: string(),
42544
+ costCapUsd: number().nonnegative(),
42545
+ maxRuntimeSec: number().int().positive(),
42546
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
42547
+ failedDatasetGraceHours: number().nonnegative()
42548
+ });
42549
+ var TrainingProviderDescriptorSchema = object({
42550
+ addonId: string(),
42551
+ /** `modal`, `runpod`, `fake`, … */
42552
+ kind: string(),
42553
+ label: string(),
42554
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
42555
+ regions: array(TrainingRegionOptionSchema).readonly(),
42556
+ maxDatasetBytes: number().int().positive(),
42557
+ maxRuntimeSec: number().int().positive(),
42558
+ freeTierNote: string().optional(),
42559
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
42560
+ dataResidencyNote: string(),
42561
+ /** Credentials are present — never the values. */
42562
+ configured: boolean(),
42563
+ defaults: TrainingProviderDefaultsSchema
42564
+ });
42565
+ var TrainingCredentialCheckSchema = object({
42566
+ ok: boolean(),
42567
+ /** Workspace / account name, when the provider says. */
42568
+ account: string().optional(),
42569
+ reason: _enum([
42570
+ "missing",
42571
+ "invalid",
42572
+ "forbidden",
42573
+ "network",
42574
+ "quota"
42575
+ ]).optional(),
42576
+ detail: string().optional()
42577
+ });
42578
+ var ProviderJobStateSchema = _enum([
42579
+ "pending",
42580
+ "starting",
42581
+ "running",
42582
+ "succeeded",
42583
+ "failed",
42584
+ "cancelled",
42585
+ "lost"
42586
+ ]);
42587
+ var ProviderJobStatusSchema = object({
42588
+ jobKey: string(),
42589
+ providerJobId: string().optional(),
42590
+ state: ProviderJobStateSchema,
42591
+ startedAt: number().optional(),
42592
+ endedAt: number().optional(),
42593
+ exitCode: number().int().optional(),
42594
+ failureReason: string().optional(),
42595
+ gpuType: string(),
42596
+ region: string().optional(),
42597
+ billedSeconds: number().nonnegative(),
42598
+ costUsd: number().nonnegative(),
42599
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
42600
+ costIsEstimate: boolean(),
42601
+ lastFetchedAt: number()
42602
+ });
42603
+ /**
42604
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
42605
+ * image its own way (Modal builds the published Dockerfile at that revision;
42606
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
42607
+ * in `result.json`.
42608
+ */
42609
+ var TrainerSourceRefSchema = object({
42610
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
42611
+ repo: string().min(1),
42612
+ /** A commit sha (never a branch) — the job must be reproducible. */
42613
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
42614
+ });
42615
+ var JobRef = {
42616
+ addonId: string(),
42617
+ jobKey: string().uuid()
42618
+ };
42619
+ var TrainingLogLineSchema = object({
42620
+ ts: number(),
42621
+ text: string()
42622
+ });
42623
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
42624
+ kind: "mutation",
42625
+ auth: "admin",
42626
+ timeoutMs: 3e4
42627
+ }), method(object({
42628
+ addonId: string(),
42629
+ gpuType: string(),
42630
+ region: string(),
42631
+ datasetBytes: number().int().nonnegative(),
42632
+ gpuSecondsLow: number().nonnegative(),
42633
+ gpuSecondsHigh: number().nonnegative()
42634
+ }), object({
42635
+ usdLow: number().nonnegative(),
42636
+ usdHigh: number().nonnegative(),
42637
+ notes: array(string()).readonly()
42638
+ }), { auth: "admin" }), method(object({
42639
+ ...JobRef,
42640
+ ticket: PeerBytesTicketSchema
42641
+ }), object({
42642
+ bytes: number().int().nonnegative(),
42643
+ sha256: string()
42644
+ }), {
42645
+ kind: "mutation",
42646
+ auth: "admin",
42647
+ timeoutMs: 120 * 6e4
42648
+ }), method(object({
42649
+ ...JobRef,
42650
+ trainer: TrainerSourceRefSchema,
42651
+ jobSpecJson: string().min(2).max(64e3),
42652
+ gpuType: string(),
42653
+ region: string(),
42654
+ maxRuntimeSec: number().int().positive()
42655
+ }), ProviderJobStatusSchema, {
42656
+ kind: "mutation",
42657
+ auth: "admin",
42658
+ timeoutMs: 30 * 6e4
42659
+ }), method(object(JobRef), ProviderJobStatusSchema, {
42660
+ auth: "admin",
42661
+ timeoutMs: 6e4
42662
+ }), method(object({
42663
+ ...JobRef,
42664
+ cursor: string().optional(),
42665
+ max: number().int().min(1).max(500)
42666
+ }), object({
42667
+ lines: array(TrainingLogLineSchema).readonly(),
42668
+ cursor: string()
42669
+ }), {
42670
+ auth: "admin",
42671
+ timeoutMs: 6e4
42672
+ }), method(object(JobRef), object({ ok: literal(true) }), {
42673
+ kind: "mutation",
42674
+ auth: "admin",
42675
+ timeoutMs: 6e4
42676
+ }), method(object(JobRef), object({
42677
+ found: boolean(),
42678
+ text: string().optional()
42679
+ }), {
42680
+ kind: "mutation",
42681
+ auth: "admin",
42682
+ timeoutMs: 5 * 6e4
42683
+ }), method(object({
42684
+ ...JobRef,
42685
+ path: _enum(["bundle.tar"])
42686
+ }), object({ ticket: PeerBytesTicketSchema }), {
42687
+ kind: "mutation",
42688
+ auth: "admin",
42689
+ timeoutMs: 5 * 6e4
42690
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
42691
+ kind: "mutation",
42692
+ auth: "admin",
42693
+ timeoutMs: 5 * 6e4
42694
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
42695
+ auth: "admin",
42696
+ timeoutMs: 2 * 6e4
42697
+ });
42698
+ /**
42699
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
42700
+ * provided by `addon-training`.
42701
+ *
42702
+ * It owns what every provider must agree on, written once:
42703
+ *
42704
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
42705
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
42706
+ * the export plan) and reaches this store through the five row methods
42707
+ * below, so the Retrain page and the export did not change.
42708
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
42709
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
42710
+ * - **The return flow.** Verified artefacts → Model Studio
42711
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
42712
+ * rollback. Nothing is ever registered automatically.
42713
+ *
42714
+ * Every method is `admin`.
42715
+ */
42716
+ /** A version WITH its frame list — what the export and a job read. */
42717
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
42718
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
42719
+ var TrainingBaseModelSchema = object({
42720
+ modelId: string(),
42721
+ label: string(),
42722
+ weights: string(),
42723
+ imgsz: number().int(),
42724
+ baselineOnnxUrl: string(),
42725
+ baselineFloors: record(string(), number()),
42726
+ /** The base the fleet runs most — the UI's default. */
42727
+ recommended: boolean()
42728
+ });
42729
+ var TrainingPresetSchema = _enum([
42730
+ "quick",
42731
+ "standard",
42732
+ "thorough"
42733
+ ]);
42734
+ var TrainingJobRequestSchema = object({
42735
+ datasetVersionId: string().min(1),
42736
+ /** The `training-provider` addon that runs it. */
42737
+ addonId: string().min(1),
42738
+ gpuType: string().min(1),
42739
+ region: string(),
42740
+ baseModelId: string().min(1),
42741
+ preset: TrainingPresetSchema,
42742
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
42743
+ freeze: number().int().nonnegative().nullable(),
42744
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
42745
+ holdoutCameras: array(number().int()).nullable()
42746
+ });
42747
+ var TrainingSplitPlanSchema = object({
42748
+ holdoutCameras: array(number().int()).readonly(),
42749
+ /** Used when no camera is held out: the last N days of every camera. */
42750
+ holdoutLastDays: number().int().nonnegative(),
42751
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
42752
+ holdoutSupport: record(string(), number().int()).nullable(),
42753
+ trainSubjects: number().int()
42754
+ });
42755
+ var TrainingRefusalReasonSchema = _enum([
42756
+ "unknown-dataset",
42757
+ "unknown-provider",
42758
+ "provider-not-configured",
42759
+ "unknown-base-model",
42760
+ "unknown-gpu",
42761
+ "dataset-too-large",
42762
+ "no-training-subjects",
42763
+ "job-already-running"
42764
+ ]);
42765
+ var TrainingJobPlanSchema = object({
42766
+ refusal: object({
42767
+ reason: TrainingRefusalReasonSchema,
42768
+ detail: string()
42769
+ }).nullable(),
42770
+ warnings: array(string()).readonly(),
42771
+ split: TrainingSplitPlanSchema.nullable(),
42772
+ estimate: object({
42773
+ datasetBytes: number().int(),
42774
+ uploadMinutesAt20Mbps: number(),
42775
+ gpuSecondsLow: number(),
42776
+ gpuSecondsHigh: number(),
42777
+ usdLow: number(),
42778
+ usdHigh: number(),
42779
+ notes: array(string()).readonly()
42780
+ }).nullable(),
42781
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
42782
+ defaults: object({
42783
+ maxCostUsd: number(),
42784
+ maxRuntimeSec: number().int()
42785
+ }).nullable(),
42786
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
42787
+ dataNotice: string()
42788
+ });
42789
+ /**
42790
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
42791
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
42792
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
42793
+ * result lives after the operator acted on it.
42794
+ */
42795
+ var TrainingJobStateSchema = _enum([
42796
+ "uploading",
42797
+ "submitted",
42798
+ "starting",
42799
+ "running",
42800
+ "collecting",
42801
+ "ready",
42802
+ "registered",
42803
+ "canary",
42804
+ "failed",
42805
+ "cancelling",
42806
+ "cancelled",
42807
+ "lost",
42808
+ "expired",
42809
+ "discarded"
42810
+ ]);
42811
+ var TrainingFailureReasonSchema = _enum([
42812
+ "cost-cap",
42813
+ "runtime-cap",
42814
+ "upload-failed",
42815
+ "submit-failed",
42816
+ "trainer-failed",
42817
+ "result-invalid",
42818
+ "checksum-mismatch",
42819
+ "fetch-failed",
42820
+ "provider-error",
42821
+ "hub-restart-during-upload"
42822
+ ]);
42823
+ var TrainingProgressPointSchema = object({
42824
+ epoch: number().int(),
42825
+ map50: number().nullable(),
42826
+ map50_95: number().nullable()
42827
+ });
42828
+ var TrainingCanarySchema = object({
42829
+ deviceIds: array(number().int()).readonly(),
42830
+ since: number(),
42831
+ /** Every override the canary replaced, exactly, so rollback restores it. */
42832
+ previous: array(object({
42833
+ deviceId: number().int(),
42834
+ nodeId: string(),
42835
+ deviceKey: string(),
42836
+ patch: object({
42837
+ modelId: string().optional(),
42838
+ settings: record(string(), unknown()).readonly().optional()
42839
+ }).nullable()
42840
+ })).readonly()
42841
+ });
42842
+ var TrainingJobSchema = object({
42843
+ id: string(),
42844
+ idempotencyKey: string(),
42845
+ name: string(),
42846
+ createdAt: number(),
42847
+ updatedAt: number(),
42848
+ state: TrainingJobStateSchema,
42849
+ stage: TrainingStageSchema.nullable(),
42850
+ failure: object({
42851
+ reason: TrainingFailureReasonSchema,
42852
+ stage: string().nullable(),
42853
+ detail: string()
42854
+ }).nullable(),
42855
+ request: TrainingJobRequestSchema,
42856
+ maxCostUsd: number().nonnegative(),
42857
+ maxRuntimeSec: number().int().positive(),
42858
+ trainer: TrainerSourceRefSchema,
42859
+ datasetLayout: RetrainExportLayoutSchema,
42860
+ dataset: object({
42861
+ bytes: number().int(),
42862
+ sha256: string(),
42863
+ uploadedAt: number()
42864
+ }).nullable(),
42865
+ split: TrainingSplitPlanSchema,
42866
+ provider: object({
42867
+ state: ProviderJobStateSchema.nullable(),
42868
+ providerJobId: string().nullable(),
42869
+ startedAt: number().nullable(),
42870
+ endedAt: number().nullable(),
42871
+ billedSeconds: number(),
42872
+ costUsd: number(),
42873
+ costIsEstimate: boolean(),
42874
+ lastPolledAt: number().nullable()
42875
+ }),
42876
+ progress: object({
42877
+ epoch: number().int().nullable(),
42878
+ epochs: number().int().nullable(),
42879
+ etaSec: number().nullable(),
42880
+ series: array(TrainingProgressPointSchema).readonly()
42881
+ }),
42882
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
42883
+ logTail: array(string()).readonly(),
42884
+ logCursor: string().nullable(),
42885
+ artifacts: object({
42886
+ bundleBytes: number().int(),
42887
+ bundleSha256: string(),
42888
+ fetchedAt: number(),
42889
+ /** When the staged artefacts are deleted from the hub. */
42890
+ expiresAt: number()
42891
+ }).nullable(),
42892
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
42893
+ cloudDatasetDeletedAt: number().nullable(),
42894
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
42895
+ cloudCleanupDueAt: number().nullable(),
42896
+ /** Model ids registered from this job (base, and int8 when kept). */
42897
+ registeredModelIds: array(string()).readonly(),
42898
+ canary: TrainingCanarySchema.nullable()
42899
+ });
42900
+ var IdInput = object({ id: string().min(1) });
42901
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
42902
+ kind: "mutation",
42903
+ auth: "admin"
42904
+ }), 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() }), {
42905
+ kind: "mutation",
42906
+ auth: "admin"
42907
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
42908
+ auth: "admin",
42909
+ timeoutMs: 6e4
42910
+ }), method(TrainingJobRequestSchema.extend({
42911
+ name: string().min(1).max(120),
42912
+ maxCostUsd: number().positive(),
42913
+ maxRuntimeSec: number().int().positive(),
42914
+ idempotencyKey: string().min(8).max(80)
42915
+ }), discriminatedUnion("kind", [object({
42916
+ kind: literal("started"),
42917
+ job: TrainingJobSchema
42918
+ }), object({
42919
+ kind: literal("refused"),
42920
+ reason: TrainingRefusalReasonSchema,
42921
+ detail: string()
42922
+ })]), {
42923
+ kind: "mutation",
42924
+ auth: "admin",
42925
+ timeoutMs: 12e4
42926
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
42927
+ kind: "mutation",
42928
+ auth: "admin",
42929
+ timeoutMs: 12e4
42930
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
42931
+ kind: "mutation",
42932
+ auth: "admin",
42933
+ timeoutMs: 30 * 6e4
42934
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
42935
+ kind: "mutation",
42936
+ auth: "admin",
42937
+ timeoutMs: 12e4
42938
+ }), method(IdInput, TrainingJobSchema, {
42939
+ kind: "mutation",
42940
+ auth: "admin",
42941
+ timeoutMs: 12e4
42942
+ }), method(IdInput, TrainingJobSchema, {
42943
+ kind: "mutation",
42944
+ auth: "admin"
42945
+ });
39971
42946
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
39972
42947
  Object.freeze({
39973
42948
  person: .5,
@@ -40454,7 +43429,8 @@ var BaseDevice = class {
40454
43429
  this.role = options.role;
40455
43430
  this.parentDeviceId = ctx.parentDeviceId;
40456
43431
  const seedData = ctx.persistedConfig ?? {};
40457
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
43432
+ const declaredSecretPaths = collectZodSecretPaths(schema);
43433
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
40458
43434
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
40459
43435
  tags: {
40460
43436
  deviceId: ctx.id,
@@ -42115,6 +45091,12 @@ Object.freeze({
42115
45091
  addonId: null,
42116
45092
  access: "create"
42117
45093
  },
45094
+ "backup.checkBackupKey": {
45095
+ capName: "backup",
45096
+ capScope: "system",
45097
+ addonId: null,
45098
+ access: "create"
45099
+ },
42118
45100
  "backup.delete": {
42119
45101
  capName: "backup",
42120
45102
  capScope: "system",
@@ -42127,6 +45109,18 @@ Object.freeze({
42127
45109
  addonId: null,
42128
45110
  access: "delete"
42129
45111
  },
45112
+ "backup.disableEncryption": {
45113
+ capName: "backup",
45114
+ capScope: "system",
45115
+ addonId: null,
45116
+ access: "create"
45117
+ },
45118
+ "backup.getEncryption": {
45119
+ capName: "backup",
45120
+ capScope: "system",
45121
+ addonId: null,
45122
+ access: "view"
45123
+ },
42130
45124
  "backup.getEntries": {
42131
45125
  capName: "backup",
42132
45126
  capScope: "system",
@@ -42181,6 +45175,12 @@ Object.freeze({
42181
45175
  addonId: null,
42182
45176
  access: "create"
42183
45177
  },
45178
+ "backup.setupEncryption": {
45179
+ capName: "backup",
45180
+ capScope: "system",
45181
+ addonId: null,
45182
+ access: "create"
45183
+ },
42184
45184
  "backup.trigger": {
42185
45185
  capName: "backup",
42186
45186
  capScope: "system",
@@ -42733,6 +45733,12 @@ Object.freeze({
42733
45733
  addonId: null,
42734
45734
  access: "create"
42735
45735
  },
45736
+ "customModelRegistry.importModelBundle": {
45737
+ capName: "custom-model-registry",
45738
+ capScope: "system",
45739
+ addonId: null,
45740
+ access: "create"
45741
+ },
42736
45742
  "customModelRegistry.listModels": {
42737
45743
  capName: "custom-model-registry",
42738
45744
  capScope: "system",
@@ -44143,6 +47149,108 @@ Object.freeze({
44143
47149
  addonId: null,
44144
47150
  access: "create"
44145
47151
  },
47152
+ "keychain.delete": {
47153
+ capName: "keychain",
47154
+ capScope: "system",
47155
+ addonId: null,
47156
+ access: "delete"
47157
+ },
47158
+ "keychain.getState": {
47159
+ capName: "keychain",
47160
+ capScope: "system",
47161
+ addonId: null,
47162
+ access: "view"
47163
+ },
47164
+ "keychain.listMeta": {
47165
+ capName: "keychain",
47166
+ capScope: "system",
47167
+ addonId: null,
47168
+ access: "view"
47169
+ },
47170
+ "keychain.put": {
47171
+ capName: "keychain",
47172
+ capScope: "system",
47173
+ addonId: null,
47174
+ access: "create"
47175
+ },
47176
+ "keychain.resolve": {
47177
+ capName: "keychain",
47178
+ capScope: "system",
47179
+ addonId: null,
47180
+ access: "view"
47181
+ },
47182
+ "keychainAdmin.acknowledgeReset": {
47183
+ capName: "keychain-admin",
47184
+ capScope: "system",
47185
+ addonId: null,
47186
+ access: "create"
47187
+ },
47188
+ "keychainAdmin.deleteOrphans": {
47189
+ capName: "keychain-admin",
47190
+ capScope: "system",
47191
+ addonId: null,
47192
+ access: "delete"
47193
+ },
47194
+ "keychainAdmin.downloadRecoveryKey": {
47195
+ capName: "keychain-admin",
47196
+ capScope: "system",
47197
+ addonId: null,
47198
+ access: "create"
47199
+ },
47200
+ "keychainAdmin.listAudit": {
47201
+ capName: "keychain-admin",
47202
+ capScope: "system",
47203
+ addonId: null,
47204
+ access: "view"
47205
+ },
47206
+ "keychainAdmin.listSecrets": {
47207
+ capName: "keychain-admin",
47208
+ capScope: "system",
47209
+ addonId: null,
47210
+ access: "view"
47211
+ },
47212
+ "keychainAdmin.purgeRetiredKeys": {
47213
+ capName: "keychain-admin",
47214
+ capScope: "system",
47215
+ addonId: null,
47216
+ access: "delete"
47217
+ },
47218
+ "keychainAdmin.resetKeychain": {
47219
+ capName: "keychain-admin",
47220
+ capScope: "system",
47221
+ addonId: null,
47222
+ access: "delete"
47223
+ },
47224
+ "keychainAdmin.resetReport": {
47225
+ capName: "keychain-admin",
47226
+ capScope: "system",
47227
+ addonId: null,
47228
+ access: "delete"
47229
+ },
47230
+ "keychainAdmin.reveal": {
47231
+ capName: "keychain-admin",
47232
+ capScope: "system",
47233
+ addonId: null,
47234
+ access: "create"
47235
+ },
47236
+ "keychainAdmin.rotateMasterKey": {
47237
+ capName: "keychain-admin",
47238
+ capScope: "system",
47239
+ addonId: null,
47240
+ access: "create"
47241
+ },
47242
+ "keychainAdmin.setSystemSecret": {
47243
+ capName: "keychain-admin",
47244
+ capScope: "system",
47245
+ addonId: null,
47246
+ access: "create"
47247
+ },
47248
+ "keychainAdmin.status": {
47249
+ capName: "keychain-admin",
47250
+ capScope: "system",
47251
+ addonId: null,
47252
+ access: "view"
47253
+ },
44146
47254
  "lawnMowerControl.dock": {
44147
47255
  capName: "lawn-mower-control",
44148
47256
  capScope: "device",
@@ -45517,6 +48625,18 @@ Object.freeze({
45517
48625
  addonId: null,
45518
48626
  access: "create"
45519
48627
  },
48628
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
48629
+ capName: "pipeline-analytics",
48630
+ capScope: "device",
48631
+ addonId: null,
48632
+ access: "create"
48633
+ },
48634
+ "pipelineAnalytics.addRetrainFramesToCollection": {
48635
+ capName: "pipeline-analytics",
48636
+ capScope: "device",
48637
+ addonId: null,
48638
+ access: "create"
48639
+ },
45520
48640
  "pipelineAnalytics.applyDeviceSettingsPatch": {
45521
48641
  capName: "pipeline-analytics",
45522
48642
  capScope: "device",
@@ -45565,12 +48685,36 @@ Object.freeze({
45565
48685
  addonId: null,
45566
48686
  access: "view"
45567
48687
  },
48688
+ "pipelineAnalytics.createRetrainCollection": {
48689
+ capName: "pipeline-analytics",
48690
+ capScope: "device",
48691
+ addonId: null,
48692
+ access: "create"
48693
+ },
48694
+ "pipelineAnalytics.createRetrainDatasetVersion": {
48695
+ capName: "pipeline-analytics",
48696
+ capScope: "device",
48697
+ addonId: null,
48698
+ access: "create"
48699
+ },
45568
48700
  "pipelineAnalytics.deleteDeviceEvents": {
45569
48701
  capName: "pipeline-analytics",
45570
48702
  capScope: "device",
45571
48703
  addonId: null,
45572
48704
  access: "delete"
45573
48705
  },
48706
+ "pipelineAnalytics.deleteRetrainCollection": {
48707
+ capName: "pipeline-analytics",
48708
+ capScope: "device",
48709
+ addonId: null,
48710
+ access: "delete"
48711
+ },
48712
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
48713
+ capName: "pipeline-analytics",
48714
+ capScope: "device",
48715
+ addonId: null,
48716
+ access: "delete"
48717
+ },
45574
48718
  "pipelineAnalytics.deleteTracks": {
45575
48719
  capName: "pipeline-analytics",
45576
48720
  capScope: "device",
@@ -45775,6 +48919,30 @@ Object.freeze({
45775
48919
  addonId: null,
45776
48920
  access: "view"
45777
48921
  },
48922
+ "pipelineAnalytics.listRetrainAssistProfiles": {
48923
+ capName: "pipeline-analytics",
48924
+ capScope: "device",
48925
+ addonId: null,
48926
+ access: "view"
48927
+ },
48928
+ "pipelineAnalytics.listRetrainCollectionFrames": {
48929
+ capName: "pipeline-analytics",
48930
+ capScope: "device",
48931
+ addonId: null,
48932
+ access: "view"
48933
+ },
48934
+ "pipelineAnalytics.listRetrainCollections": {
48935
+ capName: "pipeline-analytics",
48936
+ capScope: "device",
48937
+ addonId: null,
48938
+ access: "view"
48939
+ },
48940
+ "pipelineAnalytics.listRetrainDatasetVersions": {
48941
+ capName: "pipeline-analytics",
48942
+ capScope: "device",
48943
+ addonId: null,
48944
+ access: "view"
48945
+ },
45778
48946
  "pipelineAnalytics.listRetrainFrames": {
45779
48947
  capName: "pipeline-analytics",
45780
48948
  capScope: "device",
@@ -45805,6 +48973,12 @@ Object.freeze({
45805
48973
  addonId: null,
45806
48974
  access: "view"
45807
48975
  },
48976
+ "pipelineAnalytics.offerRetrainArchive": {
48977
+ capName: "pipeline-analytics",
48978
+ capScope: "device",
48979
+ addonId: null,
48980
+ access: "create"
48981
+ },
45808
48982
  "pipelineAnalytics.ownersWithMedia": {
45809
48983
  capName: "pipeline-analytics",
45810
48984
  capScope: "device",
@@ -45817,12 +48991,24 @@ Object.freeze({
45817
48991
  addonId: null,
45818
48992
  access: "create"
45819
48993
  },
48994
+ "pipelineAnalytics.previewRetrainDataset": {
48995
+ capName: "pipeline-analytics",
48996
+ capScope: "device",
48997
+ addonId: null,
48998
+ access: "view"
48999
+ },
45820
49000
  "pipelineAnalytics.proposeRetrainAnnotations": {
45821
49001
  capName: "pipeline-analytics",
45822
49002
  capScope: "device",
45823
49003
  addonId: null,
45824
49004
  access: "create"
45825
49005
  },
49006
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
49007
+ capName: "pipeline-analytics",
49008
+ capScope: "device",
49009
+ addonId: null,
49010
+ access: "create"
49011
+ },
45826
49012
  "pipelineAnalytics.pruneEvents": {
45827
49013
  capName: "pipeline-analytics",
45828
49014
  capScope: "device",
@@ -45877,6 +49063,18 @@ Object.freeze({
45877
49063
  addonId: null,
45878
49064
  access: "create"
45879
49065
  },
49066
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
49067
+ capName: "pipeline-analytics",
49068
+ capScope: "device",
49069
+ addonId: null,
49070
+ access: "delete"
49071
+ },
49072
+ "pipelineAnalytics.renameRetrainCollection": {
49073
+ capName: "pipeline-analytics",
49074
+ capScope: "device",
49075
+ addonId: null,
49076
+ access: "create"
49077
+ },
45880
49078
  "pipelineAnalytics.restageRetrainTrack": {
45881
49079
  capName: "pipeline-analytics",
45882
49080
  capScope: "device",
@@ -45937,6 +49135,12 @@ Object.freeze({
45937
49135
  addonId: null,
45938
49136
  access: "create"
45939
49137
  },
49138
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49139
+ capName: "pipeline-analytics",
49140
+ capScope: "device",
49141
+ addonId: null,
49142
+ access: "view"
49143
+ },
45940
49144
  "pipelineAnalytics.wipeAllAnalytics": {
45941
49145
  capName: "pipeline-analytics",
45942
49146
  capScope: "device",
@@ -46165,6 +49369,12 @@ Object.freeze({
46165
49369
  addonId: null,
46166
49370
  access: "view"
46167
49371
  },
49372
+ "pipelineOrchestrator.abortNodeBenchmark": {
49373
+ capName: "pipeline-orchestrator",
49374
+ capScope: "system",
49375
+ addonId: null,
49376
+ access: "create"
49377
+ },
46168
49378
  "pipelineOrchestrator.applyAutoTune": {
46169
49379
  capName: "pipeline-orchestrator",
46170
49380
  capScope: "system",
@@ -46189,6 +49399,12 @@ Object.freeze({
46189
49399
  addonId: null,
46190
49400
  access: "create"
46191
49401
  },
49402
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
49403
+ capName: "pipeline-orchestrator",
49404
+ capScope: "system",
49405
+ addonId: null,
49406
+ access: "delete"
49407
+ },
46192
49408
  "pipelineOrchestrator.getAgentLoad": {
46193
49409
  capName: "pipeline-orchestrator",
46194
49410
  capScope: "system",
@@ -46297,6 +49513,24 @@ Object.freeze({
46297
49513
  addonId: null,
46298
49514
  access: "view"
46299
49515
  },
49516
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
49517
+ capName: "pipeline-orchestrator",
49518
+ capScope: "system",
49519
+ addonId: null,
49520
+ access: "view"
49521
+ },
49522
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
49523
+ capName: "pipeline-orchestrator",
49524
+ capScope: "system",
49525
+ addonId: null,
49526
+ access: "view"
49527
+ },
49528
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
49529
+ capName: "pipeline-orchestrator",
49530
+ capScope: "system",
49531
+ addonId: null,
49532
+ access: "view"
49533
+ },
46300
49534
  "pipelineOrchestrator.getNodeInferenceDevices": {
46301
49535
  capName: "pipeline-orchestrator",
46302
49536
  capScope: "system",
@@ -46339,6 +49573,12 @@ Object.freeze({
46339
49573
  addonId: null,
46340
49574
  access: "view"
46341
49575
  },
49576
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
49577
+ capName: "pipeline-orchestrator",
49578
+ capScope: "system",
49579
+ addonId: null,
49580
+ access: "view"
49581
+ },
46342
49582
  "pipelineOrchestrator.pauseForStorageMigration": {
46343
49583
  capName: "pipeline-orchestrator",
46344
49584
  capScope: "system",
@@ -46483,6 +49723,12 @@ Object.freeze({
46483
49723
  addonId: null,
46484
49724
  access: "create"
46485
49725
  },
49726
+ "pipelineOrchestrator.startNodeBenchmark": {
49727
+ capName: "pipeline-orchestrator",
49728
+ capScope: "system",
49729
+ addonId: null,
49730
+ access: "create"
49731
+ },
46486
49732
  "pipelineOrchestrator.suggestShares": {
46487
49733
  capName: "pipeline-orchestrator",
46488
49734
  capScope: "system",
@@ -46501,6 +49747,12 @@ Object.freeze({
46501
49747
  addonId: null,
46502
49748
  access: "create"
46503
49749
  },
49750
+ "pipelineRunner.abortNodeBench": {
49751
+ capName: "pipeline-runner",
49752
+ capScope: "system",
49753
+ addonId: null,
49754
+ access: "create"
49755
+ },
46504
49756
  "pipelineRunner.attachCamera": {
46505
49757
  capName: "pipeline-runner",
46506
49758
  capScope: "system",
@@ -46549,6 +49801,12 @@ Object.freeze({
46549
49801
  addonId: null,
46550
49802
  access: "view"
46551
49803
  },
49804
+ "pipelineRunner.getNodeBenchStatus": {
49805
+ capName: "pipeline-runner",
49806
+ capScope: "system",
49807
+ addonId: null,
49808
+ access: "view"
49809
+ },
46552
49810
  "pipelineRunner.getParkedTrackFrame": {
46553
49811
  capName: "pipeline-runner",
46554
49812
  capScope: "system",
@@ -46591,6 +49849,12 @@ Object.freeze({
46591
49849
  addonId: null,
46592
49850
  access: "create"
46593
49851
  },
49852
+ "pipelineRunner.startNodeBench": {
49853
+ capName: "pipeline-runner",
49854
+ capScope: "system",
49855
+ addonId: null,
49856
+ access: "create"
49857
+ },
46594
49858
  "plateGallery.assignPlate": {
46595
49859
  capName: "plate-gallery",
46596
49860
  capScope: "system",
@@ -48253,6 +51517,174 @@ Object.freeze({
48253
51517
  addonId: null,
48254
51518
  access: "view"
48255
51519
  },
51520
+ "training.canaryResult": {
51521
+ capName: "training",
51522
+ capScope: "system",
51523
+ addonId: null,
51524
+ access: "create"
51525
+ },
51526
+ "training.cancelJob": {
51527
+ capName: "training",
51528
+ capScope: "system",
51529
+ addonId: null,
51530
+ access: "create"
51531
+ },
51532
+ "training.discardResult": {
51533
+ capName: "training",
51534
+ capScope: "system",
51535
+ addonId: null,
51536
+ access: "create"
51537
+ },
51538
+ "training.findDatasetVersionIdByName": {
51539
+ capName: "training",
51540
+ capScope: "system",
51541
+ addonId: null,
51542
+ access: "view"
51543
+ },
51544
+ "training.getDatasetVersion": {
51545
+ capName: "training",
51546
+ capScope: "system",
51547
+ addonId: null,
51548
+ access: "view"
51549
+ },
51550
+ "training.getJob": {
51551
+ capName: "training",
51552
+ capScope: "system",
51553
+ addonId: null,
51554
+ access: "view"
51555
+ },
51556
+ "training.getJobResult": {
51557
+ capName: "training",
51558
+ capScope: "system",
51559
+ addonId: null,
51560
+ access: "view"
51561
+ },
51562
+ "training.listBaseModels": {
51563
+ capName: "training",
51564
+ capScope: "system",
51565
+ addonId: null,
51566
+ access: "view"
51567
+ },
51568
+ "training.listDatasetVersions": {
51569
+ capName: "training",
51570
+ capScope: "system",
51571
+ addonId: null,
51572
+ access: "view"
51573
+ },
51574
+ "training.listJobs": {
51575
+ capName: "training",
51576
+ capScope: "system",
51577
+ addonId: null,
51578
+ access: "view"
51579
+ },
51580
+ "training.planJob": {
51581
+ capName: "training",
51582
+ capScope: "system",
51583
+ addonId: null,
51584
+ access: "view"
51585
+ },
51586
+ "training.putDatasetVersion": {
51587
+ capName: "training",
51588
+ capScope: "system",
51589
+ addonId: null,
51590
+ access: "create"
51591
+ },
51592
+ "training.registerResult": {
51593
+ capName: "training",
51594
+ capScope: "system",
51595
+ addonId: null,
51596
+ access: "create"
51597
+ },
51598
+ "training.removeDatasetVersion": {
51599
+ capName: "training",
51600
+ capScope: "system",
51601
+ addonId: null,
51602
+ access: "delete"
51603
+ },
51604
+ "training.rollbackCanary": {
51605
+ capName: "training",
51606
+ capScope: "system",
51607
+ addonId: null,
51608
+ access: "create"
51609
+ },
51610
+ "training.startJob": {
51611
+ capName: "training",
51612
+ capScope: "system",
51613
+ addonId: null,
51614
+ access: "create"
51615
+ },
51616
+ "trainingProvider.cancelJob": {
51617
+ capName: "training-provider",
51618
+ capScope: "system",
51619
+ addonId: null,
51620
+ access: "create"
51621
+ },
51622
+ "trainingProvider.cleanupJob": {
51623
+ capName: "training-provider",
51624
+ capScope: "system",
51625
+ addonId: null,
51626
+ access: "create"
51627
+ },
51628
+ "trainingProvider.describe": {
51629
+ capName: "training-provider",
51630
+ capScope: "system",
51631
+ addonId: null,
51632
+ access: "view"
51633
+ },
51634
+ "trainingProvider.estimateJob": {
51635
+ capName: "training-provider",
51636
+ capScope: "system",
51637
+ addonId: null,
51638
+ access: "view"
51639
+ },
51640
+ "trainingProvider.getJob": {
51641
+ capName: "training-provider",
51642
+ capScope: "system",
51643
+ addonId: null,
51644
+ access: "view"
51645
+ },
51646
+ "trainingProvider.listJobEvents": {
51647
+ capName: "training-provider",
51648
+ capScope: "system",
51649
+ addonId: null,
51650
+ access: "view"
51651
+ },
51652
+ "trainingProvider.listJobs": {
51653
+ capName: "training-provider",
51654
+ capScope: "system",
51655
+ addonId: null,
51656
+ access: "view"
51657
+ },
51658
+ "trainingProvider.offerArtifact": {
51659
+ capName: "training-provider",
51660
+ capScope: "system",
51661
+ addonId: null,
51662
+ access: "create"
51663
+ },
51664
+ "trainingProvider.readResult": {
51665
+ capName: "training-provider",
51666
+ capScope: "system",
51667
+ addonId: null,
51668
+ access: "create"
51669
+ },
51670
+ "trainingProvider.submitJob": {
51671
+ capName: "training-provider",
51672
+ capScope: "system",
51673
+ addonId: null,
51674
+ access: "create"
51675
+ },
51676
+ "trainingProvider.uploadDataset": {
51677
+ capName: "training-provider",
51678
+ capScope: "system",
51679
+ addonId: null,
51680
+ access: "create"
51681
+ },
51682
+ "trainingProvider.validateCredentials": {
51683
+ capName: "training-provider",
51684
+ capScope: "system",
51685
+ addonId: null,
51686
+ access: "create"
51687
+ },
48256
51688
  "turnProvider.getTurnServers": {
48257
51689
  capName: "turn-provider",
48258
51690
  capScope: "system",
@@ -48277,12 +51709,6 @@ Object.freeze({
48277
51709
  addonId: null,
48278
51710
  access: "create"
48279
51711
  },
48280
- "userManagement.createApiKey": {
48281
- capName: "user-management",
48282
- capScope: "system",
48283
- addonId: null,
48284
- access: "create"
48285
- },
48286
51712
  "userManagement.createScopedToken": {
48287
51713
  capName: "user-management",
48288
51714
  capScope: "system",
@@ -48319,12 +51745,6 @@ Object.freeze({
48319
51745
  addonId: null,
48320
51746
  access: "view"
48321
51747
  },
48322
- "userManagement.linkExternalIdentity": {
48323
- capName: "user-management",
48324
- capScope: "system",
48325
- addonId: null,
48326
- access: "create"
48327
- },
48328
51748
  "userManagement.listApiKeys": {
48329
51749
  capName: "user-management",
48330
51750
  capScope: "system",
@@ -48427,12 +51847,6 @@ Object.freeze({
48427
51847
  addonId: null,
48428
51848
  access: "create"
48429
51849
  },
48430
- "userManagement.validateApiKey": {
48431
- capName: "user-management",
48432
- capScope: "system",
48433
- addonId: null,
48434
- access: "view"
48435
- },
48436
51850
  "userManagement.validateCredentials": {
48437
51851
  capName: "user-management",
48438
51852
  capScope: "system",
@@ -51520,6 +54934,11 @@ Object.freeze({
51520
54934
  form: "single",
51521
54935
  optional: false
51522
54936
  }],
54937
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
54938
+ name: "deviceId",
54939
+ form: "single",
54940
+ optional: false
54941
+ }],
51523
54942
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
51524
54943
  name: "deviceId",
51525
54944
  form: "single",
@@ -51710,6 +55129,11 @@ Object.freeze({
51710
55129
  form: "single",
51711
55130
  optional: false
51712
55131
  }],
55132
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
55133
+ name: "deviceId",
55134
+ form: "single",
55135
+ optional: false
55136
+ }],
51713
55137
  "pipelineAnalytics.pruneEventsBefore": [{
51714
55138
  name: "deviceId",
51715
55139
  form: "single",
@@ -52536,6 +55960,11 @@ Object.freeze({
52536
55960
  form: "single",
52537
55961
  optional: false
52538
55962
  }],
55963
+ "training.canaryResult": [{
55964
+ name: "deviceIds",
55965
+ form: "array",
55966
+ optional: false
55967
+ }],
52539
55968
  "update.getStatus": [{
52540
55969
  name: "deviceId",
52541
55970
  form: "single",