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