@camstack/addon-decoder-nodeav 1.2.121 → 1.2.123

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +3961 -120
  2. package/dist/index.mjs +3961 -120
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
- //#region ../types/dist/event-category-B_0XEcLF.mjs
2
+ //#region ../types/dist/event-category-DaIZi00R.mjs
3
3
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
4
  EventCategory["SystemBoot"] = "system.boot";
5
5
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -78,6 +78,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
78
78
  */
79
79
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
80
80
  /**
81
+ * A keychain value was stored or removed (D787). Carries the ref, its
82
+ * owner and the new version — NEVER the value. A process holding the ref
83
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
84
+ * Telemetry (D8): a process that misses it still revalidates by version.
85
+ */
86
+ EventCategory["KeychainChanged"] = "keychain.changed";
87
+ /**
81
88
  * Addon recovered from a previous failure. Emitted when an addon
82
89
  * transitions from `failed` back to `healthy` (typically via the
83
90
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5370,7 +5377,7 @@ var ZodIssueCode = {
5370
5377
  var ZodFirstPartyTypeKind;
5371
5378
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5372
5379
  //#endregion
5373
- //#region ../types/dist/sleep-BNeXenvr.mjs
5380
+ //#region ../types/dist/sleep-DwAQ9sqX.mjs
5374
5381
  /**
5375
5382
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5376
5383
  * window to float samples (D455).
@@ -5449,6 +5456,97 @@ function buildAlawTable() {
5449
5456
  }
5450
5457
  buildUlawTable();
5451
5458
  buildAlawTable();
5459
+ /** Is this field's stored value a credential? */
5460
+ function isSecretConfigField(field) {
5461
+ if (field.type === "password") return true;
5462
+ return "secret" in field && field.secret === true;
5463
+ }
5464
+ /**
5465
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5466
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5467
+ */
5468
+ function isKeychainStoredField(field) {
5469
+ if (!isSecretConfigField(field)) return false;
5470
+ if (field.type === "textarea" && field.isJson === true) return false;
5471
+ return !("storage" in field && field.storage === "inline");
5472
+ }
5473
+ /**
5474
+ * What a settings blob holds where a secret used to be.
5475
+ *
5476
+ * A keychain-stored field never holds its value. It holds a self-describing
5477
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5478
+ * code can mistake it for a credential and no form can send it to a camera as
5479
+ * a password. The empty state is `null` / absent, never `''`.
5480
+ *
5481
+ * The same shapes travel to and from the admin UI:
5482
+ *
5483
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5484
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5485
+ * value is set, never the value.
5486
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5487
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5488
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5489
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5490
+ * treating it as "clear" is how a save destroyed a stored credential before.
5491
+ *
5492
+ * Pure and browser-safe.
5493
+ */
5494
+ var SECRET_CLEAR = { $secretClear: true };
5495
+ /** The `'***'` token D634 redaction writes for non-admins. */
5496
+ var LEGACY_DEVICE_REDACTION = "***";
5497
+ function isRecord$2(value) {
5498
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5499
+ }
5500
+ function makeSecretMarker(ref) {
5501
+ return {
5502
+ $secret: ref,
5503
+ v: 1
5504
+ };
5505
+ }
5506
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5507
+ function isSecretMarker(value) {
5508
+ if (!isRecord$2(value)) return false;
5509
+ const ref = value["$secret"];
5510
+ return typeof ref === "string" && ref.length > 0;
5511
+ }
5512
+ function isSecretClear(value) {
5513
+ return isRecord$2(value) && value["$secretClear"] === true;
5514
+ }
5515
+ /**
5516
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5517
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5518
+ * survives this function.
5519
+ */
5520
+ function toSecretFieldView(stored) {
5521
+ if (isSecretMarker(stored)) return {
5522
+ $secret: stored.$secret,
5523
+ v: 1,
5524
+ set: true
5525
+ };
5526
+ if (typeof stored === "string" && stored.length > 0) return {
5527
+ $secret: null,
5528
+ v: 1,
5529
+ set: true,
5530
+ inline: true
5531
+ };
5532
+ return null;
5533
+ }
5534
+ /**
5535
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5536
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5537
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5538
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5539
+ */
5540
+ function classifySecretWrite(incoming) {
5541
+ if (isSecretClear(incoming)) return { kind: "clear" };
5542
+ if (typeof incoming !== "string") return { kind: "keep" };
5543
+ if (incoming.length === 0) return { kind: "keep" };
5544
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5545
+ return {
5546
+ kind: "set",
5547
+ value: incoming
5548
+ };
5549
+ }
5452
5550
  Object.fromEntries([
5453
5551
  {
5454
5552
  id: "overview",
@@ -5620,33 +5718,19 @@ Object.fromEntries([
5620
5718
  function isValuelessField(field) {
5621
5719
  return field.type === "separator" || field.type === "info" || field.type === "qr-code" || field.type === "button" || field.type === "object-array" || field.type === "widget" || field.type === "addon-action-button" || field.type === "device-action-button";
5622
5720
  }
5623
- /**
5624
- * Merge a `ConfigUISchema` with a raw `values` record into a
5625
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5626
- * before returning to the admin UI. Groups are walked recursively.
5627
- *
5628
- * For each leaf field:
5629
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5630
- * - other fields get `value = values[key] ?? field.default ?? null`
5631
- *
5632
- * Unknown keys in `values` (keys not declared in the schema) are silently
5633
- * ignored — they don't contribute to the output. Missing keys fall back to
5634
- * the schema default or `null`. This mirrors the old backend behaviour where
5635
- * `FormBuilder` rendered `values[key] ?? field.default`.
5636
- */
5637
- function hydrateSchema(schema, values) {
5721
+ function hydrateSchema(schema, values, options = {}) {
5638
5722
  return {
5639
5723
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5640
5724
  sections: schema.sections.map((section) => ({
5641
5725
  ...section,
5642
- fields: section.fields.map((field) => hydrateField(field, values))
5726
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5643
5727
  }))
5644
5728
  };
5645
5729
  }
5646
- function hydrateField(field, values) {
5730
+ function hydrateField(field, values, options) {
5647
5731
  if (isValuelessField(field)) return field;
5648
5732
  if (field.type === "group") {
5649
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5733
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5650
5734
  return {
5651
5735
  ...field,
5652
5736
  fields: hydratedChildren
@@ -5655,7 +5739,7 @@ function hydrateField(field, values) {
5655
5739
  if (field.type === "sub-tabs") {
5656
5740
  const hydratedTabs = field.tabs.map((tab) => ({
5657
5741
  ...tab,
5658
- fields: tab.fields.map((child) => hydrateField(child, values))
5742
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5659
5743
  }));
5660
5744
  return {
5661
5745
  ...field,
@@ -5665,6 +5749,33 @@ function hydrateField(field, values) {
5665
5749
  const key = field.key;
5666
5750
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5667
5751
  const defaultValue = field.default;
5752
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5753
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5754
+ ...field,
5755
+ value: toSecretFieldView(storedValue)
5756
+ };
5757
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5758
+ ...field,
5759
+ value: null
5760
+ };
5761
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5762
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5763
+ if (secretItemKeys.length > 0) {
5764
+ const rows = storedValue.map((row) => {
5765
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5766
+ const out = { ...row };
5767
+ for (const k of secretItemKeys) {
5768
+ const v = Reflect.get(row, k);
5769
+ if (asView(v)) out[k] = toSecretFieldView(v);
5770
+ }
5771
+ return out;
5772
+ });
5773
+ return {
5774
+ ...field,
5775
+ value: rows
5776
+ };
5777
+ }
5778
+ }
5668
5779
  if (field.multiple) {
5669
5780
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5670
5781
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5907,6 +6018,778 @@ function projectStore(store, perNodeKeys, nodeId) {
5907
6018
  }
5908
6019
  return out;
5909
6020
  }
6021
+ var GLOBAL_SCOPE = { kind: "global" };
6022
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6023
+ function globalSecretScope() {
6024
+ return GLOBAL_SCOPE;
6025
+ }
6026
+ function encodeSegment(value) {
6027
+ return encodeURIComponent(value);
6028
+ }
6029
+ function decodeSegment(value) {
6030
+ try {
6031
+ return decodeURIComponent(value);
6032
+ } catch {
6033
+ return null;
6034
+ }
6035
+ }
6036
+ /**
6037
+ * The field path of a value inside an array item, addressed by the item's id:
6038
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6039
+ * `providers[authentik].clientSecret`.
6040
+ */
6041
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6042
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6043
+ }
6044
+ function parseScope(segments) {
6045
+ switch (segments[0]) {
6046
+ case "global": return {
6047
+ scope: GLOBAL_SCOPE,
6048
+ used: 1
6049
+ };
6050
+ case "node": {
6051
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6052
+ return nodeId === null || nodeId.length === 0 ? null : {
6053
+ scope: {
6054
+ kind: "node",
6055
+ nodeId
6056
+ },
6057
+ used: 2
6058
+ };
6059
+ }
6060
+ case "device": {
6061
+ const raw = segments[1];
6062
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6063
+ return {
6064
+ scope: {
6065
+ kind: "device",
6066
+ deviceId: Number(raw)
6067
+ },
6068
+ used: 2
6069
+ };
6070
+ }
6071
+ case "integration": {
6072
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6073
+ return id === null || id.length === 0 ? null : {
6074
+ scope: {
6075
+ kind: "integration",
6076
+ integrationId: id
6077
+ },
6078
+ used: 2
6079
+ };
6080
+ }
6081
+ case "row": {
6082
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6083
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6084
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6085
+ return {
6086
+ scope: {
6087
+ kind: "row",
6088
+ collection,
6089
+ rowId
6090
+ },
6091
+ used: 3
6092
+ };
6093
+ }
6094
+ default: return null;
6095
+ }
6096
+ }
6097
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6098
+ function parseSecretRef(ref) {
6099
+ if (!ref.startsWith("secret://")) return null;
6100
+ const segments = ref.slice(9).split("/");
6101
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6102
+ if (owner === null || owner.length === 0) return null;
6103
+ const parsed = parseScope(segments.slice(1));
6104
+ if (parsed === null) return null;
6105
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6106
+ if (fieldPath.length === 0) return null;
6107
+ return {
6108
+ owner,
6109
+ scope: parsed.scope,
6110
+ fieldPath
6111
+ };
6112
+ }
6113
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6114
+ var KeychainWriteRefusedError = class extends Error {
6115
+ fieldPath;
6116
+ constructor(fieldPath, cause) {
6117
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6118
+ this.fieldPath = fieldPath;
6119
+ this.name = "KeychainWriteRefusedError";
6120
+ }
6121
+ };
6122
+ var KEEP = { kind: "keep" };
6123
+ function isRecord$1(value) {
6124
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6125
+ }
6126
+ function defaultMintId() {
6127
+ return globalThis.crypto.randomUUID();
6128
+ }
6129
+ /** Every marker ref anywhere under `value`. */
6130
+ function collectSecretMarkerRefs(value, out = []) {
6131
+ if (isSecretMarker(value)) {
6132
+ out.push(value.$secret);
6133
+ return out;
6134
+ }
6135
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6136
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6137
+ return out;
6138
+ }
6139
+ async function storedValueEquals(secrets, marker, candidate) {
6140
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6141
+ return resolved?.kind === "value" && resolved.value === candidate;
6142
+ }
6143
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6144
+ const intent = classifySecretWrite(incoming);
6145
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6146
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6147
+ if (intent.kind === "keep") return KEEP;
6148
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6149
+ if (intent.kind === "clear") {
6150
+ if (storedIsOurs) ctx.deletes.push(ref);
6151
+ return {
6152
+ kind: "value",
6153
+ value: null
6154
+ };
6155
+ }
6156
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6157
+ kind: "value",
6158
+ value: stored
6159
+ };
6160
+ try {
6161
+ await ctx.secrets.put(ref, intent.value);
6162
+ } catch (err) {
6163
+ throw new KeychainWriteRefusedError(fieldPath, err);
6164
+ }
6165
+ return {
6166
+ kind: "value",
6167
+ value: makeSecretMarker(ref)
6168
+ };
6169
+ }
6170
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6171
+ function applyMember(out, key, result, storedParent) {
6172
+ if (result.kind === "value") {
6173
+ out[key] = result.value;
6174
+ return;
6175
+ }
6176
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6177
+ else delete out[key];
6178
+ }
6179
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6180
+ const out = { ...incoming };
6181
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6182
+ return out;
6183
+ }
6184
+ function rowId(row, idKey) {
6185
+ const raw = row[idKey];
6186
+ if (typeof raw === "string" && raw.length > 0) return raw;
6187
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6188
+ return null;
6189
+ }
6190
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6191
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6192
+ if (!Array.isArray(incoming)) {
6193
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6194
+ return {
6195
+ kind: "value",
6196
+ value: incoming
6197
+ };
6198
+ }
6199
+ const storedById = /* @__PURE__ */ new Map();
6200
+ for (const row of storedRows) {
6201
+ const id = rowId(row, node.idKey);
6202
+ if (id !== null) storedById.set(id, row);
6203
+ }
6204
+ const kept = /* @__PURE__ */ new Set();
6205
+ const rows = [];
6206
+ for (const row of incoming) {
6207
+ if (!isRecord$1(row)) {
6208
+ rows.push(row);
6209
+ continue;
6210
+ }
6211
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6212
+ kept.add(id);
6213
+ const withId = {
6214
+ ...row,
6215
+ [node.idKey]: row[node.idKey] ?? id
6216
+ };
6217
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6218
+ const storedRow = storedById.get(id) ?? {};
6219
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6220
+ }
6221
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6222
+ return {
6223
+ kind: "value",
6224
+ value: rows
6225
+ };
6226
+ }
6227
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6228
+ switch (node.kind) {
6229
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6230
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6231
+ case "object": {
6232
+ if (!isRecord$1(incoming)) {
6233
+ if (incoming === void 0) return KEEP;
6234
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6235
+ return {
6236
+ kind: "value",
6237
+ value: incoming
6238
+ };
6239
+ }
6240
+ const storedObj = isRecord$1(stored) ? stored : {};
6241
+ return {
6242
+ kind: "value",
6243
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6244
+ };
6245
+ }
6246
+ }
6247
+ }
6248
+ /** Split a perNode-scoped key (`key@nodeId`). */
6249
+ function splitNodeKey(key) {
6250
+ const at = key.indexOf("@");
6251
+ return at <= 0 ? {
6252
+ base: key,
6253
+ nodeId: null
6254
+ } : {
6255
+ base: key.slice(0, at),
6256
+ nodeId: key.slice(at + 1)
6257
+ };
6258
+ }
6259
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6260
+ async function transformSecretWrite(input) {
6261
+ const deletes = [];
6262
+ const base = {
6263
+ secrets: input.secrets,
6264
+ mintId: input.mintId ?? defaultMintId,
6265
+ deletes,
6266
+ operatorWrite: input.operatorWrite === true
6267
+ };
6268
+ const out = {};
6269
+ for (const [key, incoming] of Object.entries(input.patch)) {
6270
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6271
+ const node = input.tree.get(baseKey);
6272
+ if (node === void 0) {
6273
+ out[key] = incoming;
6274
+ continue;
6275
+ }
6276
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6277
+ kind: "node",
6278
+ nodeId
6279
+ } : input.scope ?? globalSecretScope();
6280
+ const result = await writeNode({
6281
+ ...base,
6282
+ scope
6283
+ }, node, incoming, input.stored[key], baseKey);
6284
+ if (result.kind === "value") out[key] = result.value;
6285
+ }
6286
+ return {
6287
+ patch: out,
6288
+ afterWrite: async () => {
6289
+ if (deletes.length === 0) return { orphaned: [] };
6290
+ try {
6291
+ await input.secrets.delete([...new Set(deletes)]);
6292
+ return { orphaned: [] };
6293
+ } catch {
6294
+ return { orphaned: [...new Set(deletes)] };
6295
+ }
6296
+ }
6297
+ };
6298
+ }
6299
+ /** Is `ref` one of `owner`'s refs? */
6300
+ function isSecretRefOwnedBy(ref, owner) {
6301
+ return parseSecretRef(ref)?.owner === owner;
6302
+ }
6303
+ /**
6304
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6305
+ * reference when there is no marker (no allocation, no keychain call).
6306
+ */
6307
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6308
+ const keepMarker = options.unresolved === "keep-marker";
6309
+ const owner = options.ownedBy;
6310
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6311
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6312
+ if (refs.length === 0) return {
6313
+ value,
6314
+ unresolved: []
6315
+ };
6316
+ const answers = await secrets.resolve(refs);
6317
+ const unresolved = [];
6318
+ for (const ref of new Set(refs)) {
6319
+ const answer = answers[ref];
6320
+ if (answer === void 0) unresolved.push({
6321
+ ref,
6322
+ reason: "not-initialized"
6323
+ });
6324
+ else if (answer.kind === "unavailable") unresolved.push({
6325
+ ref,
6326
+ reason: answer.reason
6327
+ });
6328
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6329
+ ref,
6330
+ reason: answer.kind
6331
+ });
6332
+ }
6333
+ const substitute = (v) => {
6334
+ if (isSecretMarker(v)) {
6335
+ if (!inScope(v.$secret)) return {
6336
+ keep: true,
6337
+ value: v
6338
+ };
6339
+ const answer = answers[v.$secret];
6340
+ if (answer?.kind === "value") return {
6341
+ keep: true,
6342
+ value: answer.value
6343
+ };
6344
+ return keepMarker ? {
6345
+ keep: true,
6346
+ value: v
6347
+ } : {
6348
+ keep: false,
6349
+ value: void 0
6350
+ };
6351
+ }
6352
+ if (Array.isArray(v)) {
6353
+ const items = [];
6354
+ for (const item of v) {
6355
+ const s = substitute(item);
6356
+ if (s.keep) items.push(s.value);
6357
+ }
6358
+ return {
6359
+ keep: true,
6360
+ value: items
6361
+ };
6362
+ }
6363
+ if (isRecord$1(v)) {
6364
+ const out = {};
6365
+ for (const [k, child] of Object.entries(v)) {
6366
+ const s = substitute(child);
6367
+ if (s.keep) out[k] = s.value;
6368
+ }
6369
+ return {
6370
+ keep: true,
6371
+ value: out
6372
+ };
6373
+ }
6374
+ return {
6375
+ keep: true,
6376
+ value: v
6377
+ };
6378
+ };
6379
+ return {
6380
+ value: substitute(value).value,
6381
+ unresolved
6382
+ };
6383
+ }
6384
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6385
+ var SecretOverwriteRefusedError = class extends Error {
6386
+ ref;
6387
+ reason;
6388
+ constructor(ref, reason) {
6389
+ super(`secret ${ref} was not replaced: its stored value cannot be read right now (${reason}), and an addon may not overwrite a secret it cannot see. Nothing was written.`);
6390
+ this.ref = ref;
6391
+ this.reason = reason;
6392
+ this.name = "SecretOverwriteRefusedError";
6393
+ }
6394
+ };
6395
+ function isRecord(value) {
6396
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6397
+ }
6398
+ function resolvedValue(pass, marker) {
6399
+ const answer = pass.answers[marker.$secret];
6400
+ return answer?.kind === "value" ? answer.value : null;
6401
+ }
6402
+ async function atMarker(pass, incoming, stored) {
6403
+ if (incoming === null) return stored;
6404
+ if (typeof incoming !== "string") return incoming;
6405
+ if (incoming === resolvedValue(pass, stored)) return stored;
6406
+ const intent = classifySecretWrite(incoming);
6407
+ if (intent.kind !== "set") return stored;
6408
+ const ref = stored.$secret;
6409
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6410
+ const answer = pass.answers[ref];
6411
+ if ((answer === void 0 || answer.kind === "unavailable" || answer.kind === "forbidden") && !pass.operatorWrite) throw new SecretOverwriteRefusedError(ref, answer === void 0 ? "not-initialized" : answer.kind === "unavailable" ? answer.reason : answer.kind);
6412
+ try {
6413
+ await pass.secrets.put(ref, intent.value);
6414
+ } catch (err) {
6415
+ throw new KeychainWriteRefusedError(ref, err);
6416
+ }
6417
+ pass.changedRefs.push(ref);
6418
+ return stored;
6419
+ }
6420
+ function inArray(pass, incoming, stored) {
6421
+ return incoming.map((item, index) => {
6422
+ const twin = stored[index];
6423
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6424
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6425
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6426
+ return item;
6427
+ });
6428
+ }
6429
+ function inArrayRow(pass, incoming, stored) {
6430
+ const out = { ...incoming };
6431
+ for (const [key, value] of Object.entries(incoming)) {
6432
+ const twin = stored[key];
6433
+ if (isSecretMarker(twin)) {
6434
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6435
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6436
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6437
+ }
6438
+ return out;
6439
+ }
6440
+ async function walk(pass, incoming, stored) {
6441
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6442
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6443
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6444
+ const out = { ...incoming };
6445
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6446
+ return out;
6447
+ }
6448
+ /** Restore markers a write-back carries as values. See the file doc. */
6449
+ async function restoreUnchangedSecrets(input) {
6450
+ const refs = [];
6451
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6452
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6453
+ if (owned.length === 0) return {
6454
+ patch: input.patch,
6455
+ changedRefs: []
6456
+ };
6457
+ const pass = {
6458
+ secrets: input.secrets,
6459
+ answers: await input.secrets.resolve([...new Set(owned)]),
6460
+ operatorWrite: input.operatorWrite,
6461
+ changedRefs: []
6462
+ };
6463
+ const out = {};
6464
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6465
+ return {
6466
+ patch: out,
6467
+ changedRefs: pass.changedRefs
6468
+ };
6469
+ }
6470
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6471
+ function isJsonEqual(a, b) {
6472
+ if (Object.is(a, b)) return true;
6473
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6474
+ if (isRecord(a) && isRecord(b)) {
6475
+ const keys = Object.keys(a);
6476
+ if (keys.length !== Object.keys(b).length) return false;
6477
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6478
+ }
6479
+ return false;
6480
+ }
6481
+ /** The patch without the keys whose value already equals the stored one. */
6482
+ function dropUnchangedKeys(patch, stored) {
6483
+ const out = {};
6484
+ for (const [key, value] of Object.entries(patch)) {
6485
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6486
+ out[key] = value;
6487
+ }
6488
+ return out;
6489
+ }
6490
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6491
+ function markerKeysOf(blob, owner) {
6492
+ const keys = /* @__PURE__ */ new Set();
6493
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6494
+ return keys;
6495
+ }
6496
+ function nodeFromStored(value, owner) {
6497
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6498
+ if (!isRecord(value)) return null;
6499
+ const children = /* @__PURE__ */ new Map();
6500
+ for (const [key, child] of Object.entries(value)) {
6501
+ const node = nodeFromStored(child, owner);
6502
+ if (node !== null) children.set(key, node);
6503
+ }
6504
+ return children.size > 0 ? {
6505
+ kind: "object",
6506
+ children
6507
+ } : null;
6508
+ }
6509
+ /**
6510
+ * The declared secret tree, widened by every place the STORED blob holds a
6511
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6512
+ * never declared: Wyze before b4906cec6) still gets the save path's
6513
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6514
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6515
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6516
+ * builtin that keeps another addon's marker (device-manager) never takes it
6517
+ * over.
6518
+ */
6519
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6520
+ const added = /* @__PURE__ */ new Map();
6521
+ for (const key of keys) {
6522
+ const at = key.indexOf("@");
6523
+ const base = at > 0 ? key.slice(0, at) : key;
6524
+ if (declared.has(base) || added.has(base)) continue;
6525
+ const node = nodeFromStored(stored[key], owner);
6526
+ if (node !== null) added.set(base, node);
6527
+ }
6528
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6529
+ }
6530
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6531
+ async function readStoredAddonBlob(raw) {
6532
+ const threeWay = raw.readAddonStoreResult;
6533
+ if (threeWay === void 0) return raw.readAddonStore();
6534
+ const result = await threeWay.call(raw);
6535
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6536
+ return result.kind === "missing" ? {} : result.value;
6537
+ }
6538
+ function touchesTree(tree, patch) {
6539
+ if (tree.size === 0) return false;
6540
+ for (const key of Object.keys(patch)) {
6541
+ const at = key.indexOf("@");
6542
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6543
+ }
6544
+ return false;
6545
+ }
6546
+ /**
6547
+ * Which top-level keys of each store held markers when last seen. `undefined`
6548
+ * for a store not seen yet: its first write reads it, to be safe.
6549
+ */
6550
+ var MarkerKeyIndex = class {
6551
+ owner;
6552
+ byStore = /* @__PURE__ */ new Map();
6553
+ constructor(owner) {
6554
+ this.owner = owner;
6555
+ }
6556
+ seen(store, blob) {
6557
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6558
+ }
6559
+ wrote(store, patch) {
6560
+ const keys = this.byStore.get(store);
6561
+ if (keys === void 0) return;
6562
+ const now = markerKeysOf(patch, this.owner);
6563
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6564
+ else keys.delete(key);
6565
+ }
6566
+ mayHoldMarkers(store, patch) {
6567
+ const keys = this.byStore.get(store);
6568
+ if (keys === void 0) return true;
6569
+ return Object.keys(patch).some((key) => keys.has(key));
6570
+ }
6571
+ };
6572
+ function createHandle(raw, opts) {
6573
+ const chains = /* @__PURE__ */ new Map();
6574
+ const serialize = (key, fn) => {
6575
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6576
+ const tail = next.catch(() => void 0);
6577
+ chains.set(key, tail);
6578
+ tail.then(() => {
6579
+ if (chains.get(key) === tail) chains.delete(key);
6580
+ });
6581
+ return next;
6582
+ };
6583
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6584
+ const resolveRead = async (store, blob) => {
6585
+ index.seen(store, blob);
6586
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6587
+ unresolved: "keep-marker",
6588
+ ownedBy: opts.secrets.owner
6589
+ });
6590
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6591
+ return value;
6592
+ };
6593
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6594
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6595
+ await rawWrite(patch);
6596
+ index.wrote(store, patch);
6597
+ return { changed: true };
6598
+ }
6599
+ return serialize(store, async () => {
6600
+ const stored = await readStored();
6601
+ index.seen(store, stored);
6602
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6603
+ const restored = await restoreUnchangedSecrets({
6604
+ patch,
6605
+ stored,
6606
+ secrets: opts.secrets,
6607
+ operatorWrite
6608
+ });
6609
+ const result = await transformSecretWrite({
6610
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6611
+ secrets: opts.secrets,
6612
+ patch: restored.patch,
6613
+ stored,
6614
+ ...scope !== void 0 ? { scope } : {},
6615
+ operatorWrite
6616
+ });
6617
+ const effective = dropUnchangedKeys(result.patch, stored);
6618
+ const wroteBlob = Object.keys(effective).length > 0;
6619
+ if (wroteBlob) {
6620
+ await rawWrite(effective);
6621
+ index.wrote(store, effective);
6622
+ }
6623
+ const { orphaned } = await result.afterWrite();
6624
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6625
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6626
+ });
6627
+ };
6628
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6629
+ const readAddonStoreResult = raw.readAddonStoreResult;
6630
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6631
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6632
+ const overrides = {
6633
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6634
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6635
+ const result = await readAddonStoreResult.call(raw);
6636
+ return result.kind === "value" ? {
6637
+ kind: "value",
6638
+ value: await resolveRead("addon", result.value)
6639
+ } : result;
6640
+ } } : {},
6641
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6642
+ const result = await readAddonStoreKeyResult.call(raw, key);
6643
+ if (result.kind !== "present") return result;
6644
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6645
+ unresolved: "keep-marker",
6646
+ ownedBy: opts.secrets.owner
6647
+ });
6648
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6649
+ return {
6650
+ kind: "present",
6651
+ value: value[key]
6652
+ };
6653
+ } } : {},
6654
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6655
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6656
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6657
+ const out = /* @__PURE__ */ new Map();
6658
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6659
+ return out;
6660
+ } } : {},
6661
+ writeAddonStore: async (patch) => {
6662
+ await writeAddon(patch);
6663
+ },
6664
+ writeDeviceStore: async (deviceId, patch) => {
6665
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6666
+ kind: "device",
6667
+ deviceId
6668
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6669
+ }
6670
+ };
6671
+ return {
6672
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6673
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6674
+ const value = Reflect.get(target, prop, receiver);
6675
+ return typeof value === "function" ? value.bind(target) : value;
6676
+ } }),
6677
+ raw: {
6678
+ readAddonStore: async () => {
6679
+ const blob = await raw.readAddonStore();
6680
+ index.seen("addon", blob);
6681
+ return blob;
6682
+ },
6683
+ readDeviceStore: async (deviceId) => {
6684
+ const blob = await raw.readDeviceStore(deviceId);
6685
+ index.seen(`device:${deviceId}`, blob);
6686
+ return blob;
6687
+ }
6688
+ },
6689
+ writeAddonStore: writeAddon
6690
+ };
6691
+ }
6692
+ /** The context the addon sees, plus the private raw view and write outcome. */
6693
+ function createSecretAwareContext(context, opts) {
6694
+ const raw = context.settings;
6695
+ if (raw === void 0) return {
6696
+ context,
6697
+ handle: null
6698
+ };
6699
+ const handle = createHandle(raw, opts);
6700
+ return {
6701
+ context: new Proxy(context, { get(target, prop, receiver) {
6702
+ if (prop === "settings") return handle.settings;
6703
+ return Reflect.get(target, prop, receiver);
6704
+ } }),
6705
+ handle
6706
+ };
6707
+ }
6708
+ var LEAF = { kind: "leaf" };
6709
+ var DEFAULT_ITEM_ID_KEY = "id";
6710
+ function collectFields(fields, out) {
6711
+ for (const field of fields) {
6712
+ if (field.type === "group") {
6713
+ collectFields(field.fields, out);
6714
+ continue;
6715
+ }
6716
+ if (field.type === "sub-tabs") {
6717
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6718
+ continue;
6719
+ }
6720
+ if (field.type === "editable-array") {
6721
+ const item = /* @__PURE__ */ new Map();
6722
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6723
+ if (item.size > 0) out.set(field.key, {
6724
+ kind: "array",
6725
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6726
+ item
6727
+ });
6728
+ continue;
6729
+ }
6730
+ if (!("key" in field) || typeof field.key !== "string") continue;
6731
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6732
+ }
6733
+ }
6734
+ /** The secret tree a settings schema declares. */
6735
+ function secretTreeFromSchema(schema) {
6736
+ const out = /* @__PURE__ */ new Map();
6737
+ if (schema === null) return out;
6738
+ for (const section of schema.sections) collectFields(section.fields, out);
6739
+ return out;
6740
+ }
6741
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6742
+ function parseSecretStatePath(path) {
6743
+ const segments = [];
6744
+ for (const raw of path.split(".")) {
6745
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6746
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6747
+ segments.push(m[2] !== void 0 ? {
6748
+ key: m[1],
6749
+ idKey: m[2]
6750
+ } : { key: m[1] });
6751
+ }
6752
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6753
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6754
+ return segments;
6755
+ }
6756
+ function insert(into, segments) {
6757
+ const [head, ...rest] = segments;
6758
+ if (head === void 0) return;
6759
+ if (rest.length === 0) {
6760
+ into.set(head.key, LEAF);
6761
+ return;
6762
+ }
6763
+ const existing = into.get(head.key);
6764
+ if (head.idKey !== void 0) {
6765
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6766
+ insert(item, rest);
6767
+ into.set(head.key, {
6768
+ kind: "array",
6769
+ idKey: head.idKey,
6770
+ item
6771
+ });
6772
+ return;
6773
+ }
6774
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6775
+ insert(children, rest);
6776
+ into.set(head.key, {
6777
+ kind: "object",
6778
+ children
6779
+ });
6780
+ }
6781
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6782
+ function mergeSecretStatePaths(tree, paths) {
6783
+ if (paths.length === 0) return tree;
6784
+ const out = new Map(tree);
6785
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6786
+ return out;
6787
+ }
6788
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6789
+ var SECRET_RETRY_FIRST_MS = 5e3;
6790
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6791
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6792
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5910
6793
  /**
5911
6794
  * Base class for CamStack addons. Eliminates settings boilerplate:
5912
6795
  *
@@ -5976,6 +6859,33 @@ var BaseAddon = class {
5976
6859
  settingsStoreReady = false;
5977
6860
  /** Default config values. Provided via constructor. */
5978
6861
  defaults;
6862
+ /**
6863
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6864
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6865
+ * Stored in the keychain exactly like a `password` field. Syntax:
6866
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6867
+ * (`key[<id field>]` addresses array items by id, never by index).
6868
+ */
6869
+ secretStatePaths = [];
6870
+ _addonSecretTree = null;
6871
+ _deviceSecretTree = null;
6872
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6873
+ _configSecretRefs = /* @__PURE__ */ new Set();
6874
+ _unresolvedSecrets = [];
6875
+ _secretRetryTimer = null;
6876
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6877
+ _secretChangeTimer = null;
6878
+ _secretChangeUnsub = null;
6879
+ /** >0 while an OPERATOR's settings write is being applied. */
6880
+ _operatorWriteDepth = 0;
6881
+ /**
6882
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6883
+ * to the marker-bearing blobs and stays private to this class: the form
6884
+ * hydrate and config resolution need markers, addon code never does.
6885
+ */
6886
+ _secretSettings = null;
6887
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6888
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
5979
6889
  constructor(defaults) {
5980
6890
  this.defaults = defaults;
5981
6891
  this._config = { ...defaults };
@@ -6011,8 +6921,26 @@ var BaseAddon = class {
6011
6921
  return this._config;
6012
6922
  }
6013
6923
  async initialize(context) {
6014
- this._ctx = context;
6924
+ const secrets = context.secrets;
6925
+ if (secrets !== void 0) {
6926
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6927
+ secrets,
6928
+ addonTree: () => this.addonSecretTree(),
6929
+ deviceTree: () => this.deviceSecretTree(),
6930
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6931
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6932
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6933
+ });
6934
+ this._ctx = wrapped;
6935
+ this._secretSettings = handle;
6936
+ } else {
6937
+ this._ctx = context;
6938
+ this._secretSettings = null;
6939
+ }
6015
6940
  await this.resolveConfig();
6941
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6942
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6943
+ });
6016
6944
  const result = await this.onInitialize();
6017
6945
  this.emitLifecycle(EventCategory.AddonStarted);
6018
6946
  const normalized = normalizeAddonInitResult(result);
@@ -6045,6 +6973,12 @@ var BaseAddon = class {
6045
6973
  */
6046
6974
  async onHubReachable() {}
6047
6975
  async shutdown() {
6976
+ this._secretChangeUnsub?.();
6977
+ this._secretChangeUnsub = null;
6978
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
6979
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
6980
+ this._secretRetryTimer = null;
6981
+ this._secretChangeTimer = null;
6048
6982
  this.emitLifecycle(EventCategory.AddonStopped);
6049
6983
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6050
6984
  await this.onShutdown();
@@ -6119,11 +7053,8 @@ var BaseAddon = class {
6119
7053
  async getGlobalSettings(overlay, cap, nodeId) {
6120
7054
  const schema = this.globalSettingsSchema(cap);
6121
7055
  if (!schema) return { sections: [] };
6122
- const projected = await this.resolveGlobalStore(nodeId, cap);
6123
- return hydrateSchema(schema, overlay ? {
6124
- ...projected,
6125
- ...overlay
6126
- } : projected);
7056
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7057
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6127
7058
  }
6128
7059
  /**
6129
7060
  * The integration-level view of this addon's settings: exactly the sections
@@ -6168,11 +7099,11 @@ var BaseAddon = class {
6168
7099
  });
6169
7100
  }
6170
7101
  if (sections.length === 0) return null;
6171
- const projected = await this.resolveGlobalStore(nodeId);
7102
+ const projected = await this.readRawProjectedStore(nodeId);
6172
7103
  return hydrateSchema({
6173
7104
  ...schema,
6174
7105
  sections
6175
- }, projected);
7106
+ }, projected, { inlineSecretsAsViews: true });
6176
7107
  }
6177
7108
  /**
6178
7109
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6185,12 +7116,50 @@ var BaseAddon = class {
6185
7116
  * the store for custom option logic (option narrowing, value snapping) to
6186
7117
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6187
7118
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7119
+ *
7120
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7121
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7122
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7123
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7124
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7125
+ * resolved blob back is a no-op for every unchanged secret.
6188
7126
  */
6189
7127
  async resolveGlobalStore(nodeId, cap) {
6190
7128
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7129
+ return this.projectForNode(raw, nodeId, cap);
7130
+ }
7131
+ projectForNode(store, nodeId, cap) {
6191
7132
  const keys = this.perNodeKeys(cap);
6192
7133
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6193
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7134
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7135
+ }
7136
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7137
+ async readRawProjectedStore(nodeId, cap) {
7138
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7139
+ return this.projectForNode(raw, nodeId, cap);
7140
+ }
7141
+ /**
7142
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7143
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7144
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7145
+ * its value.
7146
+ */
7147
+ async overlayKeepingMarkers(stored, overlay) {
7148
+ const secrets = this._ctx?.secrets;
7149
+ const merged = {
7150
+ ...stored,
7151
+ ...overlay
7152
+ };
7153
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7154
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7155
+ unresolved: "keep-marker",
7156
+ ownedBy: secrets.owner
7157
+ });
7158
+ for (const key of Object.keys(overlay)) {
7159
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7160
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7161
+ }
7162
+ return merged;
6194
7163
  }
6195
7164
  /**
6196
7165
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6226,18 +7195,58 @@ var BaseAddon = class {
6226
7195
  value: result.value[key]
6227
7196
  };
6228
7197
  }
7198
+ /**
7199
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7200
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7201
+ * the operator sends is stored as sent even when it equals a pre-keychain
7202
+ * inline value: the operator re-entering a password is a change, an addon
7203
+ * writing back what it read is not (D787).
7204
+ */
7205
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7206
+ this._operatorWriteDepth++;
7207
+ try {
7208
+ await this.applyGlobalPatch(patch, nodeId);
7209
+ } finally {
7210
+ this._operatorWriteDepth--;
7211
+ }
7212
+ }
6229
7213
  async updateGlobalSettings(patch, nodeId) {
7214
+ await this.applyGlobalPatch(patch, nodeId);
7215
+ }
7216
+ /**
7217
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7218
+ *
7219
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7220
+ * what a defaults fallback writes back, and it must never destroy a
7221
+ * credential), so code that means "forget this token" says so here. Without
7222
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7223
+ */
7224
+ async clearSecrets(keys, nodeId) {
7225
+ const tree = this.addonSecretTree();
7226
+ const keychain = this._ctx?.secrets !== void 0;
7227
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7228
+ const patch = {};
7229
+ for (const key of keys) {
7230
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7231
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7232
+ }
7233
+ await this.applyGlobalPatch(patch, nodeId);
7234
+ }
7235
+ async applyGlobalPatch(barePatch, nodeId) {
6230
7236
  const keys = this.perNodeKeys();
6231
7237
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6232
7238
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6233
- const barePatch = patch;
6234
7239
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6235
- await this._ctx?.settings?.writeAddonStore(scoped);
7240
+ const handle = this._secretSettings;
7241
+ if (handle !== null) {
7242
+ const { changed } = await handle.writeAddonStore(scoped);
7243
+ if (!changed) return;
7244
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6236
7245
  if (target !== localNode) return;
6237
7246
  await this.resolveConfig();
6238
7247
  await this.onConfigChanged();
6239
7248
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6240
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7249
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6241
7250
  }
6242
7251
  /**
6243
7252
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6262,7 +7271,7 @@ var BaseAddon = class {
6262
7271
  * time to return its response before the addon is torn down and
6263
7272
  * re-initialised by `AddonRegistryService.restartAddon`.
6264
7273
  */
6265
- maybeAutoRestart(patch, schema) {
7274
+ maybeAutoRestart(patchKeys, schema) {
6266
7275
  if (!schema) return;
6267
7276
  const restartKeys = /* @__PURE__ */ new Set();
6268
7277
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6270,13 +7279,13 @@ var BaseAddon = class {
6270
7279
  if (field.requiresRestart) restartKeys.add(field.key);
6271
7280
  }
6272
7281
  if (restartKeys.size === 0) return;
6273
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7282
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6274
7283
  const ctx = this._ctx;
6275
7284
  if (!ctx) return;
6276
7285
  const addonId = ctx.id;
6277
7286
  setImmediate(() => {
6278
7287
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6279
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7288
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6280
7289
  }).catch((err) => {
6281
7290
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6282
7291
  });
@@ -6285,7 +7294,7 @@ var BaseAddon = class {
6285
7294
  async getDeviceSettings(deviceId) {
6286
7295
  const schema = this.deviceSettingsSchema();
6287
7296
  if (!schema) return { sections: [] };
6288
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7297
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6289
7298
  }
6290
7299
  async updateDeviceSettings(deviceId, patch) {
6291
7300
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6415,7 +7424,7 @@ var BaseAddon = class {
6415
7424
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6416
7425
  */
6417
7426
  async resolveConfig() {
6418
- const stored = await this.readAddonStoreWithRetry();
7427
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6419
7428
  const perNode = this.perNodeKeys();
6420
7429
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6421
7430
  const resolved = { ...this.defaults };
@@ -6440,7 +7449,7 @@ var BaseAddon = class {
6440
7449
  key,
6441
7450
  schema,
6442
7451
  fallback,
6443
- read: () => this.readAddonStoreWithRetry(),
7452
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6444
7453
  write: async (patch) => {
6445
7454
  await this._ctx?.settings?.writeAddonStore(patch);
6446
7455
  },
@@ -6457,7 +7466,7 @@ var BaseAddon = class {
6457
7466
  key,
6458
7467
  schema,
6459
7468
  fallback,
6460
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7469
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
6461
7470
  write: async (patch) => {
6462
7471
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6463
7472
  },
@@ -6469,6 +7478,87 @@ var BaseAddon = class {
6469
7478
  } })
6470
7479
  });
6471
7480
  }
7481
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7482
+ addonSecretTree() {
7483
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7484
+ return this._addonSecretTree;
7485
+ }
7486
+ deviceSecretTree() {
7487
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7488
+ return this._deviceSecretTree;
7489
+ }
7490
+ /**
7491
+ * Secrets of this addon's stored config that could not be resolved on the
7492
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7493
+ * an addon whose function needs one should report itself degraded rather
7494
+ * than start on an empty credential.
7495
+ */
7496
+ get unresolvedSecrets() {
7497
+ return this._unresolvedSecrets;
7498
+ }
7499
+ /**
7500
+ * Substitute every keychain marker in a stored blob with its value. With no
7501
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7502
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7503
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7504
+ * ever written back from here.
7505
+ */
7506
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7507
+ const secrets = this._ctx?.secrets;
7508
+ if (secrets === void 0) return blob;
7509
+ const refs = collectSecretMarkerRefs(blob);
7510
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7511
+ if (refs.length === 0) {
7512
+ if (trackForConfig) this._unresolvedSecrets = [];
7513
+ return blob;
7514
+ }
7515
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7516
+ if (trackForConfig) {
7517
+ this._unresolvedSecrets = unresolved;
7518
+ if (unresolved.length > 0) {
7519
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7520
+ ref: u.ref,
7521
+ reason: u.reason
7522
+ })) } });
7523
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7524
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7525
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7526
+ }
7527
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7528
+ }
7529
+ return value;
7530
+ }
7531
+ /**
7532
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7533
+ * keychain the context's own view is already raw.
7534
+ */
7535
+ rawSettings() {
7536
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7537
+ }
7538
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7539
+ logUnresolvedRead(unresolved) {
7540
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7541
+ if (fresh.length === 0) return;
7542
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7543
+ this._ctx?.logger?.warn?.("settings read: a stored secret is unavailable — it reads as its marker, not as a value", { meta: { secrets: fresh.map((u) => ({
7544
+ ref: u.ref,
7545
+ reason: u.reason
7546
+ })) } });
7547
+ }
7548
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7549
+ scheduleSecretReresolve(delayMs) {
7550
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7551
+ if (this[timerOf] !== null) return;
7552
+ const timer = setTimeout(() => {
7553
+ this[timerOf] = null;
7554
+ if (this._ctx === null) return;
7555
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7556
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7557
+ });
7558
+ }, delayMs);
7559
+ timer.unref?.();
7560
+ this[timerOf] = timer;
7561
+ }
6472
7562
  /**
6473
7563
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6474
7564
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -6481,7 +7571,7 @@ var BaseAddon = class {
6481
7571
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
6482
7572
  */
6483
7573
  async readAddonStoreWithRetry() {
6484
- const settings = this._ctx?.settings;
7574
+ const settings = this.rawSettings();
6485
7575
  if (!settings) return {};
6486
7576
  const delaysMs = [
6487
7577
  150,
@@ -8226,6 +9316,16 @@ var CompositionSchema = object({
8226
9316
  seen.add(feature.cap);
8227
9317
  });
8228
9318
  });
9319
+ var NodeColorIdSchema = _enum([
9320
+ "node-a",
9321
+ "node-b",
9322
+ "node-c",
9323
+ "node-d",
9324
+ "node-e",
9325
+ "node-f",
9326
+ "node-g",
9327
+ "node-h"
9328
+ ]);
8229
9329
  new Set([
8230
9330
  "track",
8231
9331
  "face",
@@ -8717,6 +9817,278 @@ var CameraSwitchGroupSchema = object({
8717
9817
  fetchedAt: number()
8718
9818
  });
8719
9819
  /**
9820
+ * The trainer contract — what the hub hands the cloud trainer and what it
9821
+ * gets back (cloud training, D805+).
9822
+ *
9823
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9824
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9825
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9826
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9827
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9828
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9829
+ * change there, in the same piece of work.
9830
+ *
9831
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9832
+ * orchestrator fills every field of a job spec explicitly.
9833
+ */
9834
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9835
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9836
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9837
+ var TrainingExportSchema = _enum([
9838
+ "onnx",
9839
+ "openvino-fp16",
9840
+ "openvino-int8",
9841
+ "coreml-fp16"
9842
+ ]);
9843
+ var FloorsSchema = record(string(), number().min(0).max(1));
9844
+ object({
9845
+ schema: literal(TRAINING_JOB_SCHEMA),
9846
+ jobKey: string().uuid(),
9847
+ target: object({
9848
+ kind: literal("detector"),
9849
+ step: literal("object-detection")
9850
+ }),
9851
+ base: object({
9852
+ modelId: string().min(1),
9853
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9854
+ weights: string().min(1),
9855
+ imgsz: number().int().positive()
9856
+ }),
9857
+ baseline: object({
9858
+ modelId: string().min(1),
9859
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9860
+ onnxUrl: string().url(),
9861
+ imgsz: number().int().positive(),
9862
+ floors: FloorsSchema
9863
+ }),
9864
+ dataset: object({
9865
+ versionId: string().min(1),
9866
+ annotationHash: string(),
9867
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9868
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9869
+ }),
9870
+ split: object({
9871
+ holdoutCameras: array(number().int()),
9872
+ /** When no camera is held out: the last N days of every camera. */
9873
+ holdoutLastDays: number().int().nonnegative(),
9874
+ valFraction: number().min(0).max(.5),
9875
+ seed: number().int()
9876
+ }),
9877
+ hyper: object({
9878
+ epochs: number().int().positive(),
9879
+ batch: number().int().positive(),
9880
+ lr0: number().positive(),
9881
+ /** Layers frozen from the start of the backbone; 0 = none. */
9882
+ freeze: number().int().nonnegative(),
9883
+ patience: number().int().nonnegative(),
9884
+ seed: number().int()
9885
+ }),
9886
+ replay: object({
9887
+ source: literal("coco2017"),
9888
+ count: number().int().nonnegative()
9889
+ }),
9890
+ exports: array(TrainingExportSchema).min(1),
9891
+ calibration: object({ maxFrames: number().int().positive() }),
9892
+ floors: object({
9893
+ minSupport: number().int().positive(),
9894
+ clamp: number().min(0).max(1)
9895
+ }),
9896
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9897
+ catalog: object({
9898
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9899
+ name: string().min(1).max(160)
9900
+ })
9901
+ });
9902
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9903
+ var TrainingResultFileSchema = object({
9904
+ path: string().min(1),
9905
+ bytes: number().int().nonnegative(),
9906
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9907
+ format: _enum([
9908
+ "onnx",
9909
+ "openvino",
9910
+ "coreml",
9911
+ "pt"
9912
+ ]),
9913
+ variant: _enum(["base", "int8"])
9914
+ });
9915
+ var DraftFormatSchema = object({
9916
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9917
+ url: string().min(1),
9918
+ sizeMB: number().nonnegative(),
9919
+ isDirectory: boolean().optional(),
9920
+ files: array(string()).optional(),
9921
+ runtimes: array(literal("python")).optional(),
9922
+ revision: string().min(1)
9923
+ });
9924
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9925
+ var TrainingCatalogDraftSchema = object({
9926
+ id: string().min(1),
9927
+ name: string().min(1),
9928
+ description: string(),
9929
+ labels: array(unknown()),
9930
+ inputSize: object({
9931
+ width: number().int().positive(),
9932
+ height: number().int().positive()
9933
+ }),
9934
+ preprocessMode: literal("letterbox"),
9935
+ defaultClassFloors: FloorsSchema,
9936
+ formats: object({
9937
+ onnx: DraftFormatSchema.optional(),
9938
+ openvino: DraftFormatSchema.optional(),
9939
+ coreml: DraftFormatSchema.optional()
9940
+ })
9941
+ });
9942
+ /** One class of one model's holdout report (the eval harness's summary). */
9943
+ var TrainingEvalClassSchema = object({
9944
+ positives: number().int(),
9945
+ floor: number().nullable(),
9946
+ tp: number().int(),
9947
+ fp: number().int(),
9948
+ fn: number().int(),
9949
+ precision: number().nullable(),
9950
+ recall: number().nullable(),
9951
+ ap50: number().nullable(),
9952
+ recallByCamera: record(string(), number().nullable()).optional(),
9953
+ recallByLight: record(string(), number().nullable()).optional(),
9954
+ fpByCamera: record(string(), number()).optional(),
9955
+ smallFound: number().int().optional(),
9956
+ smallTotal: number().int().optional()
9957
+ }).passthrough();
9958
+ var TrainingEvalReportSchema = object({
9959
+ frames: number().int(),
9960
+ classes: record(string(), TrainingEvalClassSchema)
9961
+ }).passthrough();
9962
+ /**
9963
+ * A succeeded result carries every block; a failed one carries the error and
9964
+ * whatever was known by then — the other blocks are ABSENT, not null. The
9965
+ * orchestrator checks the blocks it needs before it trusts a success.
9966
+ */
9967
+ var TrainingResultSchema = object({
9968
+ schema: literal(TRAINING_RESULT_SCHEMA),
9969
+ jobKey: string(),
9970
+ status: _enum(["succeeded", "failed"]),
9971
+ error: object({
9972
+ stage: string(),
9973
+ code: string(),
9974
+ message: string()
9975
+ }).nullable(),
9976
+ trainer: object({
9977
+ version: string(),
9978
+ revision: string()
9979
+ }),
9980
+ toolchain: record(string(), string().nullable()),
9981
+ dataset: object({
9982
+ versionId: string(),
9983
+ annotationHash: string(),
9984
+ sha256: string(),
9985
+ frames: object({
9986
+ train: number().int(),
9987
+ val: number().int(),
9988
+ holdout: number().int()
9989
+ }),
9990
+ holdoutCameras: array(number().int()),
9991
+ replayImages: number().int()
9992
+ }).optional(),
9993
+ training: object({
9994
+ epochsRun: number().int(),
9995
+ bestEpoch: number().int(),
9996
+ bestMap50: number(),
9997
+ bestMap50_95: number(),
9998
+ seconds: number()
9999
+ }).optional(),
10000
+ evaluation: object({
10001
+ holdoutFrames: number().int(),
10002
+ baseline: TrainingEvalReportSchema.nullable(),
10003
+ candidate: TrainingEvalReportSchema.nullable(),
10004
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10005
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10006
+ map50: record(string(), number().nullable())
10007
+ }).optional(),
10008
+ floors: object({
10009
+ baseline: FloorsSchema,
10010
+ candidate: FloorsSchema,
10011
+ candidateInt8: FloorsSchema.nullable(),
10012
+ notes: array(string())
10013
+ }).optional(),
10014
+ int8: object({
10015
+ kept: boolean(),
10016
+ map50Fp16: number().nullable(),
10017
+ map50Int8: number().nullable(),
10018
+ reason: string().nullable()
10019
+ }).optional(),
10020
+ exportsDropped: array(object({
10021
+ export: string(),
10022
+ reason: string()
10023
+ })).optional(),
10024
+ files: array(TrainingResultFileSchema).optional(),
10025
+ bundle: object({
10026
+ path: literal("bundle.tar"),
10027
+ bytes: number().int().nonnegative(),
10028
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10029
+ }).nullable().optional(),
10030
+ catalogDraft: object({
10031
+ base: TrainingCatalogDraftSchema,
10032
+ int8: TrainingCatalogDraftSchema.nullable()
10033
+ }).nullable().optional(),
10034
+ licence: string()
10035
+ });
10036
+ var TrainingStageSchema = _enum([
10037
+ "prepare",
10038
+ "replay",
10039
+ "train",
10040
+ "eval",
10041
+ "export",
10042
+ "package"
10043
+ ]);
10044
+ var EventBase = {
10045
+ v: literal(1),
10046
+ ts: number()
10047
+ };
10048
+ discriminatedUnion("type", [
10049
+ object({
10050
+ ...EventBase,
10051
+ type: literal("stage"),
10052
+ stage: TrainingStageSchema
10053
+ }),
10054
+ object({
10055
+ ...EventBase,
10056
+ type: literal("epoch"),
10057
+ epoch: number().int(),
10058
+ epochs: number().int(),
10059
+ boxLoss: number().nullable().optional(),
10060
+ map50: number().nullable().optional(),
10061
+ map50_95: number().nullable().optional(),
10062
+ etaSec: number().nullable().optional()
10063
+ }),
10064
+ object({
10065
+ ...EventBase,
10066
+ type: literal("metric"),
10067
+ name: string(),
10068
+ value: number()
10069
+ }),
10070
+ object({
10071
+ ...EventBase,
10072
+ type: literal("artifact"),
10073
+ path: string(),
10074
+ bytes: number(),
10075
+ sha256: string()
10076
+ }),
10077
+ object({
10078
+ ...EventBase,
10079
+ type: literal("done"),
10080
+ status: _enum(["succeeded", "failed"]),
10081
+ resultSha256: string().nullable().optional()
10082
+ }),
10083
+ object({
10084
+ ...EventBase,
10085
+ type: literal("error"),
10086
+ stage: string(),
10087
+ code: string(),
10088
+ message: string()
10089
+ })
10090
+ ]);
10091
+ /**
8720
10092
  * What the gate decided about a birth, from the CALLER's point of view.
8721
10093
  *
8722
10094
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11044,7 +12416,9 @@ var AddonHttpRouteSchema = object({
11044
12416
  "authenticated",
11045
12417
  "admin"
11046
12418
  ]).optional(),
11047
- description: string().optional()
12419
+ description: string().optional(),
12420
+ /** The hub limits this route per client address before the handler runs. */
12421
+ rateLimit: _enum(["auth"]).optional()
11048
12422
  });
11049
12423
  /**
11050
12424
  * Cross-process route invocation envelope. The hub captures the
@@ -11786,6 +13160,37 @@ var BackupDestinationInfoSchema = object({
11786
13160
  lastError: string().optional()
11787
13161
  });
11788
13162
  /**
13163
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13164
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13165
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13166
+ * with it off — which restores without a key.
13167
+ */
13168
+ var BackupArchiveEncryptionSchema = object({
13169
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13170
+ scheme: string(),
13171
+ /** 16 hex — the backup key whose secret restores this archive. */
13172
+ keyId: string()
13173
+ });
13174
+ /**
13175
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13176
+ * one new archives are encrypted to, and the retired ones older archives
13177
+ * still need. The secret key is shown once, at `setupEncryption`.
13178
+ */
13179
+ var BackupEncryptionStatusSchema = object({
13180
+ enabled: boolean(),
13181
+ active: object({
13182
+ keyId: string(),
13183
+ publicKey: string(),
13184
+ createdAt: number()
13185
+ }).nullable(),
13186
+ /** Every key ever set up, newest first. */
13187
+ keys: array(object({
13188
+ keyId: string(),
13189
+ createdAt: number(),
13190
+ retiredAt: number().nullable()
13191
+ })).readonly()
13192
+ });
13193
+ /**
11789
13194
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
11790
13195
  * Same shape the destination drill-in renders. Sourced from the per-
11791
13196
  * location `manifests.json` (no per-archive tarball read required).
@@ -11797,7 +13202,9 @@ var BackupArchiveEntrySchema = object({
11797
13202
  sizeBytes: number(),
11798
13203
  label: string().optional(),
11799
13204
  /** Top-level locations included in the archive (db, addons, tls, …). */
11800
- locations: array(string()).readonly()
13205
+ locations: array(string()).readonly(),
13206
+ /** Present when the archive is encrypted; restore then needs that key. */
13207
+ encryption: BackupArchiveEncryptionSchema.optional()
11801
13208
  });
11802
13209
  var BackupEntrySchema = object({
11803
13210
  id: string(),
@@ -11806,7 +13213,8 @@ var BackupEntrySchema = object({
11806
13213
  label: string().optional(),
11807
13214
  createdAt: number(),
11808
13215
  sizeBytes: number(),
11809
- locations: array(string()).optional()
13216
+ locations: array(string()).optional(),
13217
+ encryption: BackupArchiveEncryptionSchema.optional()
11810
13218
  });
11811
13219
  var ArchiveEntrySchema = object({
11812
13220
  path: string(),
@@ -11995,10 +13403,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
11995
13403
  * this list and skips entries whose path doesn't start with
11996
13404
  * any of them.
11997
13405
  */
11998
- locations: array(string()).optional()
13406
+ locations: array(string()).optional(),
13407
+ /**
13408
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13409
+ * one). The archive is decrypted into the hub's private staging
13410
+ * before the restart; the key is not stored. A wrong or missing key
13411
+ * is refused before the archive is downloaded.
13412
+ */
13413
+ backupSecretKey: string().optional()
11999
13414
  }), _void(), {
12000
13415
  kind: "mutation",
12001
13416
  auth: "admin"
13417
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13418
+ keyId: string(),
13419
+ secretKey: string(),
13420
+ publicKey: string(),
13421
+ createdAt: number(),
13422
+ replacedKeyId: string().nullable()
13423
+ }), {
13424
+ kind: "mutation",
13425
+ auth: "admin"
13426
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13427
+ kind: "mutation",
13428
+ auth: "admin"
13429
+ }), method(object({ backupSecretKey: string() }), object({
13430
+ valid: boolean(),
13431
+ keyId: string().nullable(),
13432
+ /** The hub knows this key (active or retired). */
13433
+ known: boolean(),
13434
+ /** It is the key new archives are encrypted to. */
13435
+ active: boolean(),
13436
+ error: string().optional()
13437
+ }), {
13438
+ kind: "mutation",
13439
+ auth: "admin"
12002
13440
  }), method(object({
12003
13441
  destinationId: string(),
12004
13442
  backupId: string()
@@ -13622,7 +15060,60 @@ var CustomModelDescriptorSchema = object({
13622
15060
  stepId: string(),
13623
15061
  entry: ModelCatalogEntrySchema
13624
15062
  });
13625
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15063
+ /** One regular file of an imported bundle, as the producer measured it. */
15064
+ var ModelBundleFileSchema = object({
15065
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15066
+ path: string().min(1),
15067
+ bytes: number().int().nonnegative(),
15068
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15069
+ });
15070
+ var ImportModelBundleInputSchema = object({
15071
+ /** The registry provider that keeps the model (Model Studio). */
15072
+ addonId: string(),
15073
+ stepId: string().min(1),
15074
+ /**
15075
+ * The catalog rows to register, complete, every format URL already
15076
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15077
+ * bundle may carry several rows (a base and its INT8 variant).
15078
+ */
15079
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15080
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15081
+ bundle: object({
15082
+ ticket: PeerBytesTicketSchema,
15083
+ bytes: number().int().positive(),
15084
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15085
+ }),
15086
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15087
+ files: array(ModelBundleFileSchema).min(1).max(64),
15088
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15089
+ distribute: boolean()
15090
+ });
15091
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15092
+ kind: literal("imported"),
15093
+ modelIds: array(string()).readonly(),
15094
+ distributed: array(object({
15095
+ modelId: string(),
15096
+ nodeId: string(),
15097
+ format: _enum(MODEL_FORMATS),
15098
+ ok: boolean(),
15099
+ error: string().optional()
15100
+ })).readonly()
15101
+ }), object({
15102
+ kind: literal("refused"),
15103
+ reason: _enum([
15104
+ "transfer-failed",
15105
+ "checksum-mismatch",
15106
+ "bundle-mismatch",
15107
+ "invalid-entry",
15108
+ "id-taken"
15109
+ ]),
15110
+ detail: string()
15111
+ })]);
15112
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15113
+ kind: "mutation",
15114
+ auth: "admin",
15115
+ timeoutMs: 30 * 6e4
15116
+ });
13626
15117
  /**
13627
15118
  * Query filter for settings-store collections.
13628
15119
  */
@@ -14006,6 +15497,253 @@ id: union([string(), number()]) }), {
14006
15497
  auth: "admin"
14007
15498
  });
14008
15499
  /**
15500
+ * `keychain` — the hub's encrypted store of secret values (D787).
15501
+ *
15502
+ * Settings blobs never hold a secret: they hold a marker
15503
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15504
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15505
+ * is the OWNER's door to its own values: every method is owner-checked
15506
+ * against the CALLER, never against anything the caller claims.
15507
+ *
15508
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15509
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15510
+ * connection, the agent from its child's connection carried in
15511
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15512
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15513
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15514
+ * identity against BUGS and misrouting, not against a malicious addon (every
15515
+ * runner is the same OS user): see the threat model in
15516
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15517
+ *
15518
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15519
+ * parses the input, so a session can never supply it, and the internal mount
15520
+ * floors every method to admin anyway (D240).
15521
+ *
15522
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15523
+ */
15524
+ /** Why a value cannot be served right now. Never folded into "missing". */
15525
+ var KeychainUnavailableReasonSchema = _enum([
15526
+ "key-missing",
15527
+ "wrong-key",
15528
+ "key-file-unreadable",
15529
+ "store-unavailable",
15530
+ "not-initialized",
15531
+ "decrypt-failed"
15532
+ ]);
15533
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15534
+ state: literal("locked"),
15535
+ reason: KeychainUnavailableReasonSchema
15536
+ })]);
15537
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15538
+ object({
15539
+ kind: literal("value"),
15540
+ value: string(),
15541
+ version: number().int()
15542
+ }),
15543
+ object({ kind: literal("missing") }),
15544
+ object({
15545
+ kind: literal("unavailable"),
15546
+ reason: KeychainUnavailableReasonSchema
15547
+ }),
15548
+ object({ kind: literal("forbidden") })
15549
+ ]);
15550
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15551
+ /** Metadata of one stored value — never the value. */
15552
+ var KeychainSecretMetaSchema = object({
15553
+ ref: string(),
15554
+ owner: string(),
15555
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15556
+ scope: string(),
15557
+ fieldPath: string(),
15558
+ version: number().int(),
15559
+ createdAt: number(),
15560
+ updatedAt: number(),
15561
+ /** `addon:<id>` | `user:<id>` | `system`. */
15562
+ updatedBy: string(),
15563
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15564
+ lastReadAt: number().nullable()
15565
+ });
15566
+ var RefListSchema = array(string().min(1)).max(512);
15567
+ method(object({
15568
+ ref: string().min(1),
15569
+ value: string().min(1)
15570
+ }), object({
15571
+ ref: string(),
15572
+ version: number().int()
15573
+ }), {
15574
+ kind: "mutation",
15575
+ auth: "admin"
15576
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15577
+ kind: "mutation",
15578
+ auth: "admin"
15579
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15580
+ var KeychainKeySourceSchema = object({
15581
+ kind: _enum([
15582
+ "config-file",
15583
+ "previous-config-file",
15584
+ "platform",
15585
+ "default-file"
15586
+ ]),
15587
+ /** File sources only — a path is not a secret. */
15588
+ path: string().optional(),
15589
+ /**
15590
+ * True when a whole-volume backup of the data directory carries this key
15591
+ * next to the database it protects (the default file). The page warns.
15592
+ */
15593
+ sharesBackupWithDatabase: boolean()
15594
+ });
15595
+ /**
15596
+ * One keychain reset, as the Secrets page reports it until the operator
15597
+ * acknowledges it. Never a value: refs, counts and table names only.
15598
+ */
15599
+ var KeychainResetRecordSchema = object({
15600
+ id: string(),
15601
+ at: number(),
15602
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15603
+ actor: string(),
15604
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15605
+ lockedReason: string().nullable(),
15606
+ /** Values moved into the archive table (ciphertext under the lost key). */
15607
+ archived: number().int(),
15608
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15609
+ archivedCollection: string().nullable(),
15610
+ /**
15611
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15612
+ * so the archive can still be opened if the lost master key turns up.
15613
+ */
15614
+ archivedKeysCollection: string().nullable(),
15615
+ /**
15616
+ * `system-settings` keys whose marker the reset cleared — the cluster
15617
+ * secret's: a marker left pointing at an archived value would refuse every
15618
+ * agent forever (D797).
15619
+ */
15620
+ clearedSettingsKeys: array(string()).readonly(),
15621
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15622
+ acknowledgedAt: number().nullable()
15623
+ });
15624
+ var KeychainStatusSchema = object({
15625
+ keychain: KeychainStateSchema,
15626
+ /** The source of the master key in use; `null` while locked. */
15627
+ keySource: KeychainKeySourceSchema.nullable(),
15628
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15629
+ configuredSource: KeychainKeySourceSchema,
15630
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15631
+ fingerprint: string().nullable(),
15632
+ activeKeyId: string().nullable(),
15633
+ /**
15634
+ * The keychain unlocked with a NON-primary source: the configured primary
15635
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15636
+ */
15637
+ rotationPending: boolean(),
15638
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15639
+ retiredWraps: number().int(),
15640
+ recoveryKeyDownloadedAt: number().nullable(),
15641
+ secretCount: number().int(),
15642
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15643
+ lastReset: KeychainResetRecordSchema.nullable()
15644
+ });
15645
+ /**
15646
+ * Whether a stored value is still pointed at by its owner's settings.
15647
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15648
+ * never reported as an orphan (and never deleted as one).
15649
+ */
15650
+ var KeychainSecretUsageSchema = _enum([
15651
+ "in-use",
15652
+ "orphan",
15653
+ "unknown"
15654
+ ]);
15655
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15656
+ var KeychainAuditActionSchema = _enum([
15657
+ "put",
15658
+ "delete",
15659
+ "reveal",
15660
+ "rotate-master-key",
15661
+ "purge-retired-keys",
15662
+ "download-recovery-key",
15663
+ "delete-orphans",
15664
+ "reset",
15665
+ "acknowledge-reset",
15666
+ "initialize"
15667
+ ]);
15668
+ var KeychainAuditEntrySchema = object({
15669
+ id: string(),
15670
+ at: number(),
15671
+ action: KeychainAuditActionSchema,
15672
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15673
+ actor: string(),
15674
+ ref: string().nullable(),
15675
+ detail: string().nullable()
15676
+ });
15677
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15678
+ /**
15679
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15680
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15681
+ * never an orphan; it is generated on a fresh hub and replaced only through
15682
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15683
+ */
15684
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15685
+ 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({
15686
+ value: string(),
15687
+ version: number().int()
15688
+ }), {
15689
+ kind: "mutation",
15690
+ auth: "admin",
15691
+ caller: "required"
15692
+ }), method(object({
15693
+ name: SystemHeldSecretNameSchema,
15694
+ value: string().min(16)
15695
+ }), object({
15696
+ ref: string(),
15697
+ version: number().int()
15698
+ }), {
15699
+ kind: "mutation",
15700
+ auth: "admin",
15701
+ caller: "required"
15702
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15703
+ deleted: array(string()).readonly(),
15704
+ kept: array(object({
15705
+ ref: string(),
15706
+ usage: KeychainSecretUsageSchema
15707
+ })).readonly()
15708
+ }), {
15709
+ kind: "mutation",
15710
+ auth: "admin",
15711
+ caller: "required"
15712
+ }), method(object({}), object({
15713
+ fingerprint: string(),
15714
+ keySource: KeychainKeySourceSchema
15715
+ }), {
15716
+ kind: "mutation",
15717
+ auth: "admin",
15718
+ caller: "required"
15719
+ }), method(object({}), object({ purged: number().int() }), {
15720
+ kind: "mutation",
15721
+ auth: "admin",
15722
+ caller: "required"
15723
+ }), method(object({}), object({
15724
+ key: string(),
15725
+ fingerprint: string(),
15726
+ keySource: KeychainKeySourceSchema
15727
+ }), {
15728
+ kind: "mutation",
15729
+ auth: "admin",
15730
+ caller: "required"
15731
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15732
+ archivedCollection: string().nullable(),
15733
+ archived: number().int()
15734
+ }), {
15735
+ kind: "mutation",
15736
+ auth: "admin",
15737
+ caller: "required"
15738
+ }), method(object({}), object({
15739
+ reset: KeychainResetRecordSchema.nullable(),
15740
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15741
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15742
+ kind: "mutation",
15743
+ auth: "admin",
15744
+ caller: "required"
15745
+ });
15746
+ /**
14009
15747
  * Stable UI option list for the `hwaccel` setting. Decoder addons
14010
15748
  * reuse this for `globalSettingsSchema()` so the dropdown is
14011
15749
  * identical everywhere. Order: auto → off → common backends by
@@ -14903,6 +16641,10 @@ var DeviceInfoSchema = object({
14903
16641
  isCamera: boolean(),
14904
16642
  /** Current config values — serializable snapshot */
14905
16643
  config: record(string(), unknown()),
16644
+ /** Paths inside `config` the device's schema declares secret (D783) —
16645
+ * what the non-admin redaction withholds. Paths, never values. Absent
16646
+ * when the owning runner has not reported them. */
16647
+ secretConfigPaths: array(string()).optional(),
14906
16648
  /** Hardware + identity blob (manufacturer / model / firmware / sn /
14907
16649
  * uid / mac / …). Populated by drivers; editable via setMetadata. */
14908
16650
  metadata: record(string(), unknown()).nullable().optional(),
@@ -15108,12 +16850,22 @@ var DeviceRegisterPayloadSchema = object({
15108
16850
  * call (workers re-register on init), so probe-driven updates
15109
16851
  * (e.g. PTZ flag flipping after the abilities probe) propagate. */
15110
16852
  features: array(string()).optional(),
15111
- config: record(string(), unknown())
16853
+ config: record(string(), unknown()),
16854
+ /** Config paths the device's own schema DECLARES secret
16855
+ * (`.meta({ secret: true })` — dotted, `[]` for array items, e.g.
16856
+ * `connection.password`). Re-published on every register; the non-admin
16857
+ * redaction withholds them at any depth (D783). Optional: an older runner
16858
+ * omits it and the keyword backstop applies. */
16859
+ secretConfigPaths: array(string()).optional()
15112
16860
  });
15113
16861
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15114
16862
  var DevicePersistConfigPayloadSchema = object({
15115
16863
  deviceId: number(),
15116
- data: record(string(), unknown())
16864
+ data: record(string(), unknown()),
16865
+ /** The paths the device's schema declares secret (D783), when the caller
16866
+ * knows them — those values are kept in the keychain, not the blob (D787).
16867
+ * Absent: the paths the device last reported at `registerDevice` apply. */
16868
+ secretConfigPaths: array(string()).optional()
15117
16869
  });
15118
16870
  /** What a migration actually did, per switch. `unreachable` is a first-class
15119
16871
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -16431,14 +18183,14 @@ var LlmProfileSchema = object({
16431
18183
  /** ConfigUISchema tree passed through untyped on the wire (the
16432
18184
  * notification-output `ConfigSchemaPassthrough` precedent at
16433
18185
  * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16434
- var ConfigSchemaPassthrough$1 = unknown();
18186
+ var ConfigSchemaPassthrough$3 = unknown();
16435
18187
  var LlmProfileKindDescriptorSchema = object({
16436
18188
  kind: LlmProfileKindSchema,
16437
18189
  label: string(),
16438
18190
  icon: string(),
16439
18191
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
16440
18192
  addonId: string(),
16441
- configSchema: ConfigSchemaPassthrough$1
18193
+ configSchema: ConfigSchemaPassthrough$3
16442
18194
  });
16443
18195
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16444
18196
  var LlmDefaultSchema = object({
@@ -16716,7 +18468,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16716
18468
  * `login-method` — collection cap through which auth addons contribute
16717
18469
  * their pre-auth login surfaces to the login page. This is the SINGLE,
16718
18470
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
16719
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18471
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
16720
18472
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16721
18473
  * procedure aggregates them for the unauthenticated login page.
16722
18474
  *
@@ -16724,8 +18476,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16724
18476
  *
16725
18477
  * - `redirect` — a declarative button. The login page renders a generic
16726
18478
  * button that navigates to `startUrl` (an addon-owned HTTP route).
16727
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16728
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18479
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
16729
18480
  * login page needs NO change.
16730
18481
  *
16731
18482
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -16744,8 +18495,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16744
18495
  * decision.
16745
18496
  *
16746
18497
  * Every contribution carries a `stage`:
16747
- * - `primary` — shown on the first credentials screen (OIDC /
16748
- * magic-link buttons; a future usernameless passkey).
18498
+ * - `primary` — shown on the first credentials screen (OIDC
18499
+ * buttons; a usernameless passkey).
16749
18500
  * - `second-factor` — shown AFTER the password leg, gated on the
16750
18501
  * returned `factors` (passkey-as-2FA today).
16751
18502
  *
@@ -16767,7 +18518,14 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16767
18518
  icon: string().optional(),
16768
18519
  /** Addon-owned HTTP route the button navigates to (GET). */
16769
18520
  startUrl: string(),
16770
- stage: LoginStageEnum
18521
+ stage: LoginStageEnum,
18522
+ /**
18523
+ * The provider names an external identity a signed-in user can link to
18524
+ * their own account (D782): `auth.listLinkableProviders` /
18525
+ * `beginExternalLink` offer exactly the redirect methods that set this,
18526
+ * whatever their id. Absent / false — a login button only.
18527
+ */
18528
+ linkable: boolean().optional()
16771
18529
  }),
16772
18530
  object({
16773
18531
  kind: literal("widget"),
@@ -17553,7 +19311,7 @@ var TargetKindCapsSchema = object({
17553
19311
  * the union is large and not meant for runtime validation here; the exported
17554
19312
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
17555
19313
  */
17556
- var ConfigSchemaPassthrough = unknown();
19314
+ var ConfigSchemaPassthrough$2 = unknown();
17557
19315
  var TargetKindSchema = object({
17558
19316
  kind: string(),
17559
19317
  label: string(),
@@ -17590,7 +19348,7 @@ var TargetKindSchema = object({
17590
19348
  * its raster path, which is the safe default for an unknown image.
17591
19349
  */
17592
19350
  iconMediaType: string().optional(),
17593
- configSchema: ConfigSchemaPassthrough,
19351
+ configSchema: ConfigSchemaPassthrough$2,
17594
19352
  /**
17595
19353
  * The config keys that decide WHERE this kind's secrets are sent (server,
17596
19354
  * base URL, instance, chat, recipient). A save that changes any of them
@@ -20582,8 +22340,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
20582
22340
  * `super_admin` — collapsed onto the single boolean because every
20583
22341
  * non-admin caller is governed by the same scope-check rules; the
20584
22342
  * distinction was only ever used to route role-specific procedures
20585
- * which we no longer have. Agents are admin sessions issued via
20586
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22343
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
20587
22344
  * with `isAdmin: false` + an explicit scope list.
20588
22345
  */
20589
22346
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -20890,6 +22647,61 @@ var OauthIntegrationDescriptorSchema = object({
20890
22647
  });
20891
22648
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
20892
22649
  /**
22650
+ * `oidc-connections` — CRUD for IdP rows under `auth-oidc` (D828 sibling).
22651
+ *
22652
+ * One hub-only singleton (`auth-oidc`). The Settings UI is a DataTable +
22653
+ * ItemFormDialog; there is no `editable-array` in `globalSettingsSchema`.
22654
+ * Operator-chosen `id` is the URL slug (`/addon/auth-oidc/<id>/…`) and is
22655
+ * immutable after create.
22656
+ */
22657
+ var ConfigSchemaPassthrough$1 = unknown();
22658
+ var OidcConnectionSchema = object({
22659
+ id: string().min(1),
22660
+ displayName: string(),
22661
+ icon: string(),
22662
+ issuerUrl: string(),
22663
+ clientId: string(),
22664
+ /** Client id + secret present — never the secret value. */
22665
+ configured: boolean(),
22666
+ /**
22667
+ * Values for the connection form schema. `clientSecret` is a keychain
22668
+ * {@link SecretFieldView} or `null` / `''`, never plaintext (D789).
22669
+ */
22670
+ formValues: record(string(), unknown()).optional()
22671
+ });
22672
+ /**
22673
+ * Patch one connection. Omitted or empty `clientSecret` keeps the stored
22674
+ * secret (D787). `{ $secretClear: true }` clears it. `id` is never renamed.
22675
+ */
22676
+ var OidcConnectionUpdateInputSchema = object({
22677
+ id: string().min(1),
22678
+ displayName: string().min(1),
22679
+ icon: string().optional(),
22680
+ issuerUrl: string().optional(),
22681
+ clientId: string().optional(),
22682
+ clientSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
22683
+ redirectUri: string().optional(),
22684
+ scopes: string().optional(),
22685
+ usernameClaim: _enum([
22686
+ "preferred_username",
22687
+ "email",
22688
+ "sub"
22689
+ ]).optional()
22690
+ });
22691
+ method(object({}), ConfigSchemaPassthrough$1, { auth: "admin" }), method(object({}), array(OidcConnectionSchema).readonly(), { auth: "admin" }), method(object({
22692
+ id: string().min(1).regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "id must be a lowercase slug"),
22693
+ displayName: string().min(1)
22694
+ }), object({ id: string() }), {
22695
+ kind: "mutation",
22696
+ auth: "admin"
22697
+ }), method(OidcConnectionUpdateInputSchema, object({ ok: literal(true) }), {
22698
+ kind: "mutation",
22699
+ auth: "admin"
22700
+ }), method(object({ id: string().min(1) }), object({ ok: literal(true) }), {
22701
+ kind: "mutation",
22702
+ auth: "admin"
22703
+ });
22704
+ /**
20893
22705
  * What started a camera's onboard motion (D672). `camera` is the camera's own
20894
22706
  * firmware; `sensor` is a device the operator ATTACHED to it. Absent on the
20895
22707
  * wire means the camera: only the camera-sensors bridge ever says `sensor`.
@@ -22085,8 +23897,23 @@ var RetrainMacroClassSchema = _enum([
22085
23897
  ]);
22086
23898
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22087
23899
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22088
- /** Did a human draw this box, or did the assist propose it? */
22089
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
23900
+ /**
23901
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
23902
+ * the operator confirms it; once saved it keeps its source as provenance.
23903
+ *
23904
+ * - `operator` — drawn by hand.
23905
+ * - `assist` — proposed by a detector run on the copy (the camera's own
23906
+ * model, or a larger teacher model).
23907
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
23908
+ * back from the track store (never a re-run).
23909
+ * - `llm` — proposed by a vision-capable LLM profile.
23910
+ */
23911
+ var RetrainAnnotationSourceSchema = _enum([
23912
+ "operator",
23913
+ "assist",
23914
+ "pipeline",
23915
+ "llm"
23916
+ ]);
22090
23917
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22091
23918
  var RetrainBboxSchema = object({
22092
23919
  x: number(),
@@ -22104,7 +23931,8 @@ var RetrainBboxSchema = object({
22104
23931
  */
22105
23932
  var RetrainAnnotationSchema = object({
22106
23933
  id: string(),
22107
- trackId: string(),
23934
+ /** The frame's track. Absent on a recording still, which has none. */
23935
+ trackId: string().optional(),
22108
23936
  deviceId: number(),
22109
23937
  /** The COPY in retrain storage — never the source track's media key. */
22110
23938
  mediaKey: string(),
@@ -22153,18 +23981,63 @@ var RetrainFrameCandidateSchema = object({
22153
23981
  * fail, whatever became of the original. */
22154
23982
  copied: boolean()
22155
23983
  });
23984
+ /**
23985
+ * One box the live pipeline drew on a copied frame — what a correction starts
23986
+ * from. Derived when the frame is listed, from the track store: the subject
23987
+ * box recorded on the source media row when there is one, else the track
23988
+ * position nearest the frame's capture time. Never stored as an annotation
23989
+ * until the operator confirms it.
23990
+ */
23991
+ var RetrainPipelineBoxSchema = object({
23992
+ /** Normalised `[0,1]` against the full frame. */
23993
+ bbox: RetrainBboxSchema,
23994
+ macroClass: RetrainMacroClassSchema,
23995
+ label: string().optional(),
23996
+ subLabel: string().optional(),
23997
+ /** The detection score of the position used, when it was recorded. */
23998
+ score: number().optional(),
23999
+ /** The root model that produced the track, when it was recorded. */
24000
+ modelId: string().optional(),
24001
+ trackId: string(),
24002
+ /** `subject-box`: recorded on this very frame. `position`: the track's
24003
+ * position nearest the capture time, `deltaMs` away. */
24004
+ basis: _enum(["subject-box", "position"]),
24005
+ deltaMs: number()
24006
+ });
24007
+ /**
24008
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
24009
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
24010
+ * track at all.
24011
+ */
24012
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22156
24013
  /** A frame the dataset OWNS: bytes copied at selection time. */
22157
24014
  var RetrainFrameSchema = object({
22158
24015
  frameId: string(),
22159
24016
  deviceId: number(),
22160
- trackId: string(),
22161
- /** Provenance only. It may already point at nothing — that is expected. */
22162
- sourceMediaId: number().int(),
24017
+ origin: RetrainFrameOriginSchema,
24018
+ /** The track it was copied from. Absent on a recording still. */
24019
+ trackId: string().optional(),
24020
+ /** Provenance only. It may already point at nothing — that is expected.
24021
+ * Absent on a recording still. */
24022
+ sourceMediaId: number().int().optional(),
24023
+ /** A recording still: the playhead instant it was taken at. */
24024
+ epochMs: number().optional(),
22163
24025
  sourceKind: MediaFileKindEnum,
22164
24026
  sizeBytes: number().int(),
22165
24027
  width: number().int(),
22166
24028
  height: number().int(),
22167
- copiedAt: number()
24029
+ copiedAt: number(),
24030
+ /** When the CAMERA captured the frame. Absent on a copy taken before D785. */
24031
+ capturedAt: number().optional(),
24032
+ /** The operator's "every subject in this frame is boxed". Detector
24033
+ * evaluation keeps only complete frames: an unboxed subject would count as
24034
+ * a false positive. */
24035
+ complete: boolean(),
24036
+ /** The boxes the pipeline drew on this frame. Present on list answers;
24037
+ * empty when nothing the track store holds can be placed on it. */
24038
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
24039
+ /** The named collections this frame belongs to. Present on list answers. */
24040
+ collectionIds: array(string()).readonly().optional()
22168
24041
  });
22169
24042
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22170
24043
  var RetrainCopyRefusalSchema = _enum([
@@ -22185,6 +24058,101 @@ var RetrainFrameListSchema = object({
22185
24058
  /** What the page pre-selects — the native key frame when one survives. */
22186
24059
  autoPickMediaId: number().int().optional()
22187
24060
  });
24061
+ /** Exclusive partition of a corpus copy's annotation progress (design §4.2). */
24062
+ var RetrainFrameWorkStateSchema = _enum([
24063
+ "unannotated",
24064
+ "annotated",
24065
+ "complete"
24066
+ ]);
24067
+ /**
24068
+ * Filters for paginated corpus list, KPI, and matching export (design §4.4).
24069
+ * Every narrowing field is ANDed; omitted fields impose no constraint.
24070
+ */
24071
+ var RetrainCorpusFilterSchema = object({
24072
+ workState: RetrainFrameWorkStateSchema.optional(),
24073
+ deviceIds: array(number()).max(500).optional(),
24074
+ /** When set, only frames in this named collection. */
24075
+ collectionId: string().optional(),
24076
+ /** Frames that carry at least one saved annotation in one of these classes. */
24077
+ classes: array(RetrainMacroClassSchema).optional(),
24078
+ page: number().int().positive().default(1),
24079
+ pageSize: number().int().positive().max(100).default(50)
24080
+ });
24081
+ var RetrainCorpusPageSchema = object({
24082
+ frames: array(RetrainFrameSchema.extend({ workState: RetrainFrameWorkStateSchema })).readonly(),
24083
+ total: number().int().nonnegative(),
24084
+ page: number().int().positive(),
24085
+ pageSize: number().int().positive()
24086
+ });
24087
+ var RetrainCorpusKpiCameraRowSchema = object({
24088
+ deviceId: number(),
24089
+ unannotated: number().int().nonnegative(),
24090
+ annotated: number().int().nonnegative(),
24091
+ complete: number().int().nonnegative(),
24092
+ /** This camera's `complete` count divided by corpus `total`, in `[0,1]`.
24093
+ * `null` when the corpus is empty (no ratio). */
24094
+ pctOfCorpus: number().min(0).max(1).nullable()
24095
+ });
24096
+ var RetrainCorpusKpiSchema = object({
24097
+ total: number().int().nonnegative(),
24098
+ unannotated: number().int().nonnegative(),
24099
+ annotated: number().int().nonnegative(),
24100
+ complete: number().int().nonnegative(),
24101
+ cameras: array(RetrainCorpusKpiCameraRowSchema).readonly()
24102
+ });
24103
+ /**
24104
+ * Which frames an annotated export carries. Every field narrows; an empty
24105
+ * filter is every annotated copy. `frameIds` is the primitive a job or
24106
+ * download uses; `batchId` re-selects what an earlier export carried
24107
+ * (`exportedInBatch`). Frozen dataset versions were removed — live selection
24108
+ * resolves to `frameIds` at plan/start.
24109
+ */
24110
+ var RetrainExportFilterSchema = object({
24111
+ deviceIds: array(number()).optional(),
24112
+ frameIds: array(string()).max(2e4).optional(),
24113
+ /** Only frames in at least one of these named collections. */
24114
+ collectionIds: array(string()).max(200).optional(),
24115
+ /** Single collection (Frames filter bar). ANDed with `collectionIds` when both set. */
24116
+ collectionId: string().optional(),
24117
+ batchId: string().optional(),
24118
+ /** Only frames the operator marked complete (all subjects boxed). */
24119
+ completeOnly: boolean().optional(),
24120
+ /** Exclusive work-state partition (`workStateOf`); same as the corpus list. */
24121
+ workState: RetrainFrameWorkStateSchema.optional(),
24122
+ /** Frames with at least one saved annotation in one of these classes. */
24123
+ classes: array(RetrainMacroClassSchema).optional()
24124
+ });
24125
+ /**
24126
+ * `frames`: the full frame copies, boxes in `annotations.json`.
24127
+ * `crops`: additionally one JPEG per subject, cut with the runtime detail-crop
24128
+ * convention — the classifier layout.
24129
+ */
24130
+ var RetrainExportLayoutSchema = _enum(["frames", "crops"]);
24131
+ /**
24132
+ * Where `writeRetrainArchive` streams the tar: one HTTP request whose body is
24133
+ * the archive, sent chunk by chunk. Covers a presigned PUT and a provider
24134
+ * addon's data-plane upload route alike. Headers are sent verbatim and never
24135
+ * logged.
24136
+ */
24137
+ var RetrainArchiveTargetSchema = object({
24138
+ kind: literal("http"),
24139
+ method: _enum(["PUT", "POST"]),
24140
+ url: string().url(),
24141
+ headers: record(string(), string()).optional()
24142
+ });
24143
+ var RetrainArchiveResultSchema = object({
24144
+ batchId: string(),
24145
+ frames: number().int(),
24146
+ crops: number().int(),
24147
+ annotations: number().int(),
24148
+ /** Frames planned but not shipped (unreadable copy, path too long). */
24149
+ missing: number().int(),
24150
+ bytes: number().int(),
24151
+ /** sha256 of the exact bytes sent. */
24152
+ sha256: string(),
24153
+ /** The target's HTTP status. */
24154
+ status: number().int()
24155
+ });
22188
24156
  /** What the operator asked the assist to look for. */
22189
24157
  var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
22190
24158
  kind: literal("package"),
@@ -22214,6 +24182,180 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22214
24182
  reason: string(),
22215
24183
  detail: string().optional()
22216
24184
  })]);
24185
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24186
+ var RetrainCollectionSchema = object({
24187
+ id: string(),
24188
+ name: string(),
24189
+ createdAt: number(),
24190
+ frameCount: number().int()
24191
+ });
24192
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24193
+ kind: literal("created"),
24194
+ collection: RetrainCollectionSchema
24195
+ }), object({
24196
+ kind: literal("refused"),
24197
+ reason: _enum(["empty-name", "duplicate-name"])
24198
+ })]);
24199
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24200
+ kind: literal("renamed"),
24201
+ collection: RetrainCollectionSchema
24202
+ }), object({
24203
+ kind: literal("refused"),
24204
+ reason: _enum([
24205
+ "empty-name",
24206
+ "duplicate-name",
24207
+ "unknown-collection"
24208
+ ])
24209
+ })]);
24210
+ /**
24211
+ * The outcome of adding the frame at a recording instant. Every refusal is
24212
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24213
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24214
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24215
+ */
24216
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24217
+ kind: literal("added"),
24218
+ collectionId: string(),
24219
+ frame: RetrainFrameSchema,
24220
+ /** The moment was already in the dataset; nothing was decoded. */
24221
+ reused: boolean()
24222
+ }), object({
24223
+ kind: literal("refused"),
24224
+ reason: _enum([
24225
+ "unknown-collection",
24226
+ "still-unavailable",
24227
+ "still-busy",
24228
+ "unreadable-image",
24229
+ "write-failed"
24230
+ ]),
24231
+ detail: string().optional()
24232
+ })]);
24233
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24234
+ var RetrainAssistProfileSchema = object({
24235
+ id: string(),
24236
+ name: string(),
24237
+ model: string(),
24238
+ kind: string(),
24239
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24240
+ * endpoint that is not on the local network). The page confirms each such
24241
+ * run, and the provider refuses one without `allowCloud`. */
24242
+ leavesHouse: boolean()
24243
+ });
24244
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24245
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24246
+ /** What the AI assist said about a box that was already on the canvas. */
24247
+ var RetrainLlmReviewSchema = object({
24248
+ /** The `ref` the page sent the box under. */
24249
+ ref: string(),
24250
+ verdict: _enum([
24251
+ "confirmed",
24252
+ "wrong-class",
24253
+ "not-an-object",
24254
+ "uncertain"
24255
+ ]),
24256
+ suggestedClass: RetrainMacroClassSchema.optional(),
24257
+ reason: string()
24258
+ });
24259
+ /**
24260
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24261
+ * model and its confidence) and reviews; items the model got wrong (a box off
24262
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24263
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24264
+ */
24265
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24266
+ kind: literal("proposed"),
24267
+ profileId: string(),
24268
+ model: string(),
24269
+ /** The frame was sent outside the house for this answer. */
24270
+ leftHouse: boolean(),
24271
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24272
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24273
+ rejected: number().int()
24274
+ }), object({
24275
+ kind: literal("refused"),
24276
+ reason: _enum([
24277
+ "unknown-frame",
24278
+ "unreadable-frame",
24279
+ "unknown-profile",
24280
+ "profile-disabled",
24281
+ "no-vision",
24282
+ "cloud-not-confirmed",
24283
+ "llm-error",
24284
+ "malformed-answer"
24285
+ ]),
24286
+ detail: string().optional()
24287
+ })]);
24288
+ /** What a dataset version is cut from. Every field narrows. */
24289
+ var RetrainDatasetSelectionSchema = object({
24290
+ deviceIds: array(number()).readonly().optional(),
24291
+ collectionIds: array(string()).max(200).readonly().optional(),
24292
+ frameIds: array(string()).max(2e4).readonly().optional()
24293
+ });
24294
+ /** The counts a dataset is judged by. */
24295
+ var RetrainDatasetStatsSchema = object({
24296
+ frames: number().int(),
24297
+ completeFrames: number().int(),
24298
+ /** `completeFrames / frames`, 0..1. */
24299
+ completeness: number(),
24300
+ /** Boxes to learn (model errors excluded). */
24301
+ subjects: number().int(),
24302
+ modelErrors: number().int(),
24303
+ /** Complete frames with no subject. */
24304
+ hardNegatives: number().int(),
24305
+ /** Subjects per class × camera × day/night. */
24306
+ cells: array(object({
24307
+ macroClass: string(),
24308
+ deviceId: number(),
24309
+ lighting: _enum([
24310
+ "day",
24311
+ "night",
24312
+ "unknown"
24313
+ ]),
24314
+ subjects: number().int(),
24315
+ frames: number().int()
24316
+ })).readonly(),
24317
+ cameras: array(object({
24318
+ deviceId: number(),
24319
+ frames: number().int(),
24320
+ completeFrames: number().int()
24321
+ })).readonly()
24322
+ });
24323
+ object({
24324
+ id: string(),
24325
+ name: string(),
24326
+ createdAt: number(),
24327
+ selection: RetrainDatasetSelectionSchema,
24328
+ layout: RetrainExportLayoutSchema,
24329
+ completeOnly: boolean(),
24330
+ frameCount: number().int(),
24331
+ annotationHash: string(),
24332
+ manifestSchema: string(),
24333
+ stats: RetrainDatasetStatsSchema
24334
+ });
24335
+ /**
24336
+ * Live training corpus criteria — same shape as `TrainingCorpusSelection` on
24337
+ * the training cap. Resolved here so plan/start and the annotated export share
24338
+ * one definition of "the frames" (`buildRetrainExportPlan`).
24339
+ */
24340
+ var RetrainTrainingCorpusSelectionSchema = object({
24341
+ collectionIds: array(string()).min(1),
24342
+ workState: _enum([
24343
+ "complete",
24344
+ "annotated_or_complete",
24345
+ "any_annotated"
24346
+ ]).default("complete")
24347
+ });
24348
+ var RetrainTrainingCorpusResolveResultSchema = discriminatedUnion("kind", [object({
24349
+ kind: literal("resolved"),
24350
+ frameIds: array(string()).max(2e4).readonly(),
24351
+ stats: RetrainDatasetStatsSchema,
24352
+ annotationHash: string(),
24353
+ layout: RetrainExportLayoutSchema
24354
+ }), object({
24355
+ kind: literal("refused"),
24356
+ reason: _enum(["unknown-collection", "no-frames"]),
24357
+ detail: string()
24358
+ })]);
22217
24359
  /** The outcome of a lifecycle move owned by the retrain page. */
22218
24360
  var RetrainTransitionResultSchema = object({
22219
24361
  trackId: string(),
@@ -22919,6 +25061,12 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22919
25061
  }), array(RetrainTrackSchema).readonly(), {
22920
25062
  kind: "query",
22921
25063
  auth: "admin"
25064
+ }), method(RetrainCorpusFilterSchema, RetrainCorpusPageSchema, {
25065
+ kind: "query",
25066
+ auth: "admin"
25067
+ }), method(object({}), RetrainCorpusKpiSchema, {
25068
+ kind: "query",
25069
+ auth: "admin"
22922
25070
  }), method(object({ trackId: string() }), RetrainFrameListSchema, {
22923
25071
  kind: "query",
22924
25072
  auth: "admin"
@@ -22931,7 +25079,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22931
25079
  auth: "admin"
22932
25080
  }), method(object({
22933
25081
  deviceId: number(),
22934
- trackId: string(),
25082
+ trackId: string().optional(),
22935
25083
  frameId: string()
22936
25084
  }), object({
22937
25085
  removed: boolean(),
@@ -22948,7 +25096,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22948
25096
  auth: "admin"
22949
25097
  }), method(object({
22950
25098
  deviceId: number(),
22951
- trackId: string(),
25099
+ /** The frame's track, when it has one — checked against the frame. */
25100
+ trackId: string().optional(),
22952
25101
  frameId: string(),
22953
25102
  subject: RetrainAssistSubjectSchema,
22954
25103
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -22956,12 +25105,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22956
25105
  }), RetrainAssistResultSchema, {
22957
25106
  kind: "mutation",
22958
25107
  auth: "admin"
22959
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25108
+ }), method(object({
25109
+ trackId: string().optional(),
25110
+ frameIds: array(string()).max(2e3).optional()
25111
+ }), array(RetrainAnnotationSchema).readonly(), {
22960
25112
  kind: "query",
22961
25113
  auth: "admin"
22962
25114
  }), method(object({
22963
25115
  deviceId: number(),
22964
- trackId: string(),
25116
+ /** The frame's track, when it has one — checked against the frame. */
25117
+ trackId: string().optional(),
22965
25118
  frameId: string(),
22966
25119
  annotations: array(RetrainAnnotationDraftSchema)
22967
25120
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -22979,7 +25132,106 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22979
25132
  }), RetrainTransitionResultSchema, {
22980
25133
  kind: "mutation",
22981
25134
  auth: "admin"
22982
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
25135
+ }), method(RetrainExportFilterSchema.extend({ layout: RetrainExportLayoutSchema.optional() }), object({ url: string() }), {
25136
+ kind: "query",
25137
+ auth: "admin"
25138
+ }), method(object({
25139
+ deviceId: number(),
25140
+ trackId: string().optional(),
25141
+ frameId: string(),
25142
+ complete: boolean()
25143
+ }), RetrainFrameSchema, {
25144
+ kind: "mutation",
25145
+ auth: "admin"
25146
+ }), method(object({
25147
+ filter: RetrainExportFilterSchema,
25148
+ layout: RetrainExportLayoutSchema,
25149
+ target: RetrainArchiveTargetSchema
25150
+ }), RetrainArchiveResultSchema, {
25151
+ kind: "mutation",
25152
+ auth: "admin",
25153
+ timeoutMs: 60 * 6e4
25154
+ }), method(object({
25155
+ filter: RetrainExportFilterSchema,
25156
+ layout: RetrainExportLayoutSchema
25157
+ }), object({
25158
+ ticket: PeerBytesTicketSchema,
25159
+ frames: number().int(),
25160
+ annotations: number().int()
25161
+ }), {
25162
+ kind: "mutation",
25163
+ auth: "admin",
25164
+ timeoutMs: 12e4
25165
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25166
+ kind: "query",
25167
+ auth: "admin"
25168
+ }), method(object({
25169
+ deviceId: number(),
25170
+ trackId: string().optional(),
25171
+ frameId: string(),
25172
+ profileId: string(),
25173
+ classes: array(RetrainMacroClassSchema).min(1),
25174
+ boxes: array(object({
25175
+ ref: string(),
25176
+ bbox: RetrainBboxSchema,
25177
+ macroClass: RetrainMacroClassSchema,
25178
+ label: string().optional()
25179
+ })).max(50),
25180
+ allowCloud: boolean()
25181
+ }), RetrainLlmAssistResultSchema, {
25182
+ kind: "mutation",
25183
+ auth: "admin",
25184
+ timeoutMs: 18e4
25185
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25186
+ kind: "mutation",
25187
+ auth: "admin"
25188
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25189
+ kind: "query",
25190
+ auth: "admin"
25191
+ }), method(RetrainTrainingCorpusSelectionSchema, RetrainTrainingCorpusResolveResultSchema, {
25192
+ kind: "query",
25193
+ auth: "admin",
25194
+ timeoutMs: 6e4
25195
+ }), method(object({
25196
+ id: string(),
25197
+ name: string().max(120)
25198
+ }), RetrainCollectionRenameResultSchema, {
25199
+ kind: "mutation",
25200
+ auth: "admin"
25201
+ }), method(object({ id: string() }), object({
25202
+ deleted: boolean(),
25203
+ removedFrames: number().int()
25204
+ }), {
25205
+ kind: "mutation",
25206
+ auth: "admin"
25207
+ }), method(object({
25208
+ collectionId: string(),
25209
+ deviceId: number(),
25210
+ epochMs: number()
25211
+ }), AddRetrainFrameFromRecordingResultSchema, {
25212
+ kind: "mutation",
25213
+ auth: "admin",
25214
+ timeoutMs: 6e4
25215
+ }), method(object({
25216
+ collectionId: string(),
25217
+ frameIds: array(string()).min(1).max(500)
25218
+ }), object({
25219
+ added: number().int(),
25220
+ alreadyMember: number().int(),
25221
+ unknownFrameIds: array(string()).readonly()
25222
+ }), {
25223
+ kind: "mutation",
25224
+ auth: "admin"
25225
+ }), method(object({
25226
+ collectionId: string(),
25227
+ frameId: string()
25228
+ }), object({
25229
+ removed: boolean(),
25230
+ deletedFrame: boolean()
25231
+ }), {
25232
+ kind: "mutation",
25233
+ auth: "admin"
25234
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
22983
25235
  kind: "query",
22984
25236
  auth: "admin"
22985
25237
  }), method(object({
@@ -23556,11 +25808,14 @@ var HardwareClassIdSchema = _enum([
23556
25808
  "intel-n-series",
23557
25809
  "apple-m-base",
23558
25810
  "apple-m-pro",
25811
+ "amd-phoenix",
23559
25812
  "unknown"
23560
25813
  ]);
23561
25814
  var AcceleratorKindSchema = _enum([
23562
25815
  "intel-npu",
23563
25816
  "intel-igpu",
25817
+ "amd-igpu",
25818
+ "amd-npu",
23564
25819
  "x86-cpu",
23565
25820
  "arm-cpu",
23566
25821
  "apple-ane",
@@ -23605,13 +25860,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23605
25860
  object({
23606
25861
  kind: literal("no-family-build"),
23607
25862
  format: ModelFormatSchema$1
25863
+ }),
25864
+ object({
25865
+ kind: literal("kept-custom-pin"),
25866
+ modelId: string(),
25867
+ deviceKey: string()
23608
25868
  })
23609
25869
  ]);
25870
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
25871
+ var KeptReasonSchema = _enum(["custom-pin"]);
25872
+ /**
25873
+ * Where a choice's latency came from (D791): this node's own benchmark
25874
+ * result, or the hardware-class table. Measured on the node beats the table.
25875
+ */
25876
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
25877
+ kind: literal("node-benchmark"),
25878
+ resultId: string(),
25879
+ measuredAtMs: number()
25880
+ })]);
23610
25881
  var DeviceModelChoiceSchema = object({
23611
25882
  modelId: string(),
23612
25883
  p50Ms: number(),
23613
25884
  fps: number(),
23614
25885
  measured: boolean(),
25886
+ /** Absent on a plan from before D791 — read as the table. */
25887
+ source: LatencySourceSchema.optional(),
23615
25888
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
23616
25889
  capacitySessions: number(),
23617
25890
  personRecall: number()
@@ -23622,6 +25895,8 @@ var DeviceRecommendationSchema = object({
23622
25895
  enabled: boolean(),
23623
25896
  available: boolean(),
23624
25897
  chosen: DeviceModelChoiceSchema.nullable(),
25898
+ /** Present when the device is kept as is: Apply writes nothing on it. */
25899
+ kept: KeptReasonSchema.optional(),
23625
25900
  reasons: array(RecommendationReasonSchema).readonly()
23626
25901
  });
23627
25902
  var NodeRecommendationSchema = object({
@@ -23675,6 +25950,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
23675
25950
  kind: literal("coral-enabled"),
23676
25951
  nodeId: string(),
23677
25952
  deviceKey: string()
25953
+ }),
25954
+ object({
25955
+ kind: literal("custom-pin-kept"),
25956
+ nodeId: string(),
25957
+ deviceKey: string().nullable(),
25958
+ deviceId: number().nullable(),
25959
+ modelId: string()
25960
+ }),
25961
+ object({
25962
+ kind: literal("custom-registry-unreadable"),
25963
+ error: string()
23678
25964
  })
23679
25965
  ]);
23680
25966
  var AutoTuneOptionsSchema = object({
@@ -23853,13 +26139,14 @@ var SuggestSharesResultSchema = object({
23853
26139
  nodes: array(SuggestedNodeShareSchema).readonly()
23854
26140
  });
23855
26141
  /**
23856
- * Where the node and device shares come from (D750, D755).
23857
- * - `hardware` (default) — computed by the system from each node's static
23858
- * capacity (its accelerators at their Auto tune models, from the measured
23859
- * latency table), recomputed whenever a node or device joins, leaves, is
23860
- * switched on or off, or changes model. No load input.
23861
- * - `benchmark` — the same, from each node's measured capacity (node
23862
- * benchmark results); a node without results falls back to `hardware`.
26142
+ * Where the node and device shares come from (D750, D755, D791).
26143
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26144
+ * benchmark measured it; a node without fresh results is sized from
26145
+ * `hardware` and says so. Measured on the node beats the table.
26146
+ * - `hardware` — computed from each node's static capacity only (its
26147
+ * accelerators at their Auto tune models, from the latency table).
26148
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26149
+ * on or off, changes model, or a benchmark result is written. No load input.
23863
26150
  * - `manual` — the operator's stored sliders.
23864
26151
  * Either way a node or device that cannot take sessions gives its share to
23865
26152
  * the others in proportion; the stored values are never rewritten for that.
@@ -23908,6 +26195,362 @@ var EffectiveSharesSchema = object({
23908
26195
  nodeWeights: record(string(), number()),
23909
26196
  deviceWeights: record(string(), record(string(), number()))
23910
26197
  });
26198
+ /**
26199
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26200
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26201
+ * measuring runner reports, and the result rows Auto tune and the automatic
26202
+ * shares read.
26203
+ *
26204
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26205
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26206
+ * detection candidate, camera pins naming it are ignored so its sessions move
26207
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26208
+ * restart too (a persisted manifest, reconciled against the registry).
26209
+ *
26210
+ * Two measurements, both on the node, driven by its own runner (frames never
26211
+ * cross a process at frame rate, D9):
26212
+ * - `device` — one accelerator × one candidate detector, root only, open
26213
+ * loop: how many streams at the camera rate it carries inside the frame
26214
+ * interval;
26215
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26216
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26217
+ * clip: how many parallel sessions the node carries before latency, drops,
26218
+ * CPU, RAM or the event loop give out.
26219
+ */
26220
+ /** Defaults and bounds, one place. */
26221
+ var NODE_BENCHMARK_DEFAULTS = {
26222
+ fpsPerStream: 10,
26223
+ budgetMinutes: 45,
26224
+ minBudgetMinutes: 10,
26225
+ maxBudgetMinutes: 120,
26226
+ /** A result older than this no longer beats the table. */
26227
+ staleAfterDays: 30,
26228
+ /** Warm-in per ramp step (not accounted). */
26229
+ settleSec: 5,
26230
+ /** Accounted window per ramp step. */
26231
+ measureSec: 20,
26232
+ /** Longest the drain may take before the run is refused. */
26233
+ drainTimeoutSec: 120,
26234
+ /** Candidate models per device in one run. */
26235
+ maxModelsPerDevice: 6
26236
+ };
26237
+ /** The two measurements a run can make. */
26238
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26239
+ var NodeBenchmarkDevicePlanSchema = object({
26240
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26241
+ deviceKey: string().min(1),
26242
+ /**
26243
+ * Root detector candidates for the `device` measurement, in the order
26244
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26245
+ */
26246
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26247
+ });
26248
+ /** What the operator confirmed. */
26249
+ var NodeBenchmarkPlanSchema = object({
26250
+ nodeId: string().min(1),
26251
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26252
+ /** Which measurements run. At least one. */
26253
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26254
+ /**
26255
+ * Detail steps (catalog step ids under the root: faces, plates,
26256
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26257
+ * detector always runs.
26258
+ */
26259
+ steps: array(string().min(1)).default([]),
26260
+ /** Offered rate of one stream / session. */
26261
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26262
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26263
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26264
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26265
+ keepDownloadedModels: boolean().default(false),
26266
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26267
+ acceptInsufficientHeadroom: boolean().default(false)
26268
+ });
26269
+ var NodeBenchmarkRefusalSchema = object({
26270
+ kind: _enum([
26271
+ "benchmark-active",
26272
+ "node-offline",
26273
+ "unknown-device",
26274
+ "no-phase",
26275
+ "insufficient-headroom"
26276
+ ]),
26277
+ detail: string(),
26278
+ overridable: boolean()
26279
+ });
26280
+ /** A camera whose detection leaves the node for the run. */
26281
+ var NodeBenchmarkMovingCameraSchema = object({
26282
+ deviceId: number(),
26283
+ /** Placed on the node now (a standing attach or a running session). */
26284
+ placedOnNode: boolean(),
26285
+ /** A node pin naming this node, ignored for the run. */
26286
+ pinnedToNode: boolean()
26287
+ });
26288
+ /** A camera that cannot leave: no other node can obtain its frames. */
26289
+ var NodeBenchmarkStayingCameraSchema = object({
26290
+ deviceId: number(),
26291
+ reason: literal("only-frame-source")
26292
+ });
26293
+ var NodeBenchmarkPreflightSchema = object({
26294
+ nodeId: string(),
26295
+ online: boolean(),
26296
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26297
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26298
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26299
+ estimatedDurationMs: number(),
26300
+ /** The run ends and the cluster is restored at the latest after this long. */
26301
+ budgetMs: number(),
26302
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26303
+ steps: array(string()).readonly(),
26304
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26305
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26306
+ headroom: object({
26307
+ sessionsNow: number(),
26308
+ otherNodesCapacitySessions: number().nullable()
26309
+ }),
26310
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26311
+ canStart: boolean()
26312
+ });
26313
+ /** Where the measuring runner is. */
26314
+ var NodeBenchProgressSchema = object({
26315
+ phase: _enum([
26316
+ "preparing",
26317
+ "device",
26318
+ "pipeline",
26319
+ "cleanup"
26320
+ ]),
26321
+ deviceKey: string().nullable(),
26322
+ modelId: string().nullable(),
26323
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26324
+ load: number().nullable(),
26325
+ cellsDone: number(),
26326
+ cellsTotal: number(),
26327
+ message: string()
26328
+ });
26329
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26330
+ var NodeBenchLimitSchema = _enum([
26331
+ "p95",
26332
+ "drops",
26333
+ "errors",
26334
+ "stall",
26335
+ "cpu",
26336
+ "ram",
26337
+ "none"
26338
+ ]);
26339
+ var NodeBenchRampStepSchema = object({
26340
+ load: number(),
26341
+ pass: boolean(),
26342
+ p95Ms: number(),
26343
+ dropRatio: number(),
26344
+ /** Completed frames per second over the accounted window. */
26345
+ fps: number(),
26346
+ cpuPct: number().nullable(),
26347
+ ramFreePct: number().nullable(),
26348
+ failReasons: array(string()).readonly()
26349
+ });
26350
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26351
+ phase: literal("device"),
26352
+ deviceKey: string(),
26353
+ modelId: string(),
26354
+ /** Single-stream latency (the K = 1 step). */
26355
+ p50Ms: number(),
26356
+ p95Ms: number(),
26357
+ p99Ms: number(),
26358
+ /** Frames per second sustained at the last passing step. */
26359
+ fps: number(),
26360
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26361
+ kMax: number(),
26362
+ limitedBy: NodeBenchLimitSchema,
26363
+ /** First call (model load + warm-up). */
26364
+ warmupMs: number(),
26365
+ ramp: array(NodeBenchRampStepSchema).readonly()
26366
+ }), object({
26367
+ phase: literal("pipeline"),
26368
+ deviceKey: string(),
26369
+ modelId: string(),
26370
+ steps: array(string()).readonly(),
26371
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26372
+ maxSessions: number(),
26373
+ limitedBy: NodeBenchLimitSchema,
26374
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26375
+ stepsFired: array(string()).readonly(),
26376
+ warmupMs: number(),
26377
+ ramp: array(NodeBenchRampStepSchema).readonly()
26378
+ })]);
26379
+ /**
26380
+ * What a result was measured ON. A result whose fingerprint no longer matches
26381
+ * the node no longer beats the table.
26382
+ */
26383
+ var NodeBenchFingerprintSchema = object({
26384
+ pipelineVersion: string().nullable(),
26385
+ cpuModel: string().nullable(),
26386
+ ramGb: number().nullable(),
26387
+ os: string().nullable(),
26388
+ /** Per device: the pool the cells ran on (runtime + tuning). */
26389
+ pools: record(string(), object({
26390
+ runtime: string(),
26391
+ numWorkers: number(),
26392
+ concurrency: number(),
26393
+ batchMode: string()
26394
+ })).default({})
26395
+ });
26396
+ /** The frames the run used. */
26397
+ var NodeBenchClipSchema = object({
26398
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
26399
+ id: string(),
26400
+ revision: string().nullable(),
26401
+ frames: number(),
26402
+ width: number(),
26403
+ height: number()
26404
+ });
26405
+ var NodeBenchRunnerInputSchema = object({
26406
+ runId: string().min(1),
26407
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26408
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
26409
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
26410
+ steps: array(string()).default([]),
26411
+ fpsPerStream: number().int().min(1).max(30),
26412
+ /** The runner stops on its own past this instant, whatever the hub does. */
26413
+ deadlineAtMs: number(),
26414
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
26415
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
26416
+ keepDownloadedModels: boolean().default(false)
26417
+ });
26418
+ var NodeBenchRunnerStateSchema = _enum([
26419
+ "running",
26420
+ "done",
26421
+ "failed",
26422
+ "aborted"
26423
+ ]);
26424
+ var NodeBenchRunnerStatusSchema = object({
26425
+ runId: string(),
26426
+ nodeId: string(),
26427
+ state: NodeBenchRunnerStateSchema,
26428
+ progress: NodeBenchProgressSchema.nullable(),
26429
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
26430
+ cells: array(NodeBenchCellSchema).readonly(),
26431
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26432
+ clip: NodeBenchClipSchema.nullable(),
26433
+ /** Cameras seen running on the node during the run (they share its pools). */
26434
+ activeCameraIds: array(number()).readonly(),
26435
+ /** Models the run downloaded and then deleted (not installed before). */
26436
+ deletedModels: array(string()).readonly(),
26437
+ error: string().nullable(),
26438
+ startedAtMs: number(),
26439
+ finishedAtMs: number().nullable()
26440
+ });
26441
+ var NodeBenchmarkStateSchema = _enum([
26442
+ "draining",
26443
+ "measuring",
26444
+ "restoring",
26445
+ "done",
26446
+ "failed",
26447
+ "aborted"
26448
+ ]);
26449
+ /** Why a run ended. */
26450
+ var NodeBenchmarkEndReasonSchema = _enum([
26451
+ "completed",
26452
+ "operator-abort",
26453
+ "deadline",
26454
+ "node-lost",
26455
+ "runner-lost",
26456
+ "hub-restart",
26457
+ "drain-timeout",
26458
+ "failed"
26459
+ ]);
26460
+ var NodeBenchmarkRunSchema = object({
26461
+ runId: string(),
26462
+ nodeId: string(),
26463
+ state: NodeBenchmarkStateSchema,
26464
+ plan: NodeBenchmarkPlanSchema,
26465
+ startedAtMs: number(),
26466
+ deadlineAtMs: number(),
26467
+ finishedAtMs: number().nullable(),
26468
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26469
+ error: string().nullable(),
26470
+ /** Cameras moved off the node for the run. */
26471
+ moved: array(number()).readonly(),
26472
+ /** Cameras that stayed (their only frame source is the node). */
26473
+ staying: array(number()).readonly(),
26474
+ /** Something else ran on the node's pools during the run. */
26475
+ contaminated: boolean(),
26476
+ progress: NodeBenchProgressSchema.nullable(),
26477
+ resultIds: array(string()).readonly()
26478
+ });
26479
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26480
+ var NodeBenchmarkStatusSchema = object({
26481
+ /** The node the cluster is in benchmark mode for; null = none. */
26482
+ modeNodeId: string().nullable(),
26483
+ run: NodeBenchmarkRunSchema.nullable()
26484
+ });
26485
+ /**
26486
+ * One stored measurement — the only authority Auto tune and the automatic
26487
+ * shares read measured capacity from. Written by the orchestrator when a run
26488
+ * ends, never by anyone else.
26489
+ */
26490
+ var NodeBenchmarkResultSchema = object({
26491
+ id: string(),
26492
+ runId: string(),
26493
+ nodeId: string(),
26494
+ cell: NodeBenchCellSchema,
26495
+ fpsPerStream: number(),
26496
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26497
+ clip: NodeBenchClipSchema.nullable(),
26498
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26499
+ contaminated: boolean(),
26500
+ stayingCameras: array(number()).readonly(),
26501
+ /** The run ended early; the cell itself completed. */
26502
+ partialRun: boolean(),
26503
+ measuredAtMs: number()
26504
+ });
26505
+ var ListNodeBenchmarkResultsInputSchema = object({
26506
+ nodeId: string().optional(),
26507
+ deviceKey: string().optional()
26508
+ });
26509
+ /** A result with its standing today: does it still beat the table? */
26510
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26511
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26512
+ standing: _enum([
26513
+ "fresh",
26514
+ "stale",
26515
+ "superseded"
26516
+ ]),
26517
+ staleWhy: _enum([
26518
+ "age",
26519
+ "runtime",
26520
+ "pool-tuning"
26521
+ ]).nullable()
26522
+ });
26523
+ object({
26524
+ runId: string(),
26525
+ nodeId: string(),
26526
+ startedAtMs: number(),
26527
+ deadlineAtMs: number(),
26528
+ plan: NodeBenchmarkPlanSchema,
26529
+ moved: array(number()).readonly(),
26530
+ staying: array(number()).readonly()
26531
+ });
26532
+ /** Candidate detectors per device, for the plan editor. */
26533
+ var NodeBenchmarkCandidatesSchema = object({
26534
+ nodeId: string(),
26535
+ reachable: boolean(),
26536
+ devices: array(object({
26537
+ deviceKey: string(),
26538
+ enabled: boolean(),
26539
+ available: boolean(),
26540
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26541
+ suggested: array(string()).readonly(),
26542
+ /** Every root detector the device has a build for. */
26543
+ all: array(string()).readonly(),
26544
+ /** The model the device runs now, when pinned. */
26545
+ currentModelId: string().nullable()
26546
+ })).readonly(),
26547
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26548
+ steps: array(object({
26549
+ id: string(),
26550
+ name: string(),
26551
+ slot: string()
26552
+ })).readonly()
26553
+ });
23911
26554
  object({
23912
26555
  activeCameras: number(),
23913
26556
  throttledCameras: number(),
@@ -24996,7 +27639,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
24996
27639
  }), ParkedTrackFrameSchema.nullable()), method(object({
24997
27640
  deviceId: number(),
24998
27641
  trackId: string()
24999
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
27642
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
27643
+ accepted: literal(true),
27644
+ runId: string()
27645
+ }), {
27646
+ kind: "mutation",
27647
+ auth: "admin"
27648
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27649
+ kind: "mutation",
27650
+ auth: "admin"
27651
+ });
25000
27652
  var CameraPipelineConfigSchema = object({
25001
27653
  engine: PipelineEngineChoiceSchema.optional(),
25002
27654
  steps: array(PipelineStepInputSchema).readonly(),
@@ -25053,6 +27705,8 @@ var AgentPipelineSettingsSchema = object({
25053
27705
  * address is wrong (multi-homed host, NAT, custom interface).
25054
27706
  */
25055
27707
  reachableHost: string().optional(),
27708
+ /** Hub-persisted UI colour (`--color-node-*` theme tokens). */
27709
+ color: NodeColorIdSchema.optional(),
25056
27710
  /**
25057
27711
  * Multi-device inference opt-in (Phase 4). Per-node map deviceKey → {enabled,
25058
27712
  * weight, steps}. Absent / all-disabled ⇒ the node's single default
@@ -25602,8 +28256,9 @@ method(object({
25602
28256
  auth: "admin"
25603
28257
  }), method(object({
25604
28258
  agentNodeId: string(),
25605
- reachableHost: string().nullable()
25606
- }), object({ success: literal(true) }), {
28259
+ reachableHost: string().nullable().optional(),
28260
+ color: NodeColorIdSchema.nullable().optional()
28261
+ }).refine((v) => v.reachableHost !== void 0 || v.color !== void 0, { message: "reachableHost or color required" }), object({ success: literal(true) }), {
25607
28262
  kind: "mutation",
25608
28263
  auth: "admin"
25609
28264
  }), method(object({
@@ -25635,6 +28290,21 @@ method(object({
25635
28290
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
25636
28291
  kind: "mutation",
25637
28292
  auth: "admin"
28293
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28294
+ kind: literal("started"),
28295
+ runId: string()
28296
+ }), object({
28297
+ kind: literal("refused"),
28298
+ preflight: NodeBenchmarkPreflightSchema
28299
+ })]), {
28300
+ kind: "mutation",
28301
+ auth: "admin"
28302
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28303
+ kind: "mutation",
28304
+ auth: "admin"
28305
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28306
+ kind: "mutation",
28307
+ auth: "admin"
25638
28308
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
25639
28309
  deviceId: number(),
25640
28310
  addonId: string(),
@@ -26040,8 +28710,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26040
28710
  * `smtp-provider` — pluggable email delivery surface.
26041
28711
  *
26042
28712
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26043
- * one for transactional / one for notifications). Consumers (magic-link,
26044
- * notifier addons, …) walk the collection and pick the first
28713
+ * one for transactional / one for notifications). Consumers (notifier
28714
+ * addons, …) walk the collection and pick the first
26045
28715
  * ready provider OR target a specific addonId.
26046
28716
  *
26047
28717
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -26220,7 +28890,7 @@ targets: array(object({
26220
28890
  })));
26221
28891
  /**
26222
28892
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
26223
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
28893
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
26224
28894
  * carrying the post-callback claims before redirecting back to
26225
28895
  * `/api/auth/sso/finish`.
26226
28896
  *
@@ -26271,7 +28941,26 @@ var SsoBridgeClaimsSchema = object({
26271
28941
  * editing a descriptor must not retroactively extend or shorten a link the
26272
28942
  * operator already consented to.
26273
28943
  */
26274
- refreshTtl: union([number().int().positive(), literal("never")]).optional()
28944
+ refreshTtl: union([number().int().positive(), literal("never")]).optional(),
28945
+ /**
28946
+ * Opaque handle of a hub-side LINK intent (D782). Set by an OIDC callback
28947
+ * that was started from a signed-in user's "Link" button: the finish then
28948
+ * links this identity to the intent's user instead of signing anyone in.
28949
+ * The handle carries no user id — the hub resolves it, single-use.
28950
+ */
28951
+ linkIntent: string().optional(),
28952
+ /**
28953
+ * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28954
+ * subject is unique only per issuer, so a link is bound to it.
28955
+ */
28956
+ issuer: string().optional(),
28957
+ /**
28958
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
28959
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
28960
+ * request to present the matching cookie — a login bridge is useless in
28961
+ * any other browser.
28962
+ */
28963
+ browserBinding: string().optional()
26275
28964
  });
26276
28965
  method(object({
26277
28966
  claims: SsoBridgeClaimsSchema,
@@ -28177,7 +30866,22 @@ DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), ar
28177
30866
  * field their hints were silently stripped by the schema and the
28178
30867
  * adaptive ladder started blind on the client's display size.
28179
30868
  */
28180
- hints: webrtcClientHintsSchema.optional()
30869
+ hints: webrtcClientHintsSchema.optional(),
30870
+ /**
30871
+ * Talk-back (D771): relay the PEER's audio to the device's speaker
30872
+ * through the `intercom` cap's push-talk triple. When `true` and the
30873
+ * offer lets the peer send audio, the answer's audio is `sendrecv`
30874
+ * and every inbound frame goes to `intercom.pushTalkAudio` for this
30875
+ * `deviceId`; absent/false answers `sendonly`, as for every viewer.
30876
+ *
30877
+ * TRUSTED-CALLER ONLY. Set by the Alexa export for an Echo on a camera
30878
+ * with `intercom`, when the linked user may control that camera. The
30879
+ * hub STRIPS it from every request-bound call (a browser), exactly as
30880
+ * it overwrites `relayOnly` — a viewer's talk permission is the
30881
+ * intercom cap's own surface (share tokens gate it there), and this
30882
+ * flag must not become a second door to the camera's speaker.
30883
+ */
30884
+ talkback: boolean().optional()
28181
30885
  }), object({
28182
30886
  sessionId: string(),
28183
30887
  sdpAnswer: string()
@@ -28601,7 +31305,7 @@ var CustomActionInputSchema = object({
28601
31305
  action: string().min(1),
28602
31306
  input: unknown()
28603
31307
  });
28604
- method(_void(), array(AddonListItemSchema).readonly()), method(object({
31308
+ method(object({ nodeId: string().optional() }).optional(), array(AddonListItemSchema).readonly()), method(object({
28605
31309
  addonId: string(),
28606
31310
  limit: number().min(1).max(500).default(100),
28607
31311
  level: LogLevelSchema$2.optional()
@@ -30689,6 +33393,9 @@ var CreateIntegrationInputSchema = object({
30689
33393
  enabled: boolean().optional(),
30690
33394
  info: record(string(), unknown()).optional(),
30691
33395
  settings: record(string(), unknown()).optional(),
33396
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
33397
+ * the keychain, not the table (D787). */
33398
+ secretKeys: array(string()).optional(),
30692
33399
  skipRestart: boolean().optional()
30693
33400
  });
30694
33401
  var UpdateIntegrationInputSchema = object({
@@ -30712,7 +33419,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
30712
33419
  auth: "admin"
30713
33420
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
30714
33421
  id: string(),
30715
- settings: record(string(), unknown())
33422
+ settings: record(string(), unknown()),
33423
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
33424
+ secretKeys: array(string()).optional()
30716
33425
  }), object({ success: boolean() }), {
30717
33426
  kind: "mutation",
30718
33427
  auth: "admin"
@@ -32143,7 +34852,13 @@ var TopologyNodeSchema = object({
32143
34852
  })).readonly(),
32144
34853
  processes: array(TopologyProcessSchema).readonly(),
32145
34854
  categories: array(TopologyCategorySchema).readonly(),
32146
- rootPackage: TopologyRootPackageSchema.nullable()
34855
+ rootPackage: TopologyRootPackageSchema.nullable(),
34856
+ /**
34857
+ * How an online AGENT reaches the hub (mesh mTLS Release A): `tls` once it has
34858
+ * completed a mutual-TLS handshake, `clear` otherwise. Absent for the hub,
34859
+ * for offline rows and when the hub cannot tell.
34860
+ */
34861
+ meshTransport: _enum(["tls", "clear"]).optional()
32147
34862
  });
32148
34863
  var CapUsageEdgeSchema = object({
32149
34864
  callerAddonId: string(),
@@ -32483,6 +35198,7 @@ var OsdNamedTemplateSchema = object({
32483
35198
  });
32484
35199
  /** Where a slot's value comes from. */
32485
35200
  var OsdSourceSchema = discriminatedUnion("kind", [
35201
+ object({ kind: literal("none") }),
32486
35202
  object({
32487
35203
  kind: literal("static"),
32488
35204
  text: string().max(64)
@@ -32609,6 +35325,13 @@ method(object({ deviceId: number().int() }), object({
32609
35325
  }), object({ success: literal(true) }), {
32610
35326
  kind: "mutation",
32611
35327
  auth: "admin"
35328
+ }), method(object({
35329
+ deviceId: number().int(),
35330
+ slotId: string().min(1),
35331
+ enabled: boolean()
35332
+ }), object({ success: literal(true) }), {
35333
+ kind: "mutation",
35334
+ auth: "admin"
32612
35335
  }), method(object({
32613
35336
  sourceDeviceId: number().int(),
32614
35337
  targetDeviceId: number().int()
@@ -32989,7 +35712,15 @@ var GpuInfoSchema = object({
32989
35712
  name: string(),
32990
35713
  memoryMB: number().optional()
32991
35714
  });
32992
- var NpuInfoSchema = object({ type: _enum(["apple-ane", "intel-npu"]) });
35715
+ var NpuInfoSchema = object({
35716
+ type: _enum([
35717
+ "apple-ane",
35718
+ "intel-npu",
35719
+ "amd-xdna"
35720
+ ]),
35721
+ name: string().optional(),
35722
+ generation: _enum(["xdna1", "xdna2"]).optional()
35723
+ });
32993
35724
  var CoralInfoSchema = object({
32994
35725
  type: literal("coral-edgetpu"),
32995
35726
  bus: string().optional()
@@ -36171,16 +38902,6 @@ var ApiKeySummarySchema = object({
36171
38902
  createdAt: number(),
36172
38903
  lastUsedAt: number().optional()
36173
38904
  });
36174
- var CreateApiKeyInputSchema = object({
36175
- label: string(),
36176
- isAdmin: boolean().default(false),
36177
- allowedProviders: union([array(string()), literal("*")]).optional(),
36178
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
36179
- });
36180
- var CreateApiKeyResultSchema = object({
36181
- token: string(),
36182
- record: ApiKeySummarySchema
36183
- });
36184
38905
  var ScopedTokenSummarySchema = object({
36185
38906
  id: string(),
36186
38907
  userId: string(),
@@ -36221,6 +38942,32 @@ var TotpStatusSchema = object({
36221
38942
  /** Null when no row exists OR the row is still pending confirmation. */
36222
38943
  confirmedAt: number().nullable()
36223
38944
  });
38945
+ /**
38946
+ * user-management — singleton capability for user accounts, API keys,
38947
+ * and scoped tokens.
38948
+ *
38949
+ * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
38950
+ * — the subset check on `setUserScopes` / `createScopedToken` is moot
38951
+ * because non-admins never reach these. If/when we open non-admin
38952
+ * delegation, structural caller-scope subset check goes inside the
38953
+ * provider.
38954
+ */
38955
+ var ExternalIdentitySchema = object({
38956
+ /** Login-method id of the provider instance, e.g. `auth-oidc/authentik`. */
38957
+ provider: string(),
38958
+ /** The IdP's stable subject (`sub`) for this account. */
38959
+ subject: string(),
38960
+ /** The verified `iss` of the IdP the identity was linked under — `sub` is unique only per issuer. */
38961
+ issuer: string(),
38962
+ userId: string(),
38963
+ /** What the IdP called the account at link time (username / email) — display only. */
38964
+ label: string().optional(),
38965
+ linkedAt: number()
38966
+ });
38967
+ var ExternalIdentityKeySchema = object({
38968
+ provider: string().min(1),
38969
+ subject: string().min(1)
38970
+ });
36224
38971
  method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserInputSchema, UserSummarySchema, {
36225
38972
  kind: "mutation",
36226
38973
  auth: "admin",
@@ -36253,17 +39000,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36253
39000
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
36254
39001
  kind: "mutation",
36255
39002
  access: "view"
36256
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
36257
- kind: "mutation",
36258
- auth: "admin",
36259
- access: "create"
36260
- }), method(object({ id: string() }), object({ success: literal(true) }), {
39003
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
36261
39004
  kind: "mutation",
36262
39005
  auth: "admin",
36263
39006
  access: "delete"
36264
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
36265
- kind: "mutation",
36266
- access: "view"
36267
39007
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
36268
39008
  kind: "mutation",
36269
39009
  auth: "admin",
@@ -36334,7 +39074,14 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36334
39074
  userId: string(),
36335
39075
  username: string(),
36336
39076
  scopes: array(TokenScopeSchema)
36337
- }).nullable(), { access: "view" }), method(_void(), array(OauthSessionSummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: boolean() }), {
39077
+ }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
39078
+ userId: string(),
39079
+ issuer: string()
39080
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39081
+ kind: "mutation",
39082
+ auth: "admin",
39083
+ access: "delete"
39084
+ }), method(_void(), array(OauthSessionSummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: boolean() }), {
36338
39085
  kind: "mutation",
36339
39086
  auth: "admin",
36340
39087
  access: "delete"
@@ -36725,6 +39472,563 @@ DeviceType.Camera, method(object({
36725
39472
  detection: array(ZoneRuleSchema).readonly(),
36726
39473
  package: array(ZoneRuleSchema).readonly()
36727
39474
  });
39475
+ /**
39476
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39477
+ *
39478
+ * A thin, mockable translation layer: it knows how to run a container with a
39479
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39480
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39481
+ * those are the `training` orchestrator's (D805). Every rule written there
39482
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39483
+ * manifest entry and nothing else.
39484
+ *
39485
+ * Collection of provider **types** (addons). Each addon owns zero or more
39486
+ * **entries** (credentials + defaults). Concat-fans: `describe`,
39487
+ * `describeTypes`, `listEntries`, `listJobs`. Single-row work is keyed by
39488
+ * `entryId`; callers also pass the owning `addonId` as the collection
39489
+ * selector (broker posture). Every method is `admin`: these spend money.
39490
+ *
39491
+ * Every cloud object a provider creates is tagged with the orchestrator's
39492
+ * `jobKey`, so a retried submit finds the job it already started instead of
39493
+ * starting a second GPU, and `listJobs` can find orphans.
39494
+ *
39495
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39496
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39497
+ * ticket the provider mints (D613).
39498
+ */
39499
+ var TrainingGpuOptionSchema = object({
39500
+ id: string(),
39501
+ label: string(),
39502
+ /** List price, USD per GPU-hour, before any region multiplier. */
39503
+ usdPerHour: number().nonnegative(),
39504
+ vramGb: number().nonnegative()
39505
+ });
39506
+ var TrainingRegionOptionSchema = object({
39507
+ /** `''` = any region (the provider's choice). */
39508
+ id: string(),
39509
+ label: string(),
39510
+ priceMultiplier: number().positive()
39511
+ });
39512
+ /**
39513
+ * The provider's per-entry settings, as the orchestrator reads them. They
39514
+ * live on the PROVIDER addon's entry (operator decision 2026-10-08: they
39515
+ * depend on the user's account), never hard-coded in the orchestrator.
39516
+ */
39517
+ var TrainingProviderDefaultsSchema = object({
39518
+ gpuType: string(),
39519
+ region: string(),
39520
+ costCapUsd: number().nonnegative(),
39521
+ maxRuntimeSec: number().int().positive(),
39522
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39523
+ failedDatasetGraceHours: number().nonnegative()
39524
+ });
39525
+ /**
39526
+ * Entry form schema for a provider type — same seam as notification
39527
+ * `TargetKind.configSchema` (`z.unknown()` at the wire; callers tighten to
39528
+ * {@link ConfigUISchema}). Drives `ConfigFormBuilder` on Training → Providers.
39529
+ */
39530
+ var ConfigSchemaPassthrough = unknown();
39531
+ /** One creatable provider type, for the Add-entry dialog. */
39532
+ var TrainingProviderTypeSchema = object({
39533
+ typeId: string(),
39534
+ label: string(),
39535
+ /** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
39536
+ iconAsset: string(),
39537
+ /** Owning `training-provider` addon — collection selector for createEntry. */
39538
+ addonId: string(),
39539
+ /**
39540
+ * Fields for one entry of this type (credentials + defaults). Absent on a
39541
+ * type that only needs a name. Password fields are keychain-backed on the
39542
+ * provider addon (`secretStatePaths`), not D634 plaintext.
39543
+ */
39544
+ configSchema: ConfigSchemaPassthrough.optional()
39545
+ });
39546
+ /** One configured account / workspace under a provider type. */
39547
+ var TrainingProviderEntrySchema = object({
39548
+ entryId: string(),
39549
+ typeId: string(),
39550
+ name: string(),
39551
+ addonId: string(),
39552
+ /** Credentials are present — never the values. */
39553
+ configured: boolean()
39554
+ });
39555
+ var TrainingProviderDescriptorSchema = object({
39556
+ addonId: string(),
39557
+ entryId: string(),
39558
+ typeId: string(),
39559
+ /** Operator-chosen entry name. */
39560
+ name: string(),
39561
+ iconAsset: string(),
39562
+ /** `modal`, `runpod`, `fake`, … — same as typeId for current providers. */
39563
+ kind: string(),
39564
+ label: string(),
39565
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39566
+ regions: array(TrainingRegionOptionSchema).readonly(),
39567
+ maxDatasetBytes: number().int().positive(),
39568
+ maxRuntimeSec: number().int().positive(),
39569
+ freeTierNote: string().optional(),
39570
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39571
+ dataResidencyNote: string(),
39572
+ /** Credentials are present — never the values. */
39573
+ configured: boolean(),
39574
+ defaults: TrainingProviderDefaultsSchema,
39575
+ /**
39576
+ * Values for {@link TrainingProviderTypeSchema}'s `configSchema` — password
39577
+ * fields are keychain {@link SecretFieldView} or `null` / `''` (create),
39578
+ * never plaintext. Same hydrate contract as settings forms (D789).
39579
+ */
39580
+ formValues: record(string(), unknown()).optional()
39581
+ });
39582
+ /**
39583
+ * Patch one entry's name, credentials and defaults. Pin with owning `{ addonId }`.
39584
+ * An omitted or empty `tokenSecret` means KEEP the stored secret (D787).
39585
+ * `{ $secretClear: true }` clears it.
39586
+ */
39587
+ var TrainingProviderUpdateEntryInputSchema = object({
39588
+ entryId: string().min(1),
39589
+ name: string().min(1),
39590
+ tokenId: string().optional(),
39591
+ tokenSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
39592
+ environment: string().optional(),
39593
+ gpuType: string().optional(),
39594
+ region: string().optional(),
39595
+ costCapUsd: number().nonnegative().optional(),
39596
+ maxRuntimeSec: number().int().positive().optional(),
39597
+ failedDatasetGraceHours: number().nonnegative().optional()
39598
+ });
39599
+ var TrainingCredentialCheckSchema = object({
39600
+ ok: boolean(),
39601
+ /** Workspace / account name, when the provider says. */
39602
+ account: string().optional(),
39603
+ reason: _enum([
39604
+ "missing",
39605
+ "invalid",
39606
+ "forbidden",
39607
+ "network",
39608
+ "quota"
39609
+ ]).optional(),
39610
+ detail: string().optional()
39611
+ });
39612
+ var ProviderJobStateSchema = _enum([
39613
+ "pending",
39614
+ "starting",
39615
+ "running",
39616
+ "succeeded",
39617
+ "failed",
39618
+ "cancelled",
39619
+ "lost"
39620
+ ]);
39621
+ var ProviderJobStatusSchema = object({
39622
+ jobKey: string(),
39623
+ providerJobId: string().optional(),
39624
+ state: ProviderJobStateSchema,
39625
+ startedAt: number().optional(),
39626
+ endedAt: number().optional(),
39627
+ exitCode: number().int().optional(),
39628
+ failureReason: string().optional(),
39629
+ gpuType: string(),
39630
+ region: string().optional(),
39631
+ billedSeconds: number().nonnegative(),
39632
+ costUsd: number().nonnegative(),
39633
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39634
+ costIsEstimate: boolean(),
39635
+ lastFetchedAt: number()
39636
+ });
39637
+ /**
39638
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39639
+ * image its own way (Modal builds the published Dockerfile at that revision;
39640
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39641
+ * in `result.json`.
39642
+ */
39643
+ var TrainerSourceRefSchema = object({
39644
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39645
+ repo: string().min(1),
39646
+ /** A commit sha (never a branch) — the job must be reproducible. */
39647
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39648
+ });
39649
+ /** Cloud job identity — route with the owning addon's `addonId` selector. */
39650
+ var JobRef = {
39651
+ entryId: string().min(1),
39652
+ jobKey: string().uuid()
39653
+ };
39654
+ var TrainingLogLineSchema = object({
39655
+ ts: number(),
39656
+ text: string()
39657
+ });
39658
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderTypeSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderEntrySchema).readonly(), { auth: "admin" }), method(object({
39659
+ typeId: string().min(1),
39660
+ name: string().min(1)
39661
+ }), object({ entryId: string() }), {
39662
+ kind: "mutation",
39663
+ auth: "admin"
39664
+ }), method(object({ entryId: string().min(1) }), object({ ok: literal(true) }), {
39665
+ kind: "mutation",
39666
+ auth: "admin"
39667
+ }), method(TrainingProviderUpdateEntryInputSchema, object({ ok: literal(true) }), {
39668
+ kind: "mutation",
39669
+ auth: "admin"
39670
+ }), method(object({ entryId: string().min(1) }), TrainingCredentialCheckSchema, {
39671
+ kind: "mutation",
39672
+ auth: "admin",
39673
+ timeoutMs: 3e4
39674
+ }), method(object({
39675
+ entryId: string().min(1),
39676
+ gpuType: string(),
39677
+ region: string(),
39678
+ datasetBytes: number().int().nonnegative(),
39679
+ gpuSecondsLow: number().nonnegative(),
39680
+ gpuSecondsHigh: number().nonnegative()
39681
+ }), object({
39682
+ usdLow: number().nonnegative(),
39683
+ usdHigh: number().nonnegative(),
39684
+ notes: array(string()).readonly()
39685
+ }), { auth: "admin" }), method(object({
39686
+ ...JobRef,
39687
+ ticket: PeerBytesTicketSchema
39688
+ }), object({
39689
+ bytes: number().int().nonnegative(),
39690
+ sha256: string()
39691
+ }), {
39692
+ kind: "mutation",
39693
+ auth: "admin",
39694
+ timeoutMs: 120 * 6e4
39695
+ }), method(object({
39696
+ ...JobRef,
39697
+ trainer: TrainerSourceRefSchema,
39698
+ jobSpecJson: string().min(2).max(64e3),
39699
+ gpuType: string(),
39700
+ region: string(),
39701
+ maxRuntimeSec: number().int().positive()
39702
+ }), ProviderJobStatusSchema, {
39703
+ kind: "mutation",
39704
+ auth: "admin",
39705
+ timeoutMs: 30 * 6e4
39706
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39707
+ auth: "admin",
39708
+ timeoutMs: 6e4
39709
+ }), method(object({
39710
+ ...JobRef,
39711
+ cursor: string().optional(),
39712
+ max: number().int().min(1).max(500)
39713
+ }), object({
39714
+ lines: array(TrainingLogLineSchema).readonly(),
39715
+ cursor: string()
39716
+ }), {
39717
+ auth: "admin",
39718
+ timeoutMs: 6e4
39719
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39720
+ kind: "mutation",
39721
+ auth: "admin",
39722
+ timeoutMs: 6e4
39723
+ }), method(object(JobRef), object({
39724
+ found: boolean(),
39725
+ text: string().optional()
39726
+ }), {
39727
+ kind: "mutation",
39728
+ auth: "admin",
39729
+ timeoutMs: 5 * 6e4
39730
+ }), method(object({
39731
+ ...JobRef,
39732
+ path: _enum(["bundle.tar"])
39733
+ }), object({ ticket: PeerBytesTicketSchema }), {
39734
+ kind: "mutation",
39735
+ auth: "admin",
39736
+ timeoutMs: 5 * 6e4
39737
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39738
+ kind: "mutation",
39739
+ auth: "admin",
39740
+ timeoutMs: 5 * 6e4
39741
+ }), method(object({ entryId: string().min(1).optional() }), array(ProviderJobStatusSchema).readonly(), {
39742
+ auth: "admin",
39743
+ timeoutMs: 2 * 6e4
39744
+ });
39745
+ /**
39746
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39747
+ * provided by `addon-training`.
39748
+ *
39749
+ * It owns what every provider must agree on, written once:
39750
+ *
39751
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39752
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39753
+ * - **The return flow.** Verified artefacts → Model Studio
39754
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39755
+ * rollback. Nothing is ever registered automatically.
39756
+ *
39757
+ * Plan/start takes a live {@link TrainingCorpusSelection} (collections +
39758
+ * work-state rule); frame ids are resolved via pipeline-analytics at that
39759
+ * moment and snapshotted on the job. No frozen dataset version.
39760
+ *
39761
+ * Every method is `admin`.
39762
+ */
39763
+ /**
39764
+ * Live corpus criteria for plan/start (design §5.2). Default is complete-only.
39765
+ * Frame ids are resolved at plan/start — never a frozen version id.
39766
+ */
39767
+ var TrainingCorpusSelectionSchema = object({
39768
+ collectionIds: array(string()).min(1),
39769
+ /** Default complete-only for v1 */
39770
+ workState: _enum([
39771
+ "complete",
39772
+ "annotated_or_complete",
39773
+ "any_annotated"
39774
+ ]).default("complete")
39775
+ });
39776
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39777
+ var TrainingBaseModelSchema = object({
39778
+ modelId: string(),
39779
+ label: string(),
39780
+ weights: string(),
39781
+ imgsz: number().int(),
39782
+ baselineOnnxUrl: string(),
39783
+ baselineFloors: record(string(), number()),
39784
+ /** The base the fleet runs most — the UI's default. */
39785
+ recommended: boolean()
39786
+ });
39787
+ var TrainingPresetSchema = _enum([
39788
+ "quick",
39789
+ "standard",
39790
+ "thorough"
39791
+ ]);
39792
+ var TrainingJobRequestSchema = object({
39793
+ /** Live collection + work-state criteria; resolved at plan/start. */
39794
+ selection: TrainingCorpusSelectionSchema,
39795
+ /**
39796
+ * The provider **entry** that runs it (credentials + defaults).
39797
+ * Resolve to an owning addon via `training-provider.describe` / `listEntries`.
39798
+ */
39799
+ entryId: string().min(1),
39800
+ gpuType: string().min(1),
39801
+ region: string(),
39802
+ baseModelId: string().min(1),
39803
+ preset: TrainingPresetSchema,
39804
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39805
+ freeze: number().int().nonnegative().nullable(),
39806
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39807
+ holdoutCameras: array(number().int()).nullable()
39808
+ });
39809
+ var TrainingSplitPlanSchema = object({
39810
+ holdoutCameras: array(number().int()).readonly(),
39811
+ /** Used when no camera is held out: the last N days of every camera. */
39812
+ holdoutLastDays: number().int().nonnegative(),
39813
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39814
+ holdoutSupport: record(string(), number().int()).nullable(),
39815
+ trainSubjects: number().int()
39816
+ });
39817
+ var TrainingRefusalReasonSchema = _enum([
39818
+ "unknown-dataset",
39819
+ "unknown-provider",
39820
+ "provider-not-configured",
39821
+ "unknown-base-model",
39822
+ "unknown-gpu",
39823
+ "dataset-too-large",
39824
+ "no-training-subjects",
39825
+ "job-already-running"
39826
+ ]);
39827
+ var TrainingJobPlanSchema = object({
39828
+ refusal: object({
39829
+ reason: TrainingRefusalReasonSchema,
39830
+ detail: string()
39831
+ }).nullable(),
39832
+ warnings: array(string()).readonly(),
39833
+ split: TrainingSplitPlanSchema.nullable(),
39834
+ estimate: object({
39835
+ datasetBytes: number().int(),
39836
+ uploadMinutesAt20Mbps: number(),
39837
+ gpuSecondsLow: number(),
39838
+ gpuSecondsHigh: number(),
39839
+ usdLow: number(),
39840
+ usdHigh: number(),
39841
+ notes: array(string()).readonly()
39842
+ }).nullable(),
39843
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39844
+ defaults: object({
39845
+ maxCostUsd: number(),
39846
+ maxRuntimeSec: number().int()
39847
+ }).nullable(),
39848
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39849
+ dataNotice: string()
39850
+ });
39851
+ /**
39852
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39853
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39854
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39855
+ * result lives after the operator acted on it.
39856
+ */
39857
+ var TrainingJobStateSchema = _enum([
39858
+ "queued",
39859
+ "uploading",
39860
+ "submitted",
39861
+ "starting",
39862
+ "running",
39863
+ "collecting",
39864
+ "ready",
39865
+ "registered",
39866
+ "canary",
39867
+ "failed",
39868
+ "cancelling",
39869
+ "cancelled",
39870
+ "lost",
39871
+ "expired",
39872
+ "discarded"
39873
+ ]);
39874
+ var TrainingFailureReasonSchema = _enum([
39875
+ "cost-cap",
39876
+ "runtime-cap",
39877
+ "upload-failed",
39878
+ "submit-failed",
39879
+ "trainer-failed",
39880
+ "result-invalid",
39881
+ "checksum-mismatch",
39882
+ "fetch-failed",
39883
+ "provider-error",
39884
+ "hub-restart-during-upload"
39885
+ ]);
39886
+ var TrainingProgressPointSchema = object({
39887
+ epoch: number().int(),
39888
+ map50: number().nullable(),
39889
+ map50_95: number().nullable()
39890
+ });
39891
+ var TrainingCanarySchema = object({
39892
+ deviceIds: array(number().int()).readonly(),
39893
+ since: number(),
39894
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39895
+ previous: array(object({
39896
+ deviceId: number().int(),
39897
+ nodeId: string(),
39898
+ deviceKey: string(),
39899
+ patch: object({
39900
+ modelId: string().optional(),
39901
+ settings: record(string(), unknown()).readonly().optional()
39902
+ }).nullable()
39903
+ })).readonly()
39904
+ });
39905
+ var TrainingJobSchema = object({
39906
+ id: string(),
39907
+ idempotencyKey: string(),
39908
+ name: string(),
39909
+ createdAt: number(),
39910
+ updatedAt: number(),
39911
+ state: TrainingJobStateSchema,
39912
+ /**
39913
+ * Shared by every job enqueued together via `startJobBatch`.
39914
+ * `null` for a lone `startJob`. The engine advances queued siblings by this id.
39915
+ */
39916
+ batchId: string().nullable().default(null),
39917
+ stage: TrainingStageSchema.nullable(),
39918
+ failure: object({
39919
+ reason: TrainingFailureReasonSchema,
39920
+ stage: string().nullable(),
39921
+ detail: string()
39922
+ }).nullable(),
39923
+ request: TrainingJobRequestSchema,
39924
+ maxCostUsd: number().nonnegative(),
39925
+ maxRuntimeSec: number().int().positive(),
39926
+ trainer: TrainerSourceRefSchema,
39927
+ datasetLayout: RetrainExportLayoutSchema,
39928
+ /** Frame count snapshotted when the job started (audit; equals `frameIds.length`). */
39929
+ frameCount: number().int().nonnegative(),
39930
+ /** Resolved frame ids at start — the archive ships exactly these. */
39931
+ frameIds: array(string()).max(2e4).readonly(),
39932
+ /** Hash of what those frames taught at start (trainer `dataset.annotationHash`). */
39933
+ annotationHash: string(),
39934
+ dataset: object({
39935
+ bytes: number().int(),
39936
+ sha256: string(),
39937
+ uploadedAt: number()
39938
+ }).nullable(),
39939
+ split: TrainingSplitPlanSchema,
39940
+ provider: object({
39941
+ state: ProviderJobStateSchema.nullable(),
39942
+ providerJobId: string().nullable(),
39943
+ startedAt: number().nullable(),
39944
+ endedAt: number().nullable(),
39945
+ billedSeconds: number(),
39946
+ costUsd: number(),
39947
+ costIsEstimate: boolean(),
39948
+ lastPolledAt: number().nullable()
39949
+ }),
39950
+ progress: object({
39951
+ epoch: number().int().nullable(),
39952
+ epochs: number().int().nullable(),
39953
+ etaSec: number().nullable(),
39954
+ series: array(TrainingProgressPointSchema).readonly()
39955
+ }),
39956
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
39957
+ logTail: array(string()).readonly(),
39958
+ logCursor: string().nullable(),
39959
+ artifacts: object({
39960
+ bundleBytes: number().int(),
39961
+ bundleSha256: string(),
39962
+ fetchedAt: number(),
39963
+ /** When the staged artefacts are deleted from the hub. */
39964
+ expiresAt: number()
39965
+ }).nullable(),
39966
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
39967
+ cloudDatasetDeletedAt: number().nullable(),
39968
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
39969
+ cloudCleanupDueAt: number().nullable(),
39970
+ /** Model ids registered from this job (base, and int8 when kept). */
39971
+ registeredModelIds: array(string()).readonly(),
39972
+ canary: TrainingCanarySchema.nullable()
39973
+ });
39974
+ var IdInput = object({ id: string().min(1) });
39975
+ method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
39976
+ auth: "admin",
39977
+ timeoutMs: 6e4
39978
+ }), method(TrainingJobRequestSchema.extend({
39979
+ name: string().min(1).max(120),
39980
+ maxCostUsd: number().positive(),
39981
+ maxRuntimeSec: number().int().positive(),
39982
+ idempotencyKey: string().min(8).max(80)
39983
+ }), discriminatedUnion("kind", [object({
39984
+ kind: literal("started"),
39985
+ job: TrainingJobSchema
39986
+ }), object({
39987
+ kind: literal("refused"),
39988
+ reason: TrainingRefusalReasonSchema,
39989
+ detail: string()
39990
+ })]), {
39991
+ kind: "mutation",
39992
+ auth: "admin",
39993
+ timeoutMs: 12e4
39994
+ }), method(TrainingJobRequestSchema.omit({ baseModelId: true }).extend({
39995
+ baseModelIds: array(string().min(1)).min(1),
39996
+ name: string().min(1).max(120),
39997
+ maxCostUsd: number().positive(),
39998
+ maxRuntimeSec: number().int().positive(),
39999
+ idempotencyKey: string().min(8).max(80)
40000
+ }), discriminatedUnion("kind", [object({
40001
+ kind: literal("started"),
40002
+ batchId: string(),
40003
+ jobs: array(TrainingJobSchema).min(1).readonly()
40004
+ }), object({
40005
+ kind: literal("refused"),
40006
+ reason: TrainingRefusalReasonSchema,
40007
+ detail: string()
40008
+ })]), {
40009
+ kind: "mutation",
40010
+ auth: "admin",
40011
+ timeoutMs: 12e4
40012
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
40013
+ kind: "mutation",
40014
+ auth: "admin",
40015
+ timeoutMs: 12e4
40016
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
40017
+ kind: "mutation",
40018
+ auth: "admin",
40019
+ timeoutMs: 30 * 6e4
40020
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
40021
+ kind: "mutation",
40022
+ auth: "admin",
40023
+ timeoutMs: 12e4
40024
+ }), method(IdInput, TrainingJobSchema, {
40025
+ kind: "mutation",
40026
+ auth: "admin",
40027
+ timeoutMs: 12e4
40028
+ }), method(IdInput, TrainingJobSchema, {
40029
+ kind: "mutation",
40030
+ auth: "admin"
40031
+ });
36728
40032
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
36729
40033
  Object.freeze({
36730
40034
  person: .5,
@@ -37348,6 +40652,12 @@ Object.freeze({
37348
40652
  addonId: null,
37349
40653
  access: "create"
37350
40654
  },
40655
+ "backup.checkBackupKey": {
40656
+ capName: "backup",
40657
+ capScope: "system",
40658
+ addonId: null,
40659
+ access: "create"
40660
+ },
37351
40661
  "backup.delete": {
37352
40662
  capName: "backup",
37353
40663
  capScope: "system",
@@ -37360,6 +40670,18 @@ Object.freeze({
37360
40670
  addonId: null,
37361
40671
  access: "delete"
37362
40672
  },
40673
+ "backup.disableEncryption": {
40674
+ capName: "backup",
40675
+ capScope: "system",
40676
+ addonId: null,
40677
+ access: "create"
40678
+ },
40679
+ "backup.getEncryption": {
40680
+ capName: "backup",
40681
+ capScope: "system",
40682
+ addonId: null,
40683
+ access: "view"
40684
+ },
37363
40685
  "backup.getEntries": {
37364
40686
  capName: "backup",
37365
40687
  capScope: "system",
@@ -37414,6 +40736,12 @@ Object.freeze({
37414
40736
  addonId: null,
37415
40737
  access: "create"
37416
40738
  },
40739
+ "backup.setupEncryption": {
40740
+ capName: "backup",
40741
+ capScope: "system",
40742
+ addonId: null,
40743
+ access: "create"
40744
+ },
37417
40745
  "backup.trigger": {
37418
40746
  capName: "backup",
37419
40747
  capScope: "system",
@@ -37966,6 +41294,12 @@ Object.freeze({
37966
41294
  addonId: null,
37967
41295
  access: "create"
37968
41296
  },
41297
+ "customModelRegistry.importModelBundle": {
41298
+ capName: "custom-model-registry",
41299
+ capScope: "system",
41300
+ addonId: null,
41301
+ access: "create"
41302
+ },
37969
41303
  "customModelRegistry.listModels": {
37970
41304
  capName: "custom-model-registry",
37971
41305
  capScope: "system",
@@ -39376,6 +42710,108 @@ Object.freeze({
39376
42710
  addonId: null,
39377
42711
  access: "create"
39378
42712
  },
42713
+ "keychain.delete": {
42714
+ capName: "keychain",
42715
+ capScope: "system",
42716
+ addonId: null,
42717
+ access: "delete"
42718
+ },
42719
+ "keychain.getState": {
42720
+ capName: "keychain",
42721
+ capScope: "system",
42722
+ addonId: null,
42723
+ access: "view"
42724
+ },
42725
+ "keychain.listMeta": {
42726
+ capName: "keychain",
42727
+ capScope: "system",
42728
+ addonId: null,
42729
+ access: "view"
42730
+ },
42731
+ "keychain.put": {
42732
+ capName: "keychain",
42733
+ capScope: "system",
42734
+ addonId: null,
42735
+ access: "create"
42736
+ },
42737
+ "keychain.resolve": {
42738
+ capName: "keychain",
42739
+ capScope: "system",
42740
+ addonId: null,
42741
+ access: "view"
42742
+ },
42743
+ "keychainAdmin.acknowledgeReset": {
42744
+ capName: "keychain-admin",
42745
+ capScope: "system",
42746
+ addonId: null,
42747
+ access: "create"
42748
+ },
42749
+ "keychainAdmin.deleteOrphans": {
42750
+ capName: "keychain-admin",
42751
+ capScope: "system",
42752
+ addonId: null,
42753
+ access: "delete"
42754
+ },
42755
+ "keychainAdmin.downloadRecoveryKey": {
42756
+ capName: "keychain-admin",
42757
+ capScope: "system",
42758
+ addonId: null,
42759
+ access: "create"
42760
+ },
42761
+ "keychainAdmin.listAudit": {
42762
+ capName: "keychain-admin",
42763
+ capScope: "system",
42764
+ addonId: null,
42765
+ access: "view"
42766
+ },
42767
+ "keychainAdmin.listSecrets": {
42768
+ capName: "keychain-admin",
42769
+ capScope: "system",
42770
+ addonId: null,
42771
+ access: "view"
42772
+ },
42773
+ "keychainAdmin.purgeRetiredKeys": {
42774
+ capName: "keychain-admin",
42775
+ capScope: "system",
42776
+ addonId: null,
42777
+ access: "delete"
42778
+ },
42779
+ "keychainAdmin.resetKeychain": {
42780
+ capName: "keychain-admin",
42781
+ capScope: "system",
42782
+ addonId: null,
42783
+ access: "delete"
42784
+ },
42785
+ "keychainAdmin.resetReport": {
42786
+ capName: "keychain-admin",
42787
+ capScope: "system",
42788
+ addonId: null,
42789
+ access: "delete"
42790
+ },
42791
+ "keychainAdmin.reveal": {
42792
+ capName: "keychain-admin",
42793
+ capScope: "system",
42794
+ addonId: null,
42795
+ access: "create"
42796
+ },
42797
+ "keychainAdmin.rotateMasterKey": {
42798
+ capName: "keychain-admin",
42799
+ capScope: "system",
42800
+ addonId: null,
42801
+ access: "create"
42802
+ },
42803
+ "keychainAdmin.setSystemSecret": {
42804
+ capName: "keychain-admin",
42805
+ capScope: "system",
42806
+ addonId: null,
42807
+ access: "create"
42808
+ },
42809
+ "keychainAdmin.status": {
42810
+ capName: "keychain-admin",
42811
+ capScope: "system",
42812
+ addonId: null,
42813
+ access: "view"
42814
+ },
39379
42815
  "lawnMowerControl.dock": {
39380
42816
  capName: "lawn-mower-control",
39381
42817
  capScope: "device",
@@ -40606,6 +44042,36 @@ Object.freeze({
40606
44042
  addonId: null,
40607
44043
  access: "view"
40608
44044
  },
44045
+ "oidcConnections.connectionFormSchema": {
44046
+ capName: "oidc-connections",
44047
+ capScope: "system",
44048
+ addonId: null,
44049
+ access: "view"
44050
+ },
44051
+ "oidcConnections.createConnection": {
44052
+ capName: "oidc-connections",
44053
+ capScope: "system",
44054
+ addonId: null,
44055
+ access: "create"
44056
+ },
44057
+ "oidcConnections.deleteConnection": {
44058
+ capName: "oidc-connections",
44059
+ capScope: "system",
44060
+ addonId: null,
44061
+ access: "delete"
44062
+ },
44063
+ "oidcConnections.listConnections": {
44064
+ capName: "oidc-connections",
44065
+ capScope: "system",
44066
+ addonId: null,
44067
+ access: "view"
44068
+ },
44069
+ "oidcConnections.updateConnection": {
44070
+ capName: "oidc-connections",
44071
+ capScope: "system",
44072
+ addonId: null,
44073
+ access: "create"
44074
+ },
40609
44075
  "osd.getStatus": {
40610
44076
  capName: "osd",
40611
44077
  capScope: "device",
@@ -40678,6 +44144,12 @@ Object.freeze({
40678
44144
  addonId: null,
40679
44145
  access: "create"
40680
44146
  },
44147
+ "osdManager.setSlotCameraEnabled": {
44148
+ capName: "osd-manager",
44149
+ capScope: "system",
44150
+ addonId: null,
44151
+ access: "create"
44152
+ },
40681
44153
  "osdManager.upsertTemplate": {
40682
44154
  capName: "osd-manager",
40683
44155
  capScope: "system",
@@ -40750,6 +44222,18 @@ Object.freeze({
40750
44222
  addonId: null,
40751
44223
  access: "create"
40752
44224
  },
44225
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
44226
+ capName: "pipeline-analytics",
44227
+ capScope: "device",
44228
+ addonId: null,
44229
+ access: "create"
44230
+ },
44231
+ "pipelineAnalytics.addRetrainFramesToCollection": {
44232
+ capName: "pipeline-analytics",
44233
+ capScope: "device",
44234
+ addonId: null,
44235
+ access: "create"
44236
+ },
40753
44237
  "pipelineAnalytics.applyDeviceSettingsPatch": {
40754
44238
  capName: "pipeline-analytics",
40755
44239
  capScope: "device",
@@ -40798,12 +44282,24 @@ Object.freeze({
40798
44282
  addonId: null,
40799
44283
  access: "view"
40800
44284
  },
44285
+ "pipelineAnalytics.createRetrainCollection": {
44286
+ capName: "pipeline-analytics",
44287
+ capScope: "device",
44288
+ addonId: null,
44289
+ access: "create"
44290
+ },
40801
44291
  "pipelineAnalytics.deleteDeviceEvents": {
40802
44292
  capName: "pipeline-analytics",
40803
44293
  capScope: "device",
40804
44294
  addonId: null,
40805
44295
  access: "delete"
40806
44296
  },
44297
+ "pipelineAnalytics.deleteRetrainCollection": {
44298
+ capName: "pipeline-analytics",
44299
+ capScope: "device",
44300
+ addonId: null,
44301
+ access: "delete"
44302
+ },
40807
44303
  "pipelineAnalytics.deleteTracks": {
40808
44304
  capName: "pipeline-analytics",
40809
44305
  capScope: "device",
@@ -40906,6 +44402,12 @@ Object.freeze({
40906
44402
  addonId: null,
40907
44403
  access: "view"
40908
44404
  },
44405
+ "pipelineAnalytics.getRetrainCorpusKpi": {
44406
+ capName: "pipeline-analytics",
44407
+ capScope: "device",
44408
+ addonId: null,
44409
+ access: "view"
44410
+ },
40909
44411
  "pipelineAnalytics.getRetrainExportUrl": {
40910
44412
  capName: "pipeline-analytics",
40911
44413
  capScope: "device",
@@ -41008,6 +44510,30 @@ Object.freeze({
41008
44510
  addonId: null,
41009
44511
  access: "view"
41010
44512
  },
44513
+ "pipelineAnalytics.listRetrainAssistProfiles": {
44514
+ capName: "pipeline-analytics",
44515
+ capScope: "device",
44516
+ addonId: null,
44517
+ access: "view"
44518
+ },
44519
+ "pipelineAnalytics.listRetrainCollectionFrames": {
44520
+ capName: "pipeline-analytics",
44521
+ capScope: "device",
44522
+ addonId: null,
44523
+ access: "view"
44524
+ },
44525
+ "pipelineAnalytics.listRetrainCollections": {
44526
+ capName: "pipeline-analytics",
44527
+ capScope: "device",
44528
+ addonId: null,
44529
+ access: "view"
44530
+ },
44531
+ "pipelineAnalytics.listRetrainCorpusPage": {
44532
+ capName: "pipeline-analytics",
44533
+ capScope: "device",
44534
+ addonId: null,
44535
+ access: "view"
44536
+ },
41011
44537
  "pipelineAnalytics.listRetrainFrames": {
41012
44538
  capName: "pipeline-analytics",
41013
44539
  capScope: "device",
@@ -41038,6 +44564,12 @@ Object.freeze({
41038
44564
  addonId: null,
41039
44565
  access: "view"
41040
44566
  },
44567
+ "pipelineAnalytics.offerRetrainArchive": {
44568
+ capName: "pipeline-analytics",
44569
+ capScope: "device",
44570
+ addonId: null,
44571
+ access: "create"
44572
+ },
41041
44573
  "pipelineAnalytics.ownersWithMedia": {
41042
44574
  capName: "pipeline-analytics",
41043
44575
  capScope: "device",
@@ -41056,6 +44588,12 @@ Object.freeze({
41056
44588
  addonId: null,
41057
44589
  access: "create"
41058
44590
  },
44591
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
44592
+ capName: "pipeline-analytics",
44593
+ capScope: "device",
44594
+ addonId: null,
44595
+ access: "create"
44596
+ },
41059
44597
  "pipelineAnalytics.pruneEvents": {
41060
44598
  capName: "pipeline-analytics",
41061
44599
  capScope: "device",
@@ -41110,6 +44648,24 @@ Object.freeze({
41110
44648
  addonId: null,
41111
44649
  access: "create"
41112
44650
  },
44651
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
44652
+ capName: "pipeline-analytics",
44653
+ capScope: "device",
44654
+ addonId: null,
44655
+ access: "delete"
44656
+ },
44657
+ "pipelineAnalytics.renameRetrainCollection": {
44658
+ capName: "pipeline-analytics",
44659
+ capScope: "device",
44660
+ addonId: null,
44661
+ access: "create"
44662
+ },
44663
+ "pipelineAnalytics.resolveRetrainTrainingCorpus": {
44664
+ capName: "pipeline-analytics",
44665
+ capScope: "device",
44666
+ addonId: null,
44667
+ access: "view"
44668
+ },
41113
44669
  "pipelineAnalytics.restageRetrainTrack": {
41114
44670
  capName: "pipeline-analytics",
41115
44671
  capScope: "device",
@@ -41140,6 +44696,12 @@ Object.freeze({
41140
44696
  addonId: null,
41141
44697
  access: "create"
41142
44698
  },
44699
+ "pipelineAnalytics.setRetrainFrameComplete": {
44700
+ capName: "pipeline-analytics",
44701
+ capScope: "device",
44702
+ addonId: null,
44703
+ access: "create"
44704
+ },
41143
44705
  "pipelineAnalytics.setTrackFlags": {
41144
44706
  capName: "pipeline-analytics",
41145
44707
  capScope: "device",
@@ -41176,6 +44738,12 @@ Object.freeze({
41176
44738
  addonId: null,
41177
44739
  access: "delete"
41178
44740
  },
44741
+ "pipelineAnalytics.writeRetrainArchive": {
44742
+ capName: "pipeline-analytics",
44743
+ capScope: "device",
44744
+ addonId: null,
44745
+ access: "create"
44746
+ },
41179
44747
  "pipelineExecutor.cacheFrameInPool": {
41180
44748
  capName: "pipeline-executor",
41181
44749
  capScope: "system",
@@ -41386,6 +44954,12 @@ Object.freeze({
41386
44954
  addonId: null,
41387
44955
  access: "view"
41388
44956
  },
44957
+ "pipelineOrchestrator.abortNodeBenchmark": {
44958
+ capName: "pipeline-orchestrator",
44959
+ capScope: "system",
44960
+ addonId: null,
44961
+ access: "create"
44962
+ },
41389
44963
  "pipelineOrchestrator.applyAutoTune": {
41390
44964
  capName: "pipeline-orchestrator",
41391
44965
  capScope: "system",
@@ -41410,6 +44984,12 @@ Object.freeze({
41410
44984
  addonId: null,
41411
44985
  access: "create"
41412
44986
  },
44987
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
44988
+ capName: "pipeline-orchestrator",
44989
+ capScope: "system",
44990
+ addonId: null,
44991
+ access: "delete"
44992
+ },
41413
44993
  "pipelineOrchestrator.getAgentLoad": {
41414
44994
  capName: "pipeline-orchestrator",
41415
44995
  capScope: "system",
@@ -41518,6 +45098,24 @@ Object.freeze({
41518
45098
  addonId: null,
41519
45099
  access: "view"
41520
45100
  },
45101
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
45102
+ capName: "pipeline-orchestrator",
45103
+ capScope: "system",
45104
+ addonId: null,
45105
+ access: "view"
45106
+ },
45107
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
45108
+ capName: "pipeline-orchestrator",
45109
+ capScope: "system",
45110
+ addonId: null,
45111
+ access: "view"
45112
+ },
45113
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
45114
+ capName: "pipeline-orchestrator",
45115
+ capScope: "system",
45116
+ addonId: null,
45117
+ access: "view"
45118
+ },
41521
45119
  "pipelineOrchestrator.getNodeInferenceDevices": {
41522
45120
  capName: "pipeline-orchestrator",
41523
45121
  capScope: "system",
@@ -41560,6 +45158,12 @@ Object.freeze({
41560
45158
  addonId: null,
41561
45159
  access: "view"
41562
45160
  },
45161
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
45162
+ capName: "pipeline-orchestrator",
45163
+ capScope: "system",
45164
+ addonId: null,
45165
+ access: "view"
45166
+ },
41563
45167
  "pipelineOrchestrator.pauseForStorageMigration": {
41564
45168
  capName: "pipeline-orchestrator",
41565
45169
  capScope: "system",
@@ -41704,6 +45308,12 @@ Object.freeze({
41704
45308
  addonId: null,
41705
45309
  access: "create"
41706
45310
  },
45311
+ "pipelineOrchestrator.startNodeBenchmark": {
45312
+ capName: "pipeline-orchestrator",
45313
+ capScope: "system",
45314
+ addonId: null,
45315
+ access: "create"
45316
+ },
41707
45317
  "pipelineOrchestrator.suggestShares": {
41708
45318
  capName: "pipeline-orchestrator",
41709
45319
  capScope: "system",
@@ -41722,6 +45332,12 @@ Object.freeze({
41722
45332
  addonId: null,
41723
45333
  access: "create"
41724
45334
  },
45335
+ "pipelineRunner.abortNodeBench": {
45336
+ capName: "pipeline-runner",
45337
+ capScope: "system",
45338
+ addonId: null,
45339
+ access: "create"
45340
+ },
41725
45341
  "pipelineRunner.attachCamera": {
41726
45342
  capName: "pipeline-runner",
41727
45343
  capScope: "system",
@@ -41770,6 +45386,12 @@ Object.freeze({
41770
45386
  addonId: null,
41771
45387
  access: "view"
41772
45388
  },
45389
+ "pipelineRunner.getNodeBenchStatus": {
45390
+ capName: "pipeline-runner",
45391
+ capScope: "system",
45392
+ addonId: null,
45393
+ access: "view"
45394
+ },
41773
45395
  "pipelineRunner.getParkedTrackFrame": {
41774
45396
  capName: "pipeline-runner",
41775
45397
  capScope: "system",
@@ -41812,6 +45434,12 @@ Object.freeze({
41812
45434
  addonId: null,
41813
45435
  access: "create"
41814
45436
  },
45437
+ "pipelineRunner.startNodeBench": {
45438
+ capName: "pipeline-runner",
45439
+ capScope: "system",
45440
+ addonId: null,
45441
+ access: "create"
45442
+ },
41815
45443
  "plateGallery.assignPlate": {
41816
45444
  capName: "plate-gallery",
41817
45445
  capScope: "system",
@@ -43474,6 +47102,180 @@ Object.freeze({
43474
47102
  addonId: null,
43475
47103
  access: "view"
43476
47104
  },
47105
+ "training.canaryResult": {
47106
+ capName: "training",
47107
+ capScope: "system",
47108
+ addonId: null,
47109
+ access: "create"
47110
+ },
47111
+ "training.cancelJob": {
47112
+ capName: "training",
47113
+ capScope: "system",
47114
+ addonId: null,
47115
+ access: "create"
47116
+ },
47117
+ "training.discardResult": {
47118
+ capName: "training",
47119
+ capScope: "system",
47120
+ addonId: null,
47121
+ access: "create"
47122
+ },
47123
+ "training.getJob": {
47124
+ capName: "training",
47125
+ capScope: "system",
47126
+ addonId: null,
47127
+ access: "view"
47128
+ },
47129
+ "training.getJobResult": {
47130
+ capName: "training",
47131
+ capScope: "system",
47132
+ addonId: null,
47133
+ access: "view"
47134
+ },
47135
+ "training.listBaseModels": {
47136
+ capName: "training",
47137
+ capScope: "system",
47138
+ addonId: null,
47139
+ access: "view"
47140
+ },
47141
+ "training.listJobs": {
47142
+ capName: "training",
47143
+ capScope: "system",
47144
+ addonId: null,
47145
+ access: "view"
47146
+ },
47147
+ "training.planJob": {
47148
+ capName: "training",
47149
+ capScope: "system",
47150
+ addonId: null,
47151
+ access: "view"
47152
+ },
47153
+ "training.registerResult": {
47154
+ capName: "training",
47155
+ capScope: "system",
47156
+ addonId: null,
47157
+ access: "create"
47158
+ },
47159
+ "training.rollbackCanary": {
47160
+ capName: "training",
47161
+ capScope: "system",
47162
+ addonId: null,
47163
+ access: "create"
47164
+ },
47165
+ "training.startJob": {
47166
+ capName: "training",
47167
+ capScope: "system",
47168
+ addonId: null,
47169
+ access: "create"
47170
+ },
47171
+ "training.startJobBatch": {
47172
+ capName: "training",
47173
+ capScope: "system",
47174
+ addonId: null,
47175
+ access: "create"
47176
+ },
47177
+ "trainingProvider.cancelJob": {
47178
+ capName: "training-provider",
47179
+ capScope: "system",
47180
+ addonId: null,
47181
+ access: "create"
47182
+ },
47183
+ "trainingProvider.cleanupJob": {
47184
+ capName: "training-provider",
47185
+ capScope: "system",
47186
+ addonId: null,
47187
+ access: "create"
47188
+ },
47189
+ "trainingProvider.createEntry": {
47190
+ capName: "training-provider",
47191
+ capScope: "system",
47192
+ addonId: null,
47193
+ access: "create"
47194
+ },
47195
+ "trainingProvider.deleteEntry": {
47196
+ capName: "training-provider",
47197
+ capScope: "system",
47198
+ addonId: null,
47199
+ access: "delete"
47200
+ },
47201
+ "trainingProvider.describe": {
47202
+ capName: "training-provider",
47203
+ capScope: "system",
47204
+ addonId: null,
47205
+ access: "view"
47206
+ },
47207
+ "trainingProvider.describeTypes": {
47208
+ capName: "training-provider",
47209
+ capScope: "system",
47210
+ addonId: null,
47211
+ access: "view"
47212
+ },
47213
+ "trainingProvider.estimateJob": {
47214
+ capName: "training-provider",
47215
+ capScope: "system",
47216
+ addonId: null,
47217
+ access: "view"
47218
+ },
47219
+ "trainingProvider.getJob": {
47220
+ capName: "training-provider",
47221
+ capScope: "system",
47222
+ addonId: null,
47223
+ access: "view"
47224
+ },
47225
+ "trainingProvider.listEntries": {
47226
+ capName: "training-provider",
47227
+ capScope: "system",
47228
+ addonId: null,
47229
+ access: "view"
47230
+ },
47231
+ "trainingProvider.listJobEvents": {
47232
+ capName: "training-provider",
47233
+ capScope: "system",
47234
+ addonId: null,
47235
+ access: "view"
47236
+ },
47237
+ "trainingProvider.listJobs": {
47238
+ capName: "training-provider",
47239
+ capScope: "system",
47240
+ addonId: null,
47241
+ access: "view"
47242
+ },
47243
+ "trainingProvider.offerArtifact": {
47244
+ capName: "training-provider",
47245
+ capScope: "system",
47246
+ addonId: null,
47247
+ access: "create"
47248
+ },
47249
+ "trainingProvider.readResult": {
47250
+ capName: "training-provider",
47251
+ capScope: "system",
47252
+ addonId: null,
47253
+ access: "create"
47254
+ },
47255
+ "trainingProvider.submitJob": {
47256
+ capName: "training-provider",
47257
+ capScope: "system",
47258
+ addonId: null,
47259
+ access: "create"
47260
+ },
47261
+ "trainingProvider.updateEntry": {
47262
+ capName: "training-provider",
47263
+ capScope: "system",
47264
+ addonId: null,
47265
+ access: "create"
47266
+ },
47267
+ "trainingProvider.uploadDataset": {
47268
+ capName: "training-provider",
47269
+ capScope: "system",
47270
+ addonId: null,
47271
+ access: "create"
47272
+ },
47273
+ "trainingProvider.validateCredentials": {
47274
+ capName: "training-provider",
47275
+ capScope: "system",
47276
+ addonId: null,
47277
+ access: "create"
47278
+ },
43477
47279
  "turnProvider.getTurnServers": {
43478
47280
  capName: "turn-provider",
43479
47281
  capScope: "system",
@@ -43498,12 +47300,6 @@ Object.freeze({
43498
47300
  addonId: null,
43499
47301
  access: "create"
43500
47302
  },
43501
- "userManagement.createApiKey": {
43502
- capName: "user-management",
43503
- capScope: "system",
43504
- addonId: null,
43505
- access: "create"
43506
- },
43507
47303
  "userManagement.createScopedToken": {
43508
47304
  capName: "user-management",
43509
47305
  capScope: "system",
@@ -43528,6 +47324,12 @@ Object.freeze({
43528
47324
  addonId: null,
43529
47325
  access: "delete"
43530
47326
  },
47327
+ "userManagement.findUserByExternalIdentity": {
47328
+ capName: "user-management",
47329
+ capScope: "system",
47330
+ addonId: null,
47331
+ access: "view"
47332
+ },
43531
47333
  "userManagement.getTotpStatus": {
43532
47334
  capName: "user-management",
43533
47335
  capScope: "system",
@@ -43540,6 +47342,12 @@ Object.freeze({
43540
47342
  addonId: null,
43541
47343
  access: "view"
43542
47344
  },
47345
+ "userManagement.listExternalIdentities": {
47346
+ capName: "user-management",
47347
+ capScope: "system",
47348
+ addonId: null,
47349
+ access: "view"
47350
+ },
43543
47351
  "userManagement.listOauthSessions": {
43544
47352
  capName: "user-management",
43545
47353
  capScope: "system",
@@ -43618,17 +47426,17 @@ Object.freeze({
43618
47426
  addonId: null,
43619
47427
  access: "create"
43620
47428
  },
43621
- "userManagement.updateUser": {
47429
+ "userManagement.unlinkExternalIdentity": {
43622
47430
  capName: "user-management",
43623
47431
  capScope: "system",
43624
47432
  addonId: null,
43625
- access: "create"
47433
+ access: "delete"
43626
47434
  },
43627
- "userManagement.validateApiKey": {
47435
+ "userManagement.updateUser": {
43628
47436
  capName: "user-management",
43629
47437
  capScope: "system",
43630
47438
  addonId: null,
43631
- access: "view"
47439
+ access: "create"
43632
47440
  },
43633
47441
  "userManagement.validateCredentials": {
43634
47442
  capName: "user-management",
@@ -46662,6 +50470,11 @@ Object.freeze({
46662
50470
  form: "single",
46663
50471
  optional: false
46664
50472
  }],
50473
+ "osdManager.setSlotCameraEnabled": [{
50474
+ name: "deviceId",
50475
+ form: "single",
50476
+ optional: false
50477
+ }],
46665
50478
  "petFeeder.callPet": [{
46666
50479
  name: "deviceId",
46667
50480
  form: "single",
@@ -46717,6 +50530,11 @@ Object.freeze({
46717
50530
  form: "single",
46718
50531
  optional: false
46719
50532
  }],
50533
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
50534
+ name: "deviceId",
50535
+ form: "single",
50536
+ optional: false
50537
+ }],
46720
50538
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
46721
50539
  name: "deviceId",
46722
50540
  form: "single",
@@ -46877,6 +50695,11 @@ Object.freeze({
46877
50695
  form: "array",
46878
50696
  optional: false
46879
50697
  }],
50698
+ "pipelineAnalytics.listRetrainCorpusPage": [{
50699
+ name: "deviceIds",
50700
+ form: "array",
50701
+ optional: true
50702
+ }],
46880
50703
  "pipelineAnalytics.listRetrainStaging": [{
46881
50704
  name: "deviceIds",
46882
50705
  form: "array",
@@ -46907,6 +50730,11 @@ Object.freeze({
46907
50730
  form: "single",
46908
50731
  optional: false
46909
50732
  }],
50733
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
50734
+ name: "deviceId",
50735
+ form: "single",
50736
+ optional: false
50737
+ }],
46910
50738
  "pipelineAnalytics.pruneEventsBefore": [{
46911
50739
  name: "deviceId",
46912
50740
  form: "single",
@@ -46957,6 +50785,11 @@ Object.freeze({
46957
50785
  form: "single",
46958
50786
  optional: false
46959
50787
  }],
50788
+ "pipelineAnalytics.setRetrainFrameComplete": [{
50789
+ name: "deviceId",
50790
+ form: "single",
50791
+ optional: false
50792
+ }],
46960
50793
  "pipelineAnalytics.setTrackFlags": [{
46961
50794
  name: "deviceId",
46962
50795
  form: "single",
@@ -47728,6 +51561,11 @@ Object.freeze({
47728
51561
  form: "single",
47729
51562
  optional: false
47730
51563
  }],
51564
+ "training.canaryResult": [{
51565
+ name: "deviceIds",
51566
+ form: "array",
51567
+ optional: false
51568
+ }],
47731
51569
  "update.getStatus": [{
47732
51570
  name: "deviceId",
47733
51571
  form: "single",
@@ -47971,6 +51809,7 @@ Object.freeze({
47971
51809
  });
47972
51810
  Object.freeze({
47973
51811
  "broker": "broker",
51812
+ "calendar-source": "calendar",
47974
51813
  "device-export": "device-export",
47975
51814
  "llm": "ai",
47976
51815
  "mesh-network": "mesh",
@@ -48456,6 +52295,8 @@ var STATE_SUMMARY_VARS = [
48456
52295
  [...RULE_TEXT],
48457
52296
  [...RULE_TEXT],
48458
52297
  [...RULE_TEXT],
52298
+ [...RULE_TEXT],
52299
+ [...RULE_TEXT],
48459
52300
  ([...RULE_TEXT], [...UPDATES]),
48460
52301
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),
48461
52302
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),