@camstack/addon-decoder-nodeav 1.2.120 → 1.2.122

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 +3734 -113
  2. package/dist/index.mjs +3734 -113
  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-r3RWkGVx.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,
@@ -8721,6 +9811,278 @@ var CameraSwitchGroupSchema = object({
8721
9811
  fetchedAt: number()
8722
9812
  });
8723
9813
  /**
9814
+ * The trainer contract — what the hub hands the cloud trainer and what it
9815
+ * gets back (cloud training, D805+).
9816
+ *
9817
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9818
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9819
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9820
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9821
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9822
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9823
+ * change there, in the same piece of work.
9824
+ *
9825
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9826
+ * orchestrator fills every field of a job spec explicitly.
9827
+ */
9828
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9829
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9830
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9831
+ var TrainingExportSchema = _enum([
9832
+ "onnx",
9833
+ "openvino-fp16",
9834
+ "openvino-int8",
9835
+ "coreml-fp16"
9836
+ ]);
9837
+ var FloorsSchema = record(string(), number().min(0).max(1));
9838
+ object({
9839
+ schema: literal(TRAINING_JOB_SCHEMA),
9840
+ jobKey: string().uuid(),
9841
+ target: object({
9842
+ kind: literal("detector"),
9843
+ step: literal("object-detection")
9844
+ }),
9845
+ base: object({
9846
+ modelId: string().min(1),
9847
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9848
+ weights: string().min(1),
9849
+ imgsz: number().int().positive()
9850
+ }),
9851
+ baseline: object({
9852
+ modelId: string().min(1),
9853
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9854
+ onnxUrl: string().url(),
9855
+ imgsz: number().int().positive(),
9856
+ floors: FloorsSchema
9857
+ }),
9858
+ dataset: object({
9859
+ versionId: string().min(1),
9860
+ annotationHash: string(),
9861
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9862
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9863
+ }),
9864
+ split: object({
9865
+ holdoutCameras: array(number().int()),
9866
+ /** When no camera is held out: the last N days of every camera. */
9867
+ holdoutLastDays: number().int().nonnegative(),
9868
+ valFraction: number().min(0).max(.5),
9869
+ seed: number().int()
9870
+ }),
9871
+ hyper: object({
9872
+ epochs: number().int().positive(),
9873
+ batch: number().int().positive(),
9874
+ lr0: number().positive(),
9875
+ /** Layers frozen from the start of the backbone; 0 = none. */
9876
+ freeze: number().int().nonnegative(),
9877
+ patience: number().int().nonnegative(),
9878
+ seed: number().int()
9879
+ }),
9880
+ replay: object({
9881
+ source: literal("coco2017"),
9882
+ count: number().int().nonnegative()
9883
+ }),
9884
+ exports: array(TrainingExportSchema).min(1),
9885
+ calibration: object({ maxFrames: number().int().positive() }),
9886
+ floors: object({
9887
+ minSupport: number().int().positive(),
9888
+ clamp: number().min(0).max(1)
9889
+ }),
9890
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9891
+ catalog: object({
9892
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9893
+ name: string().min(1).max(160)
9894
+ })
9895
+ });
9896
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9897
+ var TrainingResultFileSchema = object({
9898
+ path: string().min(1),
9899
+ bytes: number().int().nonnegative(),
9900
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9901
+ format: _enum([
9902
+ "onnx",
9903
+ "openvino",
9904
+ "coreml",
9905
+ "pt"
9906
+ ]),
9907
+ variant: _enum(["base", "int8"])
9908
+ });
9909
+ var DraftFormatSchema = object({
9910
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9911
+ url: string().min(1),
9912
+ sizeMB: number().nonnegative(),
9913
+ isDirectory: boolean().optional(),
9914
+ files: array(string()).optional(),
9915
+ runtimes: array(literal("python")).optional(),
9916
+ revision: string().min(1)
9917
+ });
9918
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9919
+ var TrainingCatalogDraftSchema = object({
9920
+ id: string().min(1),
9921
+ name: string().min(1),
9922
+ description: string(),
9923
+ labels: array(unknown()),
9924
+ inputSize: object({
9925
+ width: number().int().positive(),
9926
+ height: number().int().positive()
9927
+ }),
9928
+ preprocessMode: literal("letterbox"),
9929
+ defaultClassFloors: FloorsSchema,
9930
+ formats: object({
9931
+ onnx: DraftFormatSchema.optional(),
9932
+ openvino: DraftFormatSchema.optional(),
9933
+ coreml: DraftFormatSchema.optional()
9934
+ })
9935
+ });
9936
+ /** One class of one model's holdout report (the eval harness's summary). */
9937
+ var TrainingEvalClassSchema = object({
9938
+ positives: number().int(),
9939
+ floor: number().nullable(),
9940
+ tp: number().int(),
9941
+ fp: number().int(),
9942
+ fn: number().int(),
9943
+ precision: number().nullable(),
9944
+ recall: number().nullable(),
9945
+ ap50: number().nullable(),
9946
+ recallByCamera: record(string(), number().nullable()).optional(),
9947
+ recallByLight: record(string(), number().nullable()).optional(),
9948
+ fpByCamera: record(string(), number()).optional(),
9949
+ smallFound: number().int().optional(),
9950
+ smallTotal: number().int().optional()
9951
+ }).passthrough();
9952
+ var TrainingEvalReportSchema = object({
9953
+ frames: number().int(),
9954
+ classes: record(string(), TrainingEvalClassSchema)
9955
+ }).passthrough();
9956
+ /**
9957
+ * A succeeded result carries every block; a failed one carries the error and
9958
+ * whatever was known by then — the other blocks are ABSENT, not null. The
9959
+ * orchestrator checks the blocks it needs before it trusts a success.
9960
+ */
9961
+ var TrainingResultSchema = object({
9962
+ schema: literal(TRAINING_RESULT_SCHEMA),
9963
+ jobKey: string(),
9964
+ status: _enum(["succeeded", "failed"]),
9965
+ error: object({
9966
+ stage: string(),
9967
+ code: string(),
9968
+ message: string()
9969
+ }).nullable(),
9970
+ trainer: object({
9971
+ version: string(),
9972
+ revision: string()
9973
+ }),
9974
+ toolchain: record(string(), string().nullable()),
9975
+ dataset: object({
9976
+ versionId: string(),
9977
+ annotationHash: string(),
9978
+ sha256: string(),
9979
+ frames: object({
9980
+ train: number().int(),
9981
+ val: number().int(),
9982
+ holdout: number().int()
9983
+ }),
9984
+ holdoutCameras: array(number().int()),
9985
+ replayImages: number().int()
9986
+ }).optional(),
9987
+ training: object({
9988
+ epochsRun: number().int(),
9989
+ bestEpoch: number().int(),
9990
+ bestMap50: number(),
9991
+ bestMap50_95: number(),
9992
+ seconds: number()
9993
+ }).optional(),
9994
+ evaluation: object({
9995
+ holdoutFrames: number().int(),
9996
+ baseline: TrainingEvalReportSchema.nullable(),
9997
+ candidate: TrainingEvalReportSchema.nullable(),
9998
+ candidateInt8: TrainingEvalReportSchema.nullable(),
9999
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10000
+ map50: record(string(), number().nullable())
10001
+ }).optional(),
10002
+ floors: object({
10003
+ baseline: FloorsSchema,
10004
+ candidate: FloorsSchema,
10005
+ candidateInt8: FloorsSchema.nullable(),
10006
+ notes: array(string())
10007
+ }).optional(),
10008
+ int8: object({
10009
+ kept: boolean(),
10010
+ map50Fp16: number().nullable(),
10011
+ map50Int8: number().nullable(),
10012
+ reason: string().nullable()
10013
+ }).optional(),
10014
+ exportsDropped: array(object({
10015
+ export: string(),
10016
+ reason: string()
10017
+ })).optional(),
10018
+ files: array(TrainingResultFileSchema).optional(),
10019
+ bundle: object({
10020
+ path: literal("bundle.tar"),
10021
+ bytes: number().int().nonnegative(),
10022
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10023
+ }).nullable().optional(),
10024
+ catalogDraft: object({
10025
+ base: TrainingCatalogDraftSchema,
10026
+ int8: TrainingCatalogDraftSchema.nullable()
10027
+ }).nullable().optional(),
10028
+ licence: string()
10029
+ });
10030
+ var TrainingStageSchema = _enum([
10031
+ "prepare",
10032
+ "replay",
10033
+ "train",
10034
+ "eval",
10035
+ "export",
10036
+ "package"
10037
+ ]);
10038
+ var EventBase = {
10039
+ v: literal(1),
10040
+ ts: number()
10041
+ };
10042
+ discriminatedUnion("type", [
10043
+ object({
10044
+ ...EventBase,
10045
+ type: literal("stage"),
10046
+ stage: TrainingStageSchema
10047
+ }),
10048
+ object({
10049
+ ...EventBase,
10050
+ type: literal("epoch"),
10051
+ epoch: number().int(),
10052
+ epochs: number().int(),
10053
+ boxLoss: number().nullable().optional(),
10054
+ map50: number().nullable().optional(),
10055
+ map50_95: number().nullable().optional(),
10056
+ etaSec: number().nullable().optional()
10057
+ }),
10058
+ object({
10059
+ ...EventBase,
10060
+ type: literal("metric"),
10061
+ name: string(),
10062
+ value: number()
10063
+ }),
10064
+ object({
10065
+ ...EventBase,
10066
+ type: literal("artifact"),
10067
+ path: string(),
10068
+ bytes: number(),
10069
+ sha256: string()
10070
+ }),
10071
+ object({
10072
+ ...EventBase,
10073
+ type: literal("done"),
10074
+ status: _enum(["succeeded", "failed"]),
10075
+ resultSha256: string().nullable().optional()
10076
+ }),
10077
+ object({
10078
+ ...EventBase,
10079
+ type: literal("error"),
10080
+ stage: string(),
10081
+ code: string(),
10082
+ message: string()
10083
+ })
10084
+ ]);
10085
+ /**
8724
10086
  * What the gate decided about a birth, from the CALLER's point of view.
8725
10087
  *
8726
10088
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11048,7 +12410,9 @@ var AddonHttpRouteSchema = object({
11048
12410
  "authenticated",
11049
12411
  "admin"
11050
12412
  ]).optional(),
11051
- description: string().optional()
12413
+ description: string().optional(),
12414
+ /** The hub limits this route per client address before the handler runs. */
12415
+ rateLimit: _enum(["auth"]).optional()
11052
12416
  });
11053
12417
  /**
11054
12418
  * Cross-process route invocation envelope. The hub captures the
@@ -11790,6 +13154,37 @@ var BackupDestinationInfoSchema = object({
11790
13154
  lastError: string().optional()
11791
13155
  });
11792
13156
  /**
13157
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13158
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13159
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13160
+ * with it off — which restores without a key.
13161
+ */
13162
+ var BackupArchiveEncryptionSchema = object({
13163
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13164
+ scheme: string(),
13165
+ /** 16 hex — the backup key whose secret restores this archive. */
13166
+ keyId: string()
13167
+ });
13168
+ /**
13169
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13170
+ * one new archives are encrypted to, and the retired ones older archives
13171
+ * still need. The secret key is shown once, at `setupEncryption`.
13172
+ */
13173
+ var BackupEncryptionStatusSchema = object({
13174
+ enabled: boolean(),
13175
+ active: object({
13176
+ keyId: string(),
13177
+ publicKey: string(),
13178
+ createdAt: number()
13179
+ }).nullable(),
13180
+ /** Every key ever set up, newest first. */
13181
+ keys: array(object({
13182
+ keyId: string(),
13183
+ createdAt: number(),
13184
+ retiredAt: number().nullable()
13185
+ })).readonly()
13186
+ });
13187
+ /**
11793
13188
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
11794
13189
  * Same shape the destination drill-in renders. Sourced from the per-
11795
13190
  * location `manifests.json` (no per-archive tarball read required).
@@ -11801,7 +13196,9 @@ var BackupArchiveEntrySchema = object({
11801
13196
  sizeBytes: number(),
11802
13197
  label: string().optional(),
11803
13198
  /** Top-level locations included in the archive (db, addons, tls, …). */
11804
- locations: array(string()).readonly()
13199
+ locations: array(string()).readonly(),
13200
+ /** Present when the archive is encrypted; restore then needs that key. */
13201
+ encryption: BackupArchiveEncryptionSchema.optional()
11805
13202
  });
11806
13203
  var BackupEntrySchema = object({
11807
13204
  id: string(),
@@ -11810,7 +13207,8 @@ var BackupEntrySchema = object({
11810
13207
  label: string().optional(),
11811
13208
  createdAt: number(),
11812
13209
  sizeBytes: number(),
11813
- locations: array(string()).optional()
13210
+ locations: array(string()).optional(),
13211
+ encryption: BackupArchiveEncryptionSchema.optional()
11814
13212
  });
11815
13213
  var ArchiveEntrySchema = object({
11816
13214
  path: string(),
@@ -11999,10 +13397,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
11999
13397
  * this list and skips entries whose path doesn't start with
12000
13398
  * any of them.
12001
13399
  */
12002
- locations: array(string()).optional()
13400
+ locations: array(string()).optional(),
13401
+ /**
13402
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13403
+ * one). The archive is decrypted into the hub's private staging
13404
+ * before the restart; the key is not stored. A wrong or missing key
13405
+ * is refused before the archive is downloaded.
13406
+ */
13407
+ backupSecretKey: string().optional()
12003
13408
  }), _void(), {
12004
13409
  kind: "mutation",
12005
13410
  auth: "admin"
13411
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13412
+ keyId: string(),
13413
+ secretKey: string(),
13414
+ publicKey: string(),
13415
+ createdAt: number(),
13416
+ replacedKeyId: string().nullable()
13417
+ }), {
13418
+ kind: "mutation",
13419
+ auth: "admin"
13420
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13421
+ kind: "mutation",
13422
+ auth: "admin"
13423
+ }), method(object({ backupSecretKey: string() }), object({
13424
+ valid: boolean(),
13425
+ keyId: string().nullable(),
13426
+ /** The hub knows this key (active or retired). */
13427
+ known: boolean(),
13428
+ /** It is the key new archives are encrypted to. */
13429
+ active: boolean(),
13430
+ error: string().optional()
13431
+ }), {
13432
+ kind: "mutation",
13433
+ auth: "admin"
12006
13434
  }), method(object({
12007
13435
  destinationId: string(),
12008
13436
  backupId: string()
@@ -13626,7 +15054,60 @@ var CustomModelDescriptorSchema = object({
13626
15054
  stepId: string(),
13627
15055
  entry: ModelCatalogEntrySchema
13628
15056
  });
13629
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15057
+ /** One regular file of an imported bundle, as the producer measured it. */
15058
+ var ModelBundleFileSchema = object({
15059
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15060
+ path: string().min(1),
15061
+ bytes: number().int().nonnegative(),
15062
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15063
+ });
15064
+ var ImportModelBundleInputSchema = object({
15065
+ /** The registry provider that keeps the model (Model Studio). */
15066
+ addonId: string(),
15067
+ stepId: string().min(1),
15068
+ /**
15069
+ * The catalog rows to register, complete, every format URL already
15070
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15071
+ * bundle may carry several rows (a base and its INT8 variant).
15072
+ */
15073
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15074
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15075
+ bundle: object({
15076
+ ticket: PeerBytesTicketSchema,
15077
+ bytes: number().int().positive(),
15078
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15079
+ }),
15080
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15081
+ files: array(ModelBundleFileSchema).min(1).max(64),
15082
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15083
+ distribute: boolean()
15084
+ });
15085
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15086
+ kind: literal("imported"),
15087
+ modelIds: array(string()).readonly(),
15088
+ distributed: array(object({
15089
+ modelId: string(),
15090
+ nodeId: string(),
15091
+ format: _enum(MODEL_FORMATS),
15092
+ ok: boolean(),
15093
+ error: string().optional()
15094
+ })).readonly()
15095
+ }), object({
15096
+ kind: literal("refused"),
15097
+ reason: _enum([
15098
+ "transfer-failed",
15099
+ "checksum-mismatch",
15100
+ "bundle-mismatch",
15101
+ "invalid-entry",
15102
+ "id-taken"
15103
+ ]),
15104
+ detail: string()
15105
+ })]);
15106
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15107
+ kind: "mutation",
15108
+ auth: "admin",
15109
+ timeoutMs: 30 * 6e4
15110
+ });
13630
15111
  /**
13631
15112
  * Query filter for settings-store collections.
13632
15113
  */
@@ -14010,6 +15491,253 @@ id: union([string(), number()]) }), {
14010
15491
  auth: "admin"
14011
15492
  });
14012
15493
  /**
15494
+ * `keychain` — the hub's encrypted store of secret values (D787).
15495
+ *
15496
+ * Settings blobs never hold a secret: they hold a marker
15497
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15498
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15499
+ * is the OWNER's door to its own values: every method is owner-checked
15500
+ * against the CALLER, never against anything the caller claims.
15501
+ *
15502
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15503
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15504
+ * connection, the agent from its child's connection carried in
15505
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15506
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15507
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15508
+ * identity against BUGS and misrouting, not against a malicious addon (every
15509
+ * runner is the same OS user): see the threat model in
15510
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15511
+ *
15512
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15513
+ * parses the input, so a session can never supply it, and the internal mount
15514
+ * floors every method to admin anyway (D240).
15515
+ *
15516
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15517
+ */
15518
+ /** Why a value cannot be served right now. Never folded into "missing". */
15519
+ var KeychainUnavailableReasonSchema = _enum([
15520
+ "key-missing",
15521
+ "wrong-key",
15522
+ "key-file-unreadable",
15523
+ "store-unavailable",
15524
+ "not-initialized",
15525
+ "decrypt-failed"
15526
+ ]);
15527
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15528
+ state: literal("locked"),
15529
+ reason: KeychainUnavailableReasonSchema
15530
+ })]);
15531
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15532
+ object({
15533
+ kind: literal("value"),
15534
+ value: string(),
15535
+ version: number().int()
15536
+ }),
15537
+ object({ kind: literal("missing") }),
15538
+ object({
15539
+ kind: literal("unavailable"),
15540
+ reason: KeychainUnavailableReasonSchema
15541
+ }),
15542
+ object({ kind: literal("forbidden") })
15543
+ ]);
15544
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15545
+ /** Metadata of one stored value — never the value. */
15546
+ var KeychainSecretMetaSchema = object({
15547
+ ref: string(),
15548
+ owner: string(),
15549
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15550
+ scope: string(),
15551
+ fieldPath: string(),
15552
+ version: number().int(),
15553
+ createdAt: number(),
15554
+ updatedAt: number(),
15555
+ /** `addon:<id>` | `user:<id>` | `system`. */
15556
+ updatedBy: string(),
15557
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15558
+ lastReadAt: number().nullable()
15559
+ });
15560
+ var RefListSchema = array(string().min(1)).max(512);
15561
+ method(object({
15562
+ ref: string().min(1),
15563
+ value: string().min(1)
15564
+ }), object({
15565
+ ref: string(),
15566
+ version: number().int()
15567
+ }), {
15568
+ kind: "mutation",
15569
+ auth: "admin"
15570
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15571
+ kind: "mutation",
15572
+ auth: "admin"
15573
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15574
+ var KeychainKeySourceSchema = object({
15575
+ kind: _enum([
15576
+ "config-file",
15577
+ "previous-config-file",
15578
+ "platform",
15579
+ "default-file"
15580
+ ]),
15581
+ /** File sources only — a path is not a secret. */
15582
+ path: string().optional(),
15583
+ /**
15584
+ * True when a whole-volume backup of the data directory carries this key
15585
+ * next to the database it protects (the default file). The page warns.
15586
+ */
15587
+ sharesBackupWithDatabase: boolean()
15588
+ });
15589
+ /**
15590
+ * One keychain reset, as the Secrets page reports it until the operator
15591
+ * acknowledges it. Never a value: refs, counts and table names only.
15592
+ */
15593
+ var KeychainResetRecordSchema = object({
15594
+ id: string(),
15595
+ at: number(),
15596
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15597
+ actor: string(),
15598
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15599
+ lockedReason: string().nullable(),
15600
+ /** Values moved into the archive table (ciphertext under the lost key). */
15601
+ archived: number().int(),
15602
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15603
+ archivedCollection: string().nullable(),
15604
+ /**
15605
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15606
+ * so the archive can still be opened if the lost master key turns up.
15607
+ */
15608
+ archivedKeysCollection: string().nullable(),
15609
+ /**
15610
+ * `system-settings` keys whose marker the reset cleared — the cluster
15611
+ * secret's: a marker left pointing at an archived value would refuse every
15612
+ * agent forever (D797).
15613
+ */
15614
+ clearedSettingsKeys: array(string()).readonly(),
15615
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15616
+ acknowledgedAt: number().nullable()
15617
+ });
15618
+ var KeychainStatusSchema = object({
15619
+ keychain: KeychainStateSchema,
15620
+ /** The source of the master key in use; `null` while locked. */
15621
+ keySource: KeychainKeySourceSchema.nullable(),
15622
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15623
+ configuredSource: KeychainKeySourceSchema,
15624
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15625
+ fingerprint: string().nullable(),
15626
+ activeKeyId: string().nullable(),
15627
+ /**
15628
+ * The keychain unlocked with a NON-primary source: the configured primary
15629
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15630
+ */
15631
+ rotationPending: boolean(),
15632
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15633
+ retiredWraps: number().int(),
15634
+ recoveryKeyDownloadedAt: number().nullable(),
15635
+ secretCount: number().int(),
15636
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15637
+ lastReset: KeychainResetRecordSchema.nullable()
15638
+ });
15639
+ /**
15640
+ * Whether a stored value is still pointed at by its owner's settings.
15641
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15642
+ * never reported as an orphan (and never deleted as one).
15643
+ */
15644
+ var KeychainSecretUsageSchema = _enum([
15645
+ "in-use",
15646
+ "orphan",
15647
+ "unknown"
15648
+ ]);
15649
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15650
+ var KeychainAuditActionSchema = _enum([
15651
+ "put",
15652
+ "delete",
15653
+ "reveal",
15654
+ "rotate-master-key",
15655
+ "purge-retired-keys",
15656
+ "download-recovery-key",
15657
+ "delete-orphans",
15658
+ "reset",
15659
+ "acknowledge-reset",
15660
+ "initialize"
15661
+ ]);
15662
+ var KeychainAuditEntrySchema = object({
15663
+ id: string(),
15664
+ at: number(),
15665
+ action: KeychainAuditActionSchema,
15666
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15667
+ actor: string(),
15668
+ ref: string().nullable(),
15669
+ detail: string().nullable()
15670
+ });
15671
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15672
+ /**
15673
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15674
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15675
+ * never an orphan; it is generated on a fresh hub and replaced only through
15676
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15677
+ */
15678
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15679
+ 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({
15680
+ value: string(),
15681
+ version: number().int()
15682
+ }), {
15683
+ kind: "mutation",
15684
+ auth: "admin",
15685
+ caller: "required"
15686
+ }), method(object({
15687
+ name: SystemHeldSecretNameSchema,
15688
+ value: string().min(16)
15689
+ }), object({
15690
+ ref: string(),
15691
+ version: number().int()
15692
+ }), {
15693
+ kind: "mutation",
15694
+ auth: "admin",
15695
+ caller: "required"
15696
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15697
+ deleted: array(string()).readonly(),
15698
+ kept: array(object({
15699
+ ref: string(),
15700
+ usage: KeychainSecretUsageSchema
15701
+ })).readonly()
15702
+ }), {
15703
+ kind: "mutation",
15704
+ auth: "admin",
15705
+ caller: "required"
15706
+ }), method(object({}), object({
15707
+ fingerprint: string(),
15708
+ keySource: KeychainKeySourceSchema
15709
+ }), {
15710
+ kind: "mutation",
15711
+ auth: "admin",
15712
+ caller: "required"
15713
+ }), method(object({}), object({ purged: number().int() }), {
15714
+ kind: "mutation",
15715
+ auth: "admin",
15716
+ caller: "required"
15717
+ }), method(object({}), object({
15718
+ key: string(),
15719
+ fingerprint: string(),
15720
+ keySource: KeychainKeySourceSchema
15721
+ }), {
15722
+ kind: "mutation",
15723
+ auth: "admin",
15724
+ caller: "required"
15725
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15726
+ archivedCollection: string().nullable(),
15727
+ archived: number().int()
15728
+ }), {
15729
+ kind: "mutation",
15730
+ auth: "admin",
15731
+ caller: "required"
15732
+ }), method(object({}), object({
15733
+ reset: KeychainResetRecordSchema.nullable(),
15734
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15735
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15736
+ kind: "mutation",
15737
+ auth: "admin",
15738
+ caller: "required"
15739
+ });
15740
+ /**
14013
15741
  * Stable UI option list for the `hwaccel` setting. Decoder addons
14014
15742
  * reuse this for `globalSettingsSchema()` so the dropdown is
14015
15743
  * identical everywhere. Order: auto → off → common backends by
@@ -14907,6 +16635,10 @@ var DeviceInfoSchema = object({
14907
16635
  isCamera: boolean(),
14908
16636
  /** Current config values — serializable snapshot */
14909
16637
  config: record(string(), unknown()),
16638
+ /** Paths inside `config` the device's schema declares secret (D783) —
16639
+ * what the non-admin redaction withholds. Paths, never values. Absent
16640
+ * when the owning runner has not reported them. */
16641
+ secretConfigPaths: array(string()).optional(),
14910
16642
  /** Hardware + identity blob (manufacturer / model / firmware / sn /
14911
16643
  * uid / mac / …). Populated by drivers; editable via setMetadata. */
14912
16644
  metadata: record(string(), unknown()).nullable().optional(),
@@ -15112,12 +16844,22 @@ var DeviceRegisterPayloadSchema = object({
15112
16844
  * call (workers re-register on init), so probe-driven updates
15113
16845
  * (e.g. PTZ flag flipping after the abilities probe) propagate. */
15114
16846
  features: array(string()).optional(),
15115
- config: record(string(), unknown())
16847
+ config: record(string(), unknown()),
16848
+ /** Config paths the device's own schema DECLARES secret
16849
+ * (`.meta({ secret: true })` — dotted, `[]` for array items, e.g.
16850
+ * `connection.password`). Re-published on every register; the non-admin
16851
+ * redaction withholds them at any depth (D783). Optional: an older runner
16852
+ * omits it and the keyword backstop applies. */
16853
+ secretConfigPaths: array(string()).optional()
15116
16854
  });
15117
16855
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15118
16856
  var DevicePersistConfigPayloadSchema = object({
15119
16857
  deviceId: number(),
15120
- data: record(string(), unknown())
16858
+ data: record(string(), unknown()),
16859
+ /** The paths the device's schema declares secret (D783), when the caller
16860
+ * knows them — those values are kept in the keychain, not the blob (D787).
16861
+ * Absent: the paths the device last reported at `registerDevice` apply. */
16862
+ secretConfigPaths: array(string()).optional()
15121
16863
  });
15122
16864
  /** What a migration actually did, per switch. `unreachable` is a first-class
15123
16865
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -16720,7 +18462,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16720
18462
  * `login-method` — collection cap through which auth addons contribute
16721
18463
  * their pre-auth login surfaces to the login page. This is the SINGLE,
16722
18464
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
16723
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18465
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
16724
18466
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16725
18467
  * procedure aggregates them for the unauthenticated login page.
16726
18468
  *
@@ -16728,8 +18470,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16728
18470
  *
16729
18471
  * - `redirect` — a declarative button. The login page renders a generic
16730
18472
  * 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
18473
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
16733
18474
  * login page needs NO change.
16734
18475
  *
16735
18476
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -16748,8 +18489,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16748
18489
  * decision.
16749
18490
  *
16750
18491
  * Every contribution carries a `stage`:
16751
- * - `primary` — shown on the first credentials screen (OIDC /
16752
- * magic-link buttons; a future usernameless passkey).
18492
+ * - `primary` — shown on the first credentials screen (OIDC
18493
+ * buttons; a usernameless passkey).
16753
18494
  * - `second-factor` — shown AFTER the password leg, gated on the
16754
18495
  * returned `factors` (passkey-as-2FA today).
16755
18496
  *
@@ -16771,7 +18512,14 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16771
18512
  icon: string().optional(),
16772
18513
  /** Addon-owned HTTP route the button navigates to (GET). */
16773
18514
  startUrl: string(),
16774
- stage: LoginStageEnum
18515
+ stage: LoginStageEnum,
18516
+ /**
18517
+ * The provider names an external identity a signed-in user can link to
18518
+ * their own account (D782): `auth.listLinkableProviders` /
18519
+ * `beginExternalLink` offer exactly the redirect methods that set this,
18520
+ * whatever their id. Absent / false — a login button only.
18521
+ */
18522
+ linkable: boolean().optional()
16775
18523
  }),
16776
18524
  object({
16777
18525
  kind: literal("widget"),
@@ -20586,8 +22334,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
20586
22334
  * `super_admin` — collapsed onto the single boolean because every
20587
22335
  * non-admin caller is governed by the same scope-check rules; the
20588
22336
  * 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
22337
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
20591
22338
  * with `isAdmin: false` + an explicit scope list.
20592
22339
  */
20593
22340
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22089,8 +23836,23 @@ var RetrainMacroClassSchema = _enum([
22089
23836
  ]);
22090
23837
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22091
23838
  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"]);
23839
+ /**
23840
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
23841
+ * the operator confirms it; once saved it keeps its source as provenance.
23842
+ *
23843
+ * - `operator` — drawn by hand.
23844
+ * - `assist` — proposed by a detector run on the copy (the camera's own
23845
+ * model, or a larger teacher model).
23846
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
23847
+ * back from the track store (never a re-run).
23848
+ * - `llm` — proposed by a vision-capable LLM profile.
23849
+ */
23850
+ var RetrainAnnotationSourceSchema = _enum([
23851
+ "operator",
23852
+ "assist",
23853
+ "pipeline",
23854
+ "llm"
23855
+ ]);
22094
23856
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22095
23857
  var RetrainBboxSchema = object({
22096
23858
  x: number(),
@@ -22108,7 +23870,8 @@ var RetrainBboxSchema = object({
22108
23870
  */
22109
23871
  var RetrainAnnotationSchema = object({
22110
23872
  id: string(),
22111
- trackId: string(),
23873
+ /** The frame's track. Absent on a recording still, which has none. */
23874
+ trackId: string().optional(),
22112
23875
  deviceId: number(),
22113
23876
  /** The COPY in retrain storage — never the source track's media key. */
22114
23877
  mediaKey: string(),
@@ -22157,18 +23920,63 @@ var RetrainFrameCandidateSchema = object({
22157
23920
  * fail, whatever became of the original. */
22158
23921
  copied: boolean()
22159
23922
  });
23923
+ /**
23924
+ * One box the live pipeline drew on a copied frame — what a correction starts
23925
+ * from. Derived when the frame is listed, from the track store: the subject
23926
+ * box recorded on the source media row when there is one, else the track
23927
+ * position nearest the frame's capture time. Never stored as an annotation
23928
+ * until the operator confirms it.
23929
+ */
23930
+ var RetrainPipelineBoxSchema = object({
23931
+ /** Normalised `[0,1]` against the full frame. */
23932
+ bbox: RetrainBboxSchema,
23933
+ macroClass: RetrainMacroClassSchema,
23934
+ label: string().optional(),
23935
+ subLabel: string().optional(),
23936
+ /** The detection score of the position used, when it was recorded. */
23937
+ score: number().optional(),
23938
+ /** The root model that produced the track, when it was recorded. */
23939
+ modelId: string().optional(),
23940
+ trackId: string(),
23941
+ /** `subject-box`: recorded on this very frame. `position`: the track's
23942
+ * position nearest the capture time, `deltaMs` away. */
23943
+ basis: _enum(["subject-box", "position"]),
23944
+ deltaMs: number()
23945
+ });
23946
+ /**
23947
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
23948
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
23949
+ * track at all.
23950
+ */
23951
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22160
23952
  /** A frame the dataset OWNS: bytes copied at selection time. */
22161
23953
  var RetrainFrameSchema = object({
22162
23954
  frameId: string(),
22163
23955
  deviceId: number(),
22164
- trackId: string(),
22165
- /** Provenance only. It may already point at nothing — that is expected. */
22166
- sourceMediaId: number().int(),
23956
+ origin: RetrainFrameOriginSchema,
23957
+ /** The track it was copied from. Absent on a recording still. */
23958
+ trackId: string().optional(),
23959
+ /** Provenance only. It may already point at nothing — that is expected.
23960
+ * Absent on a recording still. */
23961
+ sourceMediaId: number().int().optional(),
23962
+ /** A recording still: the playhead instant it was taken at. */
23963
+ epochMs: number().optional(),
22167
23964
  sourceKind: MediaFileKindEnum,
22168
23965
  sizeBytes: number().int(),
22169
23966
  width: number().int(),
22170
23967
  height: number().int(),
22171
- copiedAt: number()
23968
+ copiedAt: number(),
23969
+ /** When the CAMERA captured the frame. Absent on a copy taken before D785. */
23970
+ capturedAt: number().optional(),
23971
+ /** The operator's "every subject in this frame is boxed". Detector
23972
+ * evaluation keeps only complete frames: an unboxed subject would count as
23973
+ * a false positive. */
23974
+ complete: boolean(),
23975
+ /** The boxes the pipeline drew on this frame. Present on list answers;
23976
+ * empty when nothing the track store holds can be placed on it. */
23977
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
23978
+ /** The named collections this frame belongs to. Present on list answers. */
23979
+ collectionIds: array(string()).readonly().optional()
22172
23980
  });
22173
23981
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22174
23982
  var RetrainCopyRefusalSchema = _enum([
@@ -22189,6 +23997,56 @@ var RetrainFrameListSchema = object({
22189
23997
  /** What the page pre-selects — the native key frame when one survives. */
22190
23998
  autoPickMediaId: number().int().optional()
22191
23999
  });
24000
+ /**
24001
+ * Which frames an annotated export carries. Every field narrows; an empty
24002
+ * filter is every annotated copy. A dataset VERSION is a frozen `frameIds`
24003
+ * list owned by whoever trains (the training orchestrator), so `frameIds` is
24004
+ * the primitive a version export uses; `batchId` re-selects what an earlier
24005
+ * export carried (`exportedInBatch`).
24006
+ */
24007
+ var RetrainExportFilterSchema = object({
24008
+ deviceIds: array(number()).optional(),
24009
+ frameIds: array(string()).max(2e4).optional(),
24010
+ /** Only frames in at least one of these named collections. */
24011
+ collectionIds: array(string()).max(200).optional(),
24012
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24013
+ * unknown id selects nothing. */
24014
+ datasetVersionId: string().optional(),
24015
+ batchId: string().optional(),
24016
+ /** Only frames the operator marked complete (all subjects boxed). */
24017
+ completeOnly: boolean().optional()
24018
+ });
24019
+ /**
24020
+ * `frames`: the full frame copies, boxes in `annotations.json`.
24021
+ * `crops`: additionally one JPEG per subject, cut with the runtime detail-crop
24022
+ * convention — the classifier layout.
24023
+ */
24024
+ var RetrainExportLayoutSchema = _enum(["frames", "crops"]);
24025
+ /**
24026
+ * Where `writeRetrainArchive` streams the tar: one HTTP request whose body is
24027
+ * the archive, sent chunk by chunk. Covers a presigned PUT and a provider
24028
+ * addon's data-plane upload route alike. Headers are sent verbatim and never
24029
+ * logged.
24030
+ */
24031
+ var RetrainArchiveTargetSchema = object({
24032
+ kind: literal("http"),
24033
+ method: _enum(["PUT", "POST"]),
24034
+ url: string().url(),
24035
+ headers: record(string(), string()).optional()
24036
+ });
24037
+ var RetrainArchiveResultSchema = object({
24038
+ batchId: string(),
24039
+ frames: number().int(),
24040
+ crops: number().int(),
24041
+ annotations: number().int(),
24042
+ /** Frames planned but not shipped (unreadable copy, path too long). */
24043
+ missing: number().int(),
24044
+ bytes: number().int(),
24045
+ /** sha256 of the exact bytes sent. */
24046
+ sha256: string(),
24047
+ /** The target's HTTP status. */
24048
+ status: number().int()
24049
+ });
22192
24050
  /** What the operator asked the assist to look for. */
22193
24051
  var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
22194
24052
  kind: literal("package"),
@@ -22218,6 +24076,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22218
24076
  reason: string(),
22219
24077
  detail: string().optional()
22220
24078
  })]);
24079
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24080
+ var RetrainCollectionSchema = object({
24081
+ id: string(),
24082
+ name: string(),
24083
+ createdAt: number(),
24084
+ frameCount: number().int()
24085
+ });
24086
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24087
+ kind: literal("created"),
24088
+ collection: RetrainCollectionSchema
24089
+ }), object({
24090
+ kind: literal("refused"),
24091
+ reason: _enum(["empty-name", "duplicate-name"])
24092
+ })]);
24093
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24094
+ kind: literal("renamed"),
24095
+ collection: RetrainCollectionSchema
24096
+ }), object({
24097
+ kind: literal("refused"),
24098
+ reason: _enum([
24099
+ "empty-name",
24100
+ "duplicate-name",
24101
+ "unknown-collection"
24102
+ ])
24103
+ })]);
24104
+ /**
24105
+ * The outcome of adding the frame at a recording instant. Every refusal is
24106
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24107
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24108
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24109
+ */
24110
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24111
+ kind: literal("added"),
24112
+ collectionId: string(),
24113
+ frame: RetrainFrameSchema,
24114
+ /** The moment was already in the dataset; nothing was decoded. */
24115
+ reused: boolean()
24116
+ }), object({
24117
+ kind: literal("refused"),
24118
+ reason: _enum([
24119
+ "unknown-collection",
24120
+ "still-unavailable",
24121
+ "still-busy",
24122
+ "unreadable-image",
24123
+ "write-failed"
24124
+ ]),
24125
+ detail: string().optional()
24126
+ })]);
24127
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24128
+ var RetrainAssistProfileSchema = object({
24129
+ id: string(),
24130
+ name: string(),
24131
+ model: string(),
24132
+ kind: string(),
24133
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24134
+ * endpoint that is not on the local network). The page confirms each such
24135
+ * run, and the provider refuses one without `allowCloud`. */
24136
+ leavesHouse: boolean()
24137
+ });
24138
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24139
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24140
+ /** What the AI assist said about a box that was already on the canvas. */
24141
+ var RetrainLlmReviewSchema = object({
24142
+ /** The `ref` the page sent the box under. */
24143
+ ref: string(),
24144
+ verdict: _enum([
24145
+ "confirmed",
24146
+ "wrong-class",
24147
+ "not-an-object",
24148
+ "uncertain"
24149
+ ]),
24150
+ suggestedClass: RetrainMacroClassSchema.optional(),
24151
+ reason: string()
24152
+ });
24153
+ /**
24154
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24155
+ * model and its confidence) and reviews; items the model got wrong (a box off
24156
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24157
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24158
+ */
24159
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24160
+ kind: literal("proposed"),
24161
+ profileId: string(),
24162
+ model: string(),
24163
+ /** The frame was sent outside the house for this answer. */
24164
+ leftHouse: boolean(),
24165
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24166
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24167
+ rejected: number().int()
24168
+ }), object({
24169
+ kind: literal("refused"),
24170
+ reason: _enum([
24171
+ "unknown-frame",
24172
+ "unreadable-frame",
24173
+ "unknown-profile",
24174
+ "profile-disabled",
24175
+ "no-vision",
24176
+ "cloud-not-confirmed",
24177
+ "llm-error",
24178
+ "malformed-answer"
24179
+ ]),
24180
+ detail: string().optional()
24181
+ })]);
24182
+ /** What a dataset version is cut from. Every field narrows. */
24183
+ var RetrainDatasetSelectionSchema = object({
24184
+ deviceIds: array(number()).readonly().optional(),
24185
+ collectionIds: array(string()).max(200).readonly().optional(),
24186
+ frameIds: array(string()).max(2e4).readonly().optional()
24187
+ });
24188
+ /** The counts a dataset is judged by. */
24189
+ var RetrainDatasetStatsSchema = object({
24190
+ frames: number().int(),
24191
+ completeFrames: number().int(),
24192
+ /** `completeFrames / frames`, 0..1. */
24193
+ completeness: number(),
24194
+ /** Boxes to learn (model errors excluded). */
24195
+ subjects: number().int(),
24196
+ modelErrors: number().int(),
24197
+ /** Complete frames with no subject. */
24198
+ hardNegatives: number().int(),
24199
+ /** Subjects per class × camera × day/night. */
24200
+ cells: array(object({
24201
+ macroClass: string(),
24202
+ deviceId: number(),
24203
+ lighting: _enum([
24204
+ "day",
24205
+ "night",
24206
+ "unknown"
24207
+ ]),
24208
+ subjects: number().int(),
24209
+ frames: number().int()
24210
+ })).readonly(),
24211
+ cameras: array(object({
24212
+ deviceId: number(),
24213
+ frames: number().int(),
24214
+ completeFrames: number().int()
24215
+ })).readonly()
24216
+ });
24217
+ /** An immutable dataset version, without its frame list. */
24218
+ var RetrainDatasetVersionSchema = object({
24219
+ id: string(),
24220
+ name: string(),
24221
+ createdAt: number(),
24222
+ selection: RetrainDatasetSelectionSchema,
24223
+ layout: RetrainExportLayoutSchema,
24224
+ completeOnly: boolean(),
24225
+ frameCount: number().int(),
24226
+ /** sha256 of what the frames taught when the version was frozen. */
24227
+ annotationHash: string(),
24228
+ /** The export manifest schema the version was cut under. */
24229
+ manifestSchema: string(),
24230
+ stats: RetrainDatasetStatsSchema
24231
+ });
24232
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24233
+ kind: literal("created"),
24234
+ version: RetrainDatasetVersionSchema
24235
+ }), object({
24236
+ kind: literal("refused"),
24237
+ reason: _enum([
24238
+ "empty-name",
24239
+ "duplicate-name",
24240
+ "no-frames"
24241
+ ])
24242
+ })]);
22221
24243
  /** The outcome of a lifecycle move owned by the retrain page. */
22222
24244
  var RetrainTransitionResultSchema = object({
22223
24245
  trackId: string(),
@@ -22935,7 +24957,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22935
24957
  auth: "admin"
22936
24958
  }), method(object({
22937
24959
  deviceId: number(),
22938
- trackId: string(),
24960
+ trackId: string().optional(),
22939
24961
  frameId: string()
22940
24962
  }), object({
22941
24963
  removed: boolean(),
@@ -22952,7 +24974,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22952
24974
  auth: "admin"
22953
24975
  }), method(object({
22954
24976
  deviceId: number(),
22955
- trackId: string(),
24977
+ /** The frame's track, when it has one — checked against the frame. */
24978
+ trackId: string().optional(),
22956
24979
  frameId: string(),
22957
24980
  subject: RetrainAssistSubjectSchema,
22958
24981
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -22960,12 +24983,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22960
24983
  }), RetrainAssistResultSchema, {
22961
24984
  kind: "mutation",
22962
24985
  auth: "admin"
22963
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
24986
+ }), method(object({
24987
+ trackId: string().optional(),
24988
+ frameIds: array(string()).max(2e3).optional()
24989
+ }), array(RetrainAnnotationSchema).readonly(), {
22964
24990
  kind: "query",
22965
24991
  auth: "admin"
22966
24992
  }), method(object({
22967
24993
  deviceId: number(),
22968
- trackId: string(),
24994
+ /** The frame's track, when it has one — checked against the frame. */
24995
+ trackId: string().optional(),
22969
24996
  frameId: string(),
22970
24997
  annotations: array(RetrainAnnotationDraftSchema)
22971
24998
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -22983,7 +25010,132 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22983
25010
  }), RetrainTransitionResultSchema, {
22984
25011
  kind: "mutation",
22985
25012
  auth: "admin"
22986
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
25013
+ }), method(RetrainExportFilterSchema.extend({ layout: RetrainExportLayoutSchema.optional() }), object({ url: string() }), {
25014
+ kind: "query",
25015
+ auth: "admin"
25016
+ }), method(object({
25017
+ deviceId: number(),
25018
+ trackId: string().optional(),
25019
+ frameId: string(),
25020
+ complete: boolean()
25021
+ }), RetrainFrameSchema, {
25022
+ kind: "mutation",
25023
+ auth: "admin"
25024
+ }), method(object({
25025
+ filter: RetrainExportFilterSchema,
25026
+ layout: RetrainExportLayoutSchema,
25027
+ target: RetrainArchiveTargetSchema
25028
+ }), RetrainArchiveResultSchema, {
25029
+ kind: "mutation",
25030
+ auth: "admin",
25031
+ timeoutMs: 60 * 6e4
25032
+ }), method(object({
25033
+ filter: RetrainExportFilterSchema,
25034
+ layout: RetrainExportLayoutSchema
25035
+ }), object({
25036
+ ticket: PeerBytesTicketSchema,
25037
+ frames: number().int(),
25038
+ annotations: number().int()
25039
+ }), {
25040
+ kind: "mutation",
25041
+ auth: "admin",
25042
+ timeoutMs: 12e4
25043
+ }), method(object({
25044
+ selection: RetrainDatasetSelectionSchema,
25045
+ completeOnly: boolean().optional()
25046
+ }), RetrainDatasetStatsSchema, {
25047
+ kind: "query",
25048
+ auth: "admin"
25049
+ }), method(object({
25050
+ name: string().max(120),
25051
+ selection: RetrainDatasetSelectionSchema,
25052
+ layout: RetrainExportLayoutSchema,
25053
+ completeOnly: boolean()
25054
+ }), CreateRetrainDatasetVersionResultSchema, {
25055
+ kind: "mutation",
25056
+ auth: "admin",
25057
+ timeoutMs: 12e4
25058
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25059
+ kind: "query",
25060
+ auth: "admin"
25061
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25062
+ kind: "mutation",
25063
+ auth: "admin"
25064
+ }), method(object({ id: string() }), object({
25065
+ found: boolean(),
25066
+ annotationHash: string(),
25067
+ matches: boolean(),
25068
+ missingFrames: number().int()
25069
+ }), {
25070
+ kind: "query",
25071
+ auth: "admin",
25072
+ timeoutMs: 12e4
25073
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25074
+ kind: "query",
25075
+ auth: "admin"
25076
+ }), method(object({
25077
+ deviceId: number(),
25078
+ trackId: string().optional(),
25079
+ frameId: string(),
25080
+ profileId: string(),
25081
+ classes: array(RetrainMacroClassSchema).min(1),
25082
+ boxes: array(object({
25083
+ ref: string(),
25084
+ bbox: RetrainBboxSchema,
25085
+ macroClass: RetrainMacroClassSchema,
25086
+ label: string().optional()
25087
+ })).max(50),
25088
+ allowCloud: boolean()
25089
+ }), RetrainLlmAssistResultSchema, {
25090
+ kind: "mutation",
25091
+ auth: "admin",
25092
+ timeoutMs: 18e4
25093
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25094
+ kind: "mutation",
25095
+ auth: "admin"
25096
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25097
+ kind: "query",
25098
+ auth: "admin"
25099
+ }), method(object({
25100
+ id: string(),
25101
+ name: string().max(120)
25102
+ }), RetrainCollectionRenameResultSchema, {
25103
+ kind: "mutation",
25104
+ auth: "admin"
25105
+ }), method(object({ id: string() }), object({
25106
+ deleted: boolean(),
25107
+ removedFrames: number().int()
25108
+ }), {
25109
+ kind: "mutation",
25110
+ auth: "admin"
25111
+ }), method(object({
25112
+ collectionId: string(),
25113
+ deviceId: number(),
25114
+ epochMs: number()
25115
+ }), AddRetrainFrameFromRecordingResultSchema, {
25116
+ kind: "mutation",
25117
+ auth: "admin",
25118
+ timeoutMs: 6e4
25119
+ }), method(object({
25120
+ collectionId: string(),
25121
+ frameIds: array(string()).min(1).max(500)
25122
+ }), object({
25123
+ added: number().int(),
25124
+ alreadyMember: number().int(),
25125
+ unknownFrameIds: array(string()).readonly()
25126
+ }), {
25127
+ kind: "mutation",
25128
+ auth: "admin"
25129
+ }), method(object({
25130
+ collectionId: string(),
25131
+ frameId: string()
25132
+ }), object({
25133
+ removed: boolean(),
25134
+ deletedFrame: boolean()
25135
+ }), {
25136
+ kind: "mutation",
25137
+ auth: "admin"
25138
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
22987
25139
  kind: "query",
22988
25140
  auth: "admin"
22989
25141
  }), method(object({
@@ -23609,13 +25761,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23609
25761
  object({
23610
25762
  kind: literal("no-family-build"),
23611
25763
  format: ModelFormatSchema$1
25764
+ }),
25765
+ object({
25766
+ kind: literal("kept-custom-pin"),
25767
+ modelId: string(),
25768
+ deviceKey: string()
23612
25769
  })
23613
25770
  ]);
25771
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
25772
+ var KeptReasonSchema = _enum(["custom-pin"]);
25773
+ /**
25774
+ * Where a choice's latency came from (D791): this node's own benchmark
25775
+ * result, or the hardware-class table. Measured on the node beats the table.
25776
+ */
25777
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
25778
+ kind: literal("node-benchmark"),
25779
+ resultId: string(),
25780
+ measuredAtMs: number()
25781
+ })]);
23614
25782
  var DeviceModelChoiceSchema = object({
23615
25783
  modelId: string(),
23616
25784
  p50Ms: number(),
23617
25785
  fps: number(),
23618
25786
  measured: boolean(),
25787
+ /** Absent on a plan from before D791 — read as the table. */
25788
+ source: LatencySourceSchema.optional(),
23619
25789
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
23620
25790
  capacitySessions: number(),
23621
25791
  personRecall: number()
@@ -23626,6 +25796,8 @@ var DeviceRecommendationSchema = object({
23626
25796
  enabled: boolean(),
23627
25797
  available: boolean(),
23628
25798
  chosen: DeviceModelChoiceSchema.nullable(),
25799
+ /** Present when the device is kept as is: Apply writes nothing on it. */
25800
+ kept: KeptReasonSchema.optional(),
23629
25801
  reasons: array(RecommendationReasonSchema).readonly()
23630
25802
  });
23631
25803
  var NodeRecommendationSchema = object({
@@ -23679,6 +25851,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
23679
25851
  kind: literal("coral-enabled"),
23680
25852
  nodeId: string(),
23681
25853
  deviceKey: string()
25854
+ }),
25855
+ object({
25856
+ kind: literal("custom-pin-kept"),
25857
+ nodeId: string(),
25858
+ deviceKey: string().nullable(),
25859
+ deviceId: number().nullable(),
25860
+ modelId: string()
25861
+ }),
25862
+ object({
25863
+ kind: literal("custom-registry-unreadable"),
25864
+ error: string()
23682
25865
  })
23683
25866
  ]);
23684
25867
  var AutoTuneOptionsSchema = object({
@@ -23857,13 +26040,14 @@ var SuggestSharesResultSchema = object({
23857
26040
  nodes: array(SuggestedNodeShareSchema).readonly()
23858
26041
  });
23859
26042
  /**
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`.
26043
+ * Where the node and device shares come from (D750, D755, D791).
26044
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26045
+ * benchmark measured it; a node without fresh results is sized from
26046
+ * `hardware` and says so. Measured on the node beats the table.
26047
+ * - `hardware` — computed from each node's static capacity only (its
26048
+ * accelerators at their Auto tune models, from the latency table).
26049
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26050
+ * on or off, changes model, or a benchmark result is written. No load input.
23867
26051
  * - `manual` — the operator's stored sliders.
23868
26052
  * Either way a node or device that cannot take sessions gives its share to
23869
26053
  * the others in proportion; the stored values are never rewritten for that.
@@ -23912,6 +26096,362 @@ var EffectiveSharesSchema = object({
23912
26096
  nodeWeights: record(string(), number()),
23913
26097
  deviceWeights: record(string(), record(string(), number()))
23914
26098
  });
26099
+ /**
26100
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26101
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26102
+ * measuring runner reports, and the result rows Auto tune and the automatic
26103
+ * shares read.
26104
+ *
26105
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26106
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26107
+ * detection candidate, camera pins naming it are ignored so its sessions move
26108
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26109
+ * restart too (a persisted manifest, reconciled against the registry).
26110
+ *
26111
+ * Two measurements, both on the node, driven by its own runner (frames never
26112
+ * cross a process at frame rate, D9):
26113
+ * - `device` — one accelerator × one candidate detector, root only, open
26114
+ * loop: how many streams at the camera rate it carries inside the frame
26115
+ * interval;
26116
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26117
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26118
+ * clip: how many parallel sessions the node carries before latency, drops,
26119
+ * CPU, RAM or the event loop give out.
26120
+ */
26121
+ /** Defaults and bounds, one place. */
26122
+ var NODE_BENCHMARK_DEFAULTS = {
26123
+ fpsPerStream: 10,
26124
+ budgetMinutes: 45,
26125
+ minBudgetMinutes: 10,
26126
+ maxBudgetMinutes: 120,
26127
+ /** A result older than this no longer beats the table. */
26128
+ staleAfterDays: 30,
26129
+ /** Warm-in per ramp step (not accounted). */
26130
+ settleSec: 5,
26131
+ /** Accounted window per ramp step. */
26132
+ measureSec: 20,
26133
+ /** Longest the drain may take before the run is refused. */
26134
+ drainTimeoutSec: 120,
26135
+ /** Candidate models per device in one run. */
26136
+ maxModelsPerDevice: 6
26137
+ };
26138
+ /** The two measurements a run can make. */
26139
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26140
+ var NodeBenchmarkDevicePlanSchema = object({
26141
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26142
+ deviceKey: string().min(1),
26143
+ /**
26144
+ * Root detector candidates for the `device` measurement, in the order
26145
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26146
+ */
26147
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26148
+ });
26149
+ /** What the operator confirmed. */
26150
+ var NodeBenchmarkPlanSchema = object({
26151
+ nodeId: string().min(1),
26152
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26153
+ /** Which measurements run. At least one. */
26154
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26155
+ /**
26156
+ * Detail steps (catalog step ids under the root: faces, plates,
26157
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26158
+ * detector always runs.
26159
+ */
26160
+ steps: array(string().min(1)).default([]),
26161
+ /** Offered rate of one stream / session. */
26162
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26163
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26164
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26165
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26166
+ keepDownloadedModels: boolean().default(false),
26167
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26168
+ acceptInsufficientHeadroom: boolean().default(false)
26169
+ });
26170
+ var NodeBenchmarkRefusalSchema = object({
26171
+ kind: _enum([
26172
+ "benchmark-active",
26173
+ "node-offline",
26174
+ "unknown-device",
26175
+ "no-phase",
26176
+ "insufficient-headroom"
26177
+ ]),
26178
+ detail: string(),
26179
+ overridable: boolean()
26180
+ });
26181
+ /** A camera whose detection leaves the node for the run. */
26182
+ var NodeBenchmarkMovingCameraSchema = object({
26183
+ deviceId: number(),
26184
+ /** Placed on the node now (a standing attach or a running session). */
26185
+ placedOnNode: boolean(),
26186
+ /** A node pin naming this node, ignored for the run. */
26187
+ pinnedToNode: boolean()
26188
+ });
26189
+ /** A camera that cannot leave: no other node can obtain its frames. */
26190
+ var NodeBenchmarkStayingCameraSchema = object({
26191
+ deviceId: number(),
26192
+ reason: literal("only-frame-source")
26193
+ });
26194
+ var NodeBenchmarkPreflightSchema = object({
26195
+ nodeId: string(),
26196
+ online: boolean(),
26197
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26198
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26199
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26200
+ estimatedDurationMs: number(),
26201
+ /** The run ends and the cluster is restored at the latest after this long. */
26202
+ budgetMs: number(),
26203
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26204
+ steps: array(string()).readonly(),
26205
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26206
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26207
+ headroom: object({
26208
+ sessionsNow: number(),
26209
+ otherNodesCapacitySessions: number().nullable()
26210
+ }),
26211
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26212
+ canStart: boolean()
26213
+ });
26214
+ /** Where the measuring runner is. */
26215
+ var NodeBenchProgressSchema = object({
26216
+ phase: _enum([
26217
+ "preparing",
26218
+ "device",
26219
+ "pipeline",
26220
+ "cleanup"
26221
+ ]),
26222
+ deviceKey: string().nullable(),
26223
+ modelId: string().nullable(),
26224
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26225
+ load: number().nullable(),
26226
+ cellsDone: number(),
26227
+ cellsTotal: number(),
26228
+ message: string()
26229
+ });
26230
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26231
+ var NodeBenchLimitSchema = _enum([
26232
+ "p95",
26233
+ "drops",
26234
+ "errors",
26235
+ "stall",
26236
+ "cpu",
26237
+ "ram",
26238
+ "none"
26239
+ ]);
26240
+ var NodeBenchRampStepSchema = object({
26241
+ load: number(),
26242
+ pass: boolean(),
26243
+ p95Ms: number(),
26244
+ dropRatio: number(),
26245
+ /** Completed frames per second over the accounted window. */
26246
+ fps: number(),
26247
+ cpuPct: number().nullable(),
26248
+ ramFreePct: number().nullable(),
26249
+ failReasons: array(string()).readonly()
26250
+ });
26251
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26252
+ phase: literal("device"),
26253
+ deviceKey: string(),
26254
+ modelId: string(),
26255
+ /** Single-stream latency (the K = 1 step). */
26256
+ p50Ms: number(),
26257
+ p95Ms: number(),
26258
+ p99Ms: number(),
26259
+ /** Frames per second sustained at the last passing step. */
26260
+ fps: number(),
26261
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26262
+ kMax: number(),
26263
+ limitedBy: NodeBenchLimitSchema,
26264
+ /** First call (model load + warm-up). */
26265
+ warmupMs: number(),
26266
+ ramp: array(NodeBenchRampStepSchema).readonly()
26267
+ }), object({
26268
+ phase: literal("pipeline"),
26269
+ deviceKey: string(),
26270
+ modelId: string(),
26271
+ steps: array(string()).readonly(),
26272
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26273
+ maxSessions: number(),
26274
+ limitedBy: NodeBenchLimitSchema,
26275
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26276
+ stepsFired: array(string()).readonly(),
26277
+ warmupMs: number(),
26278
+ ramp: array(NodeBenchRampStepSchema).readonly()
26279
+ })]);
26280
+ /**
26281
+ * What a result was measured ON. A result whose fingerprint no longer matches
26282
+ * the node no longer beats the table.
26283
+ */
26284
+ var NodeBenchFingerprintSchema = object({
26285
+ pipelineVersion: string().nullable(),
26286
+ cpuModel: string().nullable(),
26287
+ ramGb: number().nullable(),
26288
+ os: string().nullable(),
26289
+ /** Per device: the pool the cells ran on (runtime + tuning). */
26290
+ pools: record(string(), object({
26291
+ runtime: string(),
26292
+ numWorkers: number(),
26293
+ concurrency: number(),
26294
+ batchMode: string()
26295
+ })).default({})
26296
+ });
26297
+ /** The frames the run used. */
26298
+ var NodeBenchClipSchema = object({
26299
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
26300
+ id: string(),
26301
+ revision: string().nullable(),
26302
+ frames: number(),
26303
+ width: number(),
26304
+ height: number()
26305
+ });
26306
+ var NodeBenchRunnerInputSchema = object({
26307
+ runId: string().min(1),
26308
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26309
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
26310
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
26311
+ steps: array(string()).default([]),
26312
+ fpsPerStream: number().int().min(1).max(30),
26313
+ /** The runner stops on its own past this instant, whatever the hub does. */
26314
+ deadlineAtMs: number(),
26315
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
26316
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
26317
+ keepDownloadedModels: boolean().default(false)
26318
+ });
26319
+ var NodeBenchRunnerStateSchema = _enum([
26320
+ "running",
26321
+ "done",
26322
+ "failed",
26323
+ "aborted"
26324
+ ]);
26325
+ var NodeBenchRunnerStatusSchema = object({
26326
+ runId: string(),
26327
+ nodeId: string(),
26328
+ state: NodeBenchRunnerStateSchema,
26329
+ progress: NodeBenchProgressSchema.nullable(),
26330
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
26331
+ cells: array(NodeBenchCellSchema).readonly(),
26332
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26333
+ clip: NodeBenchClipSchema.nullable(),
26334
+ /** Cameras seen running on the node during the run (they share its pools). */
26335
+ activeCameraIds: array(number()).readonly(),
26336
+ /** Models the run downloaded and then deleted (not installed before). */
26337
+ deletedModels: array(string()).readonly(),
26338
+ error: string().nullable(),
26339
+ startedAtMs: number(),
26340
+ finishedAtMs: number().nullable()
26341
+ });
26342
+ var NodeBenchmarkStateSchema = _enum([
26343
+ "draining",
26344
+ "measuring",
26345
+ "restoring",
26346
+ "done",
26347
+ "failed",
26348
+ "aborted"
26349
+ ]);
26350
+ /** Why a run ended. */
26351
+ var NodeBenchmarkEndReasonSchema = _enum([
26352
+ "completed",
26353
+ "operator-abort",
26354
+ "deadline",
26355
+ "node-lost",
26356
+ "runner-lost",
26357
+ "hub-restart",
26358
+ "drain-timeout",
26359
+ "failed"
26360
+ ]);
26361
+ var NodeBenchmarkRunSchema = object({
26362
+ runId: string(),
26363
+ nodeId: string(),
26364
+ state: NodeBenchmarkStateSchema,
26365
+ plan: NodeBenchmarkPlanSchema,
26366
+ startedAtMs: number(),
26367
+ deadlineAtMs: number(),
26368
+ finishedAtMs: number().nullable(),
26369
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26370
+ error: string().nullable(),
26371
+ /** Cameras moved off the node for the run. */
26372
+ moved: array(number()).readonly(),
26373
+ /** Cameras that stayed (their only frame source is the node). */
26374
+ staying: array(number()).readonly(),
26375
+ /** Something else ran on the node's pools during the run. */
26376
+ contaminated: boolean(),
26377
+ progress: NodeBenchProgressSchema.nullable(),
26378
+ resultIds: array(string()).readonly()
26379
+ });
26380
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26381
+ var NodeBenchmarkStatusSchema = object({
26382
+ /** The node the cluster is in benchmark mode for; null = none. */
26383
+ modeNodeId: string().nullable(),
26384
+ run: NodeBenchmarkRunSchema.nullable()
26385
+ });
26386
+ /**
26387
+ * One stored measurement — the only authority Auto tune and the automatic
26388
+ * shares read measured capacity from. Written by the orchestrator when a run
26389
+ * ends, never by anyone else.
26390
+ */
26391
+ var NodeBenchmarkResultSchema = object({
26392
+ id: string(),
26393
+ runId: string(),
26394
+ nodeId: string(),
26395
+ cell: NodeBenchCellSchema,
26396
+ fpsPerStream: number(),
26397
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26398
+ clip: NodeBenchClipSchema.nullable(),
26399
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26400
+ contaminated: boolean(),
26401
+ stayingCameras: array(number()).readonly(),
26402
+ /** The run ended early; the cell itself completed. */
26403
+ partialRun: boolean(),
26404
+ measuredAtMs: number()
26405
+ });
26406
+ var ListNodeBenchmarkResultsInputSchema = object({
26407
+ nodeId: string().optional(),
26408
+ deviceKey: string().optional()
26409
+ });
26410
+ /** A result with its standing today: does it still beat the table? */
26411
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26412
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26413
+ standing: _enum([
26414
+ "fresh",
26415
+ "stale",
26416
+ "superseded"
26417
+ ]),
26418
+ staleWhy: _enum([
26419
+ "age",
26420
+ "runtime",
26421
+ "pool-tuning"
26422
+ ]).nullable()
26423
+ });
26424
+ object({
26425
+ runId: string(),
26426
+ nodeId: string(),
26427
+ startedAtMs: number(),
26428
+ deadlineAtMs: number(),
26429
+ plan: NodeBenchmarkPlanSchema,
26430
+ moved: array(number()).readonly(),
26431
+ staying: array(number()).readonly()
26432
+ });
26433
+ /** Candidate detectors per device, for the plan editor. */
26434
+ var NodeBenchmarkCandidatesSchema = object({
26435
+ nodeId: string(),
26436
+ reachable: boolean(),
26437
+ devices: array(object({
26438
+ deviceKey: string(),
26439
+ enabled: boolean(),
26440
+ available: boolean(),
26441
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26442
+ suggested: array(string()).readonly(),
26443
+ /** Every root detector the device has a build for. */
26444
+ all: array(string()).readonly(),
26445
+ /** The model the device runs now, when pinned. */
26446
+ currentModelId: string().nullable()
26447
+ })).readonly(),
26448
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26449
+ steps: array(object({
26450
+ id: string(),
26451
+ name: string(),
26452
+ slot: string()
26453
+ })).readonly()
26454
+ });
23915
26455
  object({
23916
26456
  activeCameras: number(),
23917
26457
  throttledCameras: number(),
@@ -25000,7 +27540,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25000
27540
  }), ParkedTrackFrameSchema.nullable()), method(object({
25001
27541
  deviceId: number(),
25002
27542
  trackId: string()
25003
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
27543
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
27544
+ accepted: literal(true),
27545
+ runId: string()
27546
+ }), {
27547
+ kind: "mutation",
27548
+ auth: "admin"
27549
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27550
+ kind: "mutation",
27551
+ auth: "admin"
27552
+ });
25004
27553
  var CameraPipelineConfigSchema = object({
25005
27554
  engine: PipelineEngineChoiceSchema.optional(),
25006
27555
  steps: array(PipelineStepInputSchema).readonly(),
@@ -25639,6 +28188,21 @@ method(object({
25639
28188
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
25640
28189
  kind: "mutation",
25641
28190
  auth: "admin"
28191
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28192
+ kind: literal("started"),
28193
+ runId: string()
28194
+ }), object({
28195
+ kind: literal("refused"),
28196
+ preflight: NodeBenchmarkPreflightSchema
28197
+ })]), {
28198
+ kind: "mutation",
28199
+ auth: "admin"
28200
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28201
+ kind: "mutation",
28202
+ auth: "admin"
28203
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28204
+ kind: "mutation",
28205
+ auth: "admin"
25642
28206
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
25643
28207
  deviceId: number(),
25644
28208
  addonId: string(),
@@ -26044,8 +28608,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26044
28608
  * `smtp-provider` — pluggable email delivery surface.
26045
28609
  *
26046
28610
  * 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
28611
+ * one for transactional / one for notifications). Consumers (notifier
28612
+ * addons, …) walk the collection and pick the first
26049
28613
  * ready provider OR target a specific addonId.
26050
28614
  *
26051
28615
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -26224,7 +28788,7 @@ targets: array(object({
26224
28788
  })));
26225
28789
  /**
26226
28790
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
26227
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
28791
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
26228
28792
  * carrying the post-callback claims before redirecting back to
26229
28793
  * `/api/auth/sso/finish`.
26230
28794
  *
@@ -26275,7 +28839,26 @@ var SsoBridgeClaimsSchema = object({
26275
28839
  * editing a descriptor must not retroactively extend or shorten a link the
26276
28840
  * operator already consented to.
26277
28841
  */
26278
- refreshTtl: union([number().int().positive(), literal("never")]).optional()
28842
+ refreshTtl: union([number().int().positive(), literal("never")]).optional(),
28843
+ /**
28844
+ * Opaque handle of a hub-side LINK intent (D782). Set by an OIDC callback
28845
+ * that was started from a signed-in user's "Link" button: the finish then
28846
+ * links this identity to the intent's user instead of signing anyone in.
28847
+ * The handle carries no user id — the hub resolves it, single-use.
28848
+ */
28849
+ linkIntent: string().optional(),
28850
+ /**
28851
+ * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28852
+ * subject is unique only per issuer, so a link is bound to it.
28853
+ */
28854
+ issuer: string().optional(),
28855
+ /**
28856
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
28857
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
28858
+ * request to present the matching cookie — a login bridge is useless in
28859
+ * any other browser.
28860
+ */
28861
+ browserBinding: string().optional()
26279
28862
  });
26280
28863
  method(object({
26281
28864
  claims: SsoBridgeClaimsSchema,
@@ -28181,7 +30764,22 @@ DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), ar
28181
30764
  * field their hints were silently stripped by the schema and the
28182
30765
  * adaptive ladder started blind on the client's display size.
28183
30766
  */
28184
- hints: webrtcClientHintsSchema.optional()
30767
+ hints: webrtcClientHintsSchema.optional(),
30768
+ /**
30769
+ * Talk-back (D771): relay the PEER's audio to the device's speaker
30770
+ * through the `intercom` cap's push-talk triple. When `true` and the
30771
+ * offer lets the peer send audio, the answer's audio is `sendrecv`
30772
+ * and every inbound frame goes to `intercom.pushTalkAudio` for this
30773
+ * `deviceId`; absent/false answers `sendonly`, as for every viewer.
30774
+ *
30775
+ * TRUSTED-CALLER ONLY. Set by the Alexa export for an Echo on a camera
30776
+ * with `intercom`, when the linked user may control that camera. The
30777
+ * hub STRIPS it from every request-bound call (a browser), exactly as
30778
+ * it overwrites `relayOnly` — a viewer's talk permission is the
30779
+ * intercom cap's own surface (share tokens gate it there), and this
30780
+ * flag must not become a second door to the camera's speaker.
30781
+ */
30782
+ talkback: boolean().optional()
28185
30783
  }), object({
28186
30784
  sessionId: string(),
28187
30785
  sdpAnswer: string()
@@ -28483,6 +31081,59 @@ var AddonAutoUpdateSchema = ChannelWithInheritSchema;
28483
31081
  var RestartAddonResultSchema = unknown();
28484
31082
  var InstallPackageResultSchema = unknown();
28485
31083
  var ReloadPackagesResultSchema = unknown();
31084
+ /**
31085
+ * What an uninstall did on ONE node.
31086
+ * - `uninstalled` — removed: runner(s) stopped, caps gone, code deleted.
31087
+ * - `not-installed` — the node did not have it (nothing to do).
31088
+ * - `refused` — protected / bootstrap package; nothing touched.
31089
+ * - `failed` — attempted and did not complete; `error` says why.
31090
+ * - `pending-reconnect` — the node is OFFLINE: its record was pruned so the
31091
+ * back-fill never returns the package, and the stale-addon sweep removes the
31092
+ * copy when the node registers again (only once the hub no longer has it).
31093
+ */
31094
+ var UninstallNodeOutcomeSchema = _enum([
31095
+ "uninstalled",
31096
+ "not-installed",
31097
+ "refused",
31098
+ "failed",
31099
+ "pending-reconnect"
31100
+ ]);
31101
+ var UninstallNodeResultSchema = object({
31102
+ nodeId: string(),
31103
+ outcome: UninstallNodeOutcomeSchema,
31104
+ error: string().optional(),
31105
+ addonIds: array(string()).readonly(),
31106
+ runnersStopped: array(string()).readonly(),
31107
+ warnings: array(string()).readonly()
31108
+ });
31109
+ var UninstallPackageResultSchema = object({
31110
+ /** Every targeted node ended `uninstalled`, `not-installed` or `pending-reconnect`. */
31111
+ success: boolean(),
31112
+ packageName: string(),
31113
+ results: array(UninstallNodeResultSchema).readonly()
31114
+ });
31115
+ /**
31116
+ * `unreachable` lists online agents whose status read FAILED — absence from
31117
+ * `installations` is only "not installed" for a node that answered (D315).
31118
+ */
31119
+ var PackageInstallationsSchema = object({
31120
+ installations: array(object({
31121
+ packageName: string(),
31122
+ nodeId: string(),
31123
+ nodeName: string(),
31124
+ isHub: boolean(),
31125
+ isOnline: boolean(),
31126
+ version: string().nullable(),
31127
+ addonIds: array(string()).readonly(),
31128
+ source: _enum(["live", "recorded"]),
31129
+ /** The hub installs this package too. `false` on an agent row = an orphan. */
31130
+ onHub: boolean()
31131
+ })).readonly(),
31132
+ unreachable: array(object({
31133
+ nodeId: string(),
31134
+ error: string()
31135
+ })).readonly()
31136
+ });
28486
31137
  var BulkUpdateItemStatusSchema = _enum([
28487
31138
  "queued",
28488
31139
  "updating",
@@ -28565,10 +31216,14 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
28565
31216
  }), method(object({ packageName: string() }), InstallPackageResultSchema, {
28566
31217
  kind: "mutation",
28567
31218
  auth: "admin"
28568
- }), method(_void(), boolean()), method(_void(), array(unknown()).readonly()), method(object({ packageName: string() }), unknown(), {
31219
+ }), method(_void(), boolean()), method(_void(), array(unknown()).readonly()), method(object({
31220
+ packageName: string().min(1),
31221
+ nodeId: string().optional(),
31222
+ everywhere: boolean().optional()
31223
+ }), UninstallPackageResultSchema, {
28569
31224
  kind: "mutation",
28570
31225
  auth: "admin"
28571
- }), method(_void(), ReloadPackagesResultSchema, {
31226
+ }), method(object({ packageName: string().optional() }), PackageInstallationsSchema, { auth: "admin" }), method(_void(), ReloadPackagesResultSchema, {
28572
31227
  kind: "mutation",
28573
31228
  auth: "admin"
28574
31229
  }), method(object({ query: string().optional() }), array(SearchResultSchema)), method(object({ nodeId: string().optional() }), array(PackageUpdateSchema).readonly(), { auth: "admin" }), method(object({
@@ -30636,6 +33291,9 @@ var CreateIntegrationInputSchema = object({
30636
33291
  enabled: boolean().optional(),
30637
33292
  info: record(string(), unknown()).optional(),
30638
33293
  settings: record(string(), unknown()).optional(),
33294
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
33295
+ * the keychain, not the table (D787). */
33296
+ secretKeys: array(string()).optional(),
30639
33297
  skipRestart: boolean().optional()
30640
33298
  });
30641
33299
  var UpdateIntegrationInputSchema = object({
@@ -30659,7 +33317,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
30659
33317
  auth: "admin"
30660
33318
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
30661
33319
  id: string(),
30662
- settings: record(string(), unknown())
33320
+ settings: record(string(), unknown()),
33321
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
33322
+ secretKeys: array(string()).optional()
30663
33323
  }), object({ success: boolean() }), {
30664
33324
  kind: "mutation",
30665
33325
  auth: "admin"
@@ -36118,16 +38778,6 @@ var ApiKeySummarySchema = object({
36118
38778
  createdAt: number(),
36119
38779
  lastUsedAt: number().optional()
36120
38780
  });
36121
- var CreateApiKeyInputSchema = object({
36122
- label: string(),
36123
- isAdmin: boolean().default(false),
36124
- allowedProviders: union([array(string()), literal("*")]).optional(),
36125
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
36126
- });
36127
- var CreateApiKeyResultSchema = object({
36128
- token: string(),
36129
- record: ApiKeySummarySchema
36130
- });
36131
38781
  var ScopedTokenSummarySchema = object({
36132
38782
  id: string(),
36133
38783
  userId: string(),
@@ -36168,6 +38818,32 @@ var TotpStatusSchema = object({
36168
38818
  /** Null when no row exists OR the row is still pending confirmation. */
36169
38819
  confirmedAt: number().nullable()
36170
38820
  });
38821
+ /**
38822
+ * user-management — singleton capability for user accounts, API keys,
38823
+ * and scoped tokens.
38824
+ *
38825
+ * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
38826
+ * — the subset check on `setUserScopes` / `createScopedToken` is moot
38827
+ * because non-admins never reach these. If/when we open non-admin
38828
+ * delegation, structural caller-scope subset check goes inside the
38829
+ * provider.
38830
+ */
38831
+ var ExternalIdentitySchema = object({
38832
+ /** Login-method id of the provider instance, e.g. `auth-oidc/authentik`. */
38833
+ provider: string(),
38834
+ /** The IdP's stable subject (`sub`) for this account. */
38835
+ subject: string(),
38836
+ /** The verified `iss` of the IdP the identity was linked under — `sub` is unique only per issuer. */
38837
+ issuer: string(),
38838
+ userId: string(),
38839
+ /** What the IdP called the account at link time (username / email) — display only. */
38840
+ label: string().optional(),
38841
+ linkedAt: number()
38842
+ });
38843
+ var ExternalIdentityKeySchema = object({
38844
+ provider: string().min(1),
38845
+ subject: string().min(1)
38846
+ });
36171
38847
  method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserInputSchema, UserSummarySchema, {
36172
38848
  kind: "mutation",
36173
38849
  auth: "admin",
@@ -36200,17 +38876,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36200
38876
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
36201
38877
  kind: "mutation",
36202
38878
  access: "view"
36203
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
36204
- kind: "mutation",
36205
- auth: "admin",
36206
- access: "create"
36207
- }), method(object({ id: string() }), object({ success: literal(true) }), {
38879
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
36208
38880
  kind: "mutation",
36209
38881
  auth: "admin",
36210
38882
  access: "delete"
36211
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
36212
- kind: "mutation",
36213
- access: "view"
36214
38883
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
36215
38884
  kind: "mutation",
36216
38885
  auth: "admin",
@@ -36281,7 +38950,14 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36281
38950
  userId: string(),
36282
38951
  username: string(),
36283
38952
  scopes: array(TokenScopeSchema)
36284
- }).nullable(), { access: "view" }), method(_void(), array(OauthSessionSummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: boolean() }), {
38953
+ }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
38954
+ userId: string(),
38955
+ issuer: string()
38956
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38957
+ kind: "mutation",
38958
+ auth: "admin",
38959
+ access: "delete"
38960
+ }), method(_void(), array(OauthSessionSummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: boolean() }), {
36285
38961
  kind: "mutation",
36286
38962
  auth: "admin",
36287
38963
  access: "delete"
@@ -36672,6 +39348,451 @@ DeviceType.Camera, method(object({
36672
39348
  detection: array(ZoneRuleSchema).readonly(),
36673
39349
  package: array(ZoneRuleSchema).readonly()
36674
39350
  });
39351
+ /**
39352
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39353
+ *
39354
+ * A thin, mockable translation layer: it knows how to run a container with a
39355
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39356
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39357
+ * those are the `training` orchestrator's (D805). Every rule written there
39358
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39359
+ * manifest entry and nothing else.
39360
+ *
39361
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
39362
+ * `notification-output` posture); `describe` concat-fans across providers.
39363
+ * Every method is `admin`: these spend money.
39364
+ *
39365
+ * Every cloud object a provider creates is tagged with the orchestrator's
39366
+ * `jobKey`, so a retried submit finds the job it already started instead of
39367
+ * starting a second GPU, and `listJobs` can find orphans.
39368
+ *
39369
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39370
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39371
+ * ticket the provider mints (D613).
39372
+ */
39373
+ var TrainingGpuOptionSchema = object({
39374
+ id: string(),
39375
+ label: string(),
39376
+ /** List price, USD per GPU-hour, before any region multiplier. */
39377
+ usdPerHour: number().nonnegative(),
39378
+ vramGb: number().nonnegative()
39379
+ });
39380
+ var TrainingRegionOptionSchema = object({
39381
+ /** `''` = any region (the provider's choice). */
39382
+ id: string(),
39383
+ label: string(),
39384
+ priceMultiplier: number().positive()
39385
+ });
39386
+ /**
39387
+ * The provider's per-account settings, as the orchestrator reads them. They
39388
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
39389
+ * depend on the user's account), never hard-coded in the orchestrator.
39390
+ */
39391
+ var TrainingProviderDefaultsSchema = object({
39392
+ gpuType: string(),
39393
+ region: string(),
39394
+ costCapUsd: number().nonnegative(),
39395
+ maxRuntimeSec: number().int().positive(),
39396
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39397
+ failedDatasetGraceHours: number().nonnegative()
39398
+ });
39399
+ var TrainingProviderDescriptorSchema = object({
39400
+ addonId: string(),
39401
+ /** `modal`, `runpod`, `fake`, … */
39402
+ kind: string(),
39403
+ label: string(),
39404
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39405
+ regions: array(TrainingRegionOptionSchema).readonly(),
39406
+ maxDatasetBytes: number().int().positive(),
39407
+ maxRuntimeSec: number().int().positive(),
39408
+ freeTierNote: string().optional(),
39409
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39410
+ dataResidencyNote: string(),
39411
+ /** Credentials are present — never the values. */
39412
+ configured: boolean(),
39413
+ defaults: TrainingProviderDefaultsSchema
39414
+ });
39415
+ var TrainingCredentialCheckSchema = object({
39416
+ ok: boolean(),
39417
+ /** Workspace / account name, when the provider says. */
39418
+ account: string().optional(),
39419
+ reason: _enum([
39420
+ "missing",
39421
+ "invalid",
39422
+ "forbidden",
39423
+ "network",
39424
+ "quota"
39425
+ ]).optional(),
39426
+ detail: string().optional()
39427
+ });
39428
+ var ProviderJobStateSchema = _enum([
39429
+ "pending",
39430
+ "starting",
39431
+ "running",
39432
+ "succeeded",
39433
+ "failed",
39434
+ "cancelled",
39435
+ "lost"
39436
+ ]);
39437
+ var ProviderJobStatusSchema = object({
39438
+ jobKey: string(),
39439
+ providerJobId: string().optional(),
39440
+ state: ProviderJobStateSchema,
39441
+ startedAt: number().optional(),
39442
+ endedAt: number().optional(),
39443
+ exitCode: number().int().optional(),
39444
+ failureReason: string().optional(),
39445
+ gpuType: string(),
39446
+ region: string().optional(),
39447
+ billedSeconds: number().nonnegative(),
39448
+ costUsd: number().nonnegative(),
39449
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39450
+ costIsEstimate: boolean(),
39451
+ lastFetchedAt: number()
39452
+ });
39453
+ /**
39454
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39455
+ * image its own way (Modal builds the published Dockerfile at that revision;
39456
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39457
+ * in `result.json`.
39458
+ */
39459
+ var TrainerSourceRefSchema = object({
39460
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39461
+ repo: string().min(1),
39462
+ /** A commit sha (never a branch) — the job must be reproducible. */
39463
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39464
+ });
39465
+ var JobRef = {
39466
+ addonId: string(),
39467
+ jobKey: string().uuid()
39468
+ };
39469
+ var TrainingLogLineSchema = object({
39470
+ ts: number(),
39471
+ text: string()
39472
+ });
39473
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
39474
+ kind: "mutation",
39475
+ auth: "admin",
39476
+ timeoutMs: 3e4
39477
+ }), method(object({
39478
+ addonId: string(),
39479
+ gpuType: string(),
39480
+ region: string(),
39481
+ datasetBytes: number().int().nonnegative(),
39482
+ gpuSecondsLow: number().nonnegative(),
39483
+ gpuSecondsHigh: number().nonnegative()
39484
+ }), object({
39485
+ usdLow: number().nonnegative(),
39486
+ usdHigh: number().nonnegative(),
39487
+ notes: array(string()).readonly()
39488
+ }), { auth: "admin" }), method(object({
39489
+ ...JobRef,
39490
+ ticket: PeerBytesTicketSchema
39491
+ }), object({
39492
+ bytes: number().int().nonnegative(),
39493
+ sha256: string()
39494
+ }), {
39495
+ kind: "mutation",
39496
+ auth: "admin",
39497
+ timeoutMs: 120 * 6e4
39498
+ }), method(object({
39499
+ ...JobRef,
39500
+ trainer: TrainerSourceRefSchema,
39501
+ jobSpecJson: string().min(2).max(64e3),
39502
+ gpuType: string(),
39503
+ region: string(),
39504
+ maxRuntimeSec: number().int().positive()
39505
+ }), ProviderJobStatusSchema, {
39506
+ kind: "mutation",
39507
+ auth: "admin",
39508
+ timeoutMs: 30 * 6e4
39509
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39510
+ auth: "admin",
39511
+ timeoutMs: 6e4
39512
+ }), method(object({
39513
+ ...JobRef,
39514
+ cursor: string().optional(),
39515
+ max: number().int().min(1).max(500)
39516
+ }), object({
39517
+ lines: array(TrainingLogLineSchema).readonly(),
39518
+ cursor: string()
39519
+ }), {
39520
+ auth: "admin",
39521
+ timeoutMs: 6e4
39522
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39523
+ kind: "mutation",
39524
+ auth: "admin",
39525
+ timeoutMs: 6e4
39526
+ }), method(object(JobRef), object({
39527
+ found: boolean(),
39528
+ text: string().optional()
39529
+ }), {
39530
+ kind: "mutation",
39531
+ auth: "admin",
39532
+ timeoutMs: 5 * 6e4
39533
+ }), method(object({
39534
+ ...JobRef,
39535
+ path: _enum(["bundle.tar"])
39536
+ }), object({ ticket: PeerBytesTicketSchema }), {
39537
+ kind: "mutation",
39538
+ auth: "admin",
39539
+ timeoutMs: 5 * 6e4
39540
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39541
+ kind: "mutation",
39542
+ auth: "admin",
39543
+ timeoutMs: 5 * 6e4
39544
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
39545
+ auth: "admin",
39546
+ timeoutMs: 2 * 6e4
39547
+ });
39548
+ /**
39549
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39550
+ * provided by `addon-training`.
39551
+ *
39552
+ * It owns what every provider must agree on, written once:
39553
+ *
39554
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
39555
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
39556
+ * the export plan) and reaches this store through the five row methods
39557
+ * below, so the Retrain page and the export did not change.
39558
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39559
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39560
+ * - **The return flow.** Verified artefacts → Model Studio
39561
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39562
+ * rollback. Nothing is ever registered automatically.
39563
+ *
39564
+ * Every method is `admin`.
39565
+ */
39566
+ /** A version WITH its frame list — what the export and a job read. */
39567
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
39568
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39569
+ var TrainingBaseModelSchema = object({
39570
+ modelId: string(),
39571
+ label: string(),
39572
+ weights: string(),
39573
+ imgsz: number().int(),
39574
+ baselineOnnxUrl: string(),
39575
+ baselineFloors: record(string(), number()),
39576
+ /** The base the fleet runs most — the UI's default. */
39577
+ recommended: boolean()
39578
+ });
39579
+ var TrainingPresetSchema = _enum([
39580
+ "quick",
39581
+ "standard",
39582
+ "thorough"
39583
+ ]);
39584
+ var TrainingJobRequestSchema = object({
39585
+ datasetVersionId: string().min(1),
39586
+ /** The `training-provider` addon that runs it. */
39587
+ addonId: string().min(1),
39588
+ gpuType: string().min(1),
39589
+ region: string(),
39590
+ baseModelId: string().min(1),
39591
+ preset: TrainingPresetSchema,
39592
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39593
+ freeze: number().int().nonnegative().nullable(),
39594
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39595
+ holdoutCameras: array(number().int()).nullable()
39596
+ });
39597
+ var TrainingSplitPlanSchema = object({
39598
+ holdoutCameras: array(number().int()).readonly(),
39599
+ /** Used when no camera is held out: the last N days of every camera. */
39600
+ holdoutLastDays: number().int().nonnegative(),
39601
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39602
+ holdoutSupport: record(string(), number().int()).nullable(),
39603
+ trainSubjects: number().int()
39604
+ });
39605
+ var TrainingRefusalReasonSchema = _enum([
39606
+ "unknown-dataset",
39607
+ "unknown-provider",
39608
+ "provider-not-configured",
39609
+ "unknown-base-model",
39610
+ "unknown-gpu",
39611
+ "dataset-too-large",
39612
+ "no-training-subjects",
39613
+ "job-already-running"
39614
+ ]);
39615
+ var TrainingJobPlanSchema = object({
39616
+ refusal: object({
39617
+ reason: TrainingRefusalReasonSchema,
39618
+ detail: string()
39619
+ }).nullable(),
39620
+ warnings: array(string()).readonly(),
39621
+ split: TrainingSplitPlanSchema.nullable(),
39622
+ estimate: object({
39623
+ datasetBytes: number().int(),
39624
+ uploadMinutesAt20Mbps: number(),
39625
+ gpuSecondsLow: number(),
39626
+ gpuSecondsHigh: number(),
39627
+ usdLow: number(),
39628
+ usdHigh: number(),
39629
+ notes: array(string()).readonly()
39630
+ }).nullable(),
39631
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39632
+ defaults: object({
39633
+ maxCostUsd: number(),
39634
+ maxRuntimeSec: number().int()
39635
+ }).nullable(),
39636
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39637
+ dataNotice: string()
39638
+ });
39639
+ /**
39640
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39641
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39642
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39643
+ * result lives after the operator acted on it.
39644
+ */
39645
+ var TrainingJobStateSchema = _enum([
39646
+ "uploading",
39647
+ "submitted",
39648
+ "starting",
39649
+ "running",
39650
+ "collecting",
39651
+ "ready",
39652
+ "registered",
39653
+ "canary",
39654
+ "failed",
39655
+ "cancelling",
39656
+ "cancelled",
39657
+ "lost",
39658
+ "expired",
39659
+ "discarded"
39660
+ ]);
39661
+ var TrainingFailureReasonSchema = _enum([
39662
+ "cost-cap",
39663
+ "runtime-cap",
39664
+ "upload-failed",
39665
+ "submit-failed",
39666
+ "trainer-failed",
39667
+ "result-invalid",
39668
+ "checksum-mismatch",
39669
+ "fetch-failed",
39670
+ "provider-error",
39671
+ "hub-restart-during-upload"
39672
+ ]);
39673
+ var TrainingProgressPointSchema = object({
39674
+ epoch: number().int(),
39675
+ map50: number().nullable(),
39676
+ map50_95: number().nullable()
39677
+ });
39678
+ var TrainingCanarySchema = object({
39679
+ deviceIds: array(number().int()).readonly(),
39680
+ since: number(),
39681
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39682
+ previous: array(object({
39683
+ deviceId: number().int(),
39684
+ nodeId: string(),
39685
+ deviceKey: string(),
39686
+ patch: object({
39687
+ modelId: string().optional(),
39688
+ settings: record(string(), unknown()).readonly().optional()
39689
+ }).nullable()
39690
+ })).readonly()
39691
+ });
39692
+ var TrainingJobSchema = object({
39693
+ id: string(),
39694
+ idempotencyKey: string(),
39695
+ name: string(),
39696
+ createdAt: number(),
39697
+ updatedAt: number(),
39698
+ state: TrainingJobStateSchema,
39699
+ stage: TrainingStageSchema.nullable(),
39700
+ failure: object({
39701
+ reason: TrainingFailureReasonSchema,
39702
+ stage: string().nullable(),
39703
+ detail: string()
39704
+ }).nullable(),
39705
+ request: TrainingJobRequestSchema,
39706
+ maxCostUsd: number().nonnegative(),
39707
+ maxRuntimeSec: number().int().positive(),
39708
+ trainer: TrainerSourceRefSchema,
39709
+ datasetLayout: RetrainExportLayoutSchema,
39710
+ dataset: object({
39711
+ bytes: number().int(),
39712
+ sha256: string(),
39713
+ uploadedAt: number()
39714
+ }).nullable(),
39715
+ split: TrainingSplitPlanSchema,
39716
+ provider: object({
39717
+ state: ProviderJobStateSchema.nullable(),
39718
+ providerJobId: string().nullable(),
39719
+ startedAt: number().nullable(),
39720
+ endedAt: number().nullable(),
39721
+ billedSeconds: number(),
39722
+ costUsd: number(),
39723
+ costIsEstimate: boolean(),
39724
+ lastPolledAt: number().nullable()
39725
+ }),
39726
+ progress: object({
39727
+ epoch: number().int().nullable(),
39728
+ epochs: number().int().nullable(),
39729
+ etaSec: number().nullable(),
39730
+ series: array(TrainingProgressPointSchema).readonly()
39731
+ }),
39732
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
39733
+ logTail: array(string()).readonly(),
39734
+ logCursor: string().nullable(),
39735
+ artifacts: object({
39736
+ bundleBytes: number().int(),
39737
+ bundleSha256: string(),
39738
+ fetchedAt: number(),
39739
+ /** When the staged artefacts are deleted from the hub. */
39740
+ expiresAt: number()
39741
+ }).nullable(),
39742
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
39743
+ cloudDatasetDeletedAt: number().nullable(),
39744
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
39745
+ cloudCleanupDueAt: number().nullable(),
39746
+ /** Model ids registered from this job (base, and int8 when kept). */
39747
+ registeredModelIds: array(string()).readonly(),
39748
+ canary: TrainingCanarySchema.nullable()
39749
+ });
39750
+ var IdInput = object({ id: string().min(1) });
39751
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
39752
+ kind: "mutation",
39753
+ auth: "admin"
39754
+ }), method(IdInput, TrainingDatasetVersionRowSchema.nullable(), { auth: "admin" }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), { auth: "admin" }), method(object({ name: string() }), object({ id: string().nullable() }), { auth: "admin" }), method(IdInput, object({ removed: boolean() }), {
39755
+ kind: "mutation",
39756
+ auth: "admin"
39757
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
39758
+ auth: "admin",
39759
+ timeoutMs: 6e4
39760
+ }), method(TrainingJobRequestSchema.extend({
39761
+ name: string().min(1).max(120),
39762
+ maxCostUsd: number().positive(),
39763
+ maxRuntimeSec: number().int().positive(),
39764
+ idempotencyKey: string().min(8).max(80)
39765
+ }), discriminatedUnion("kind", [object({
39766
+ kind: literal("started"),
39767
+ job: TrainingJobSchema
39768
+ }), object({
39769
+ kind: literal("refused"),
39770
+ reason: TrainingRefusalReasonSchema,
39771
+ detail: string()
39772
+ })]), {
39773
+ kind: "mutation",
39774
+ auth: "admin",
39775
+ timeoutMs: 12e4
39776
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
39777
+ kind: "mutation",
39778
+ auth: "admin",
39779
+ timeoutMs: 12e4
39780
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
39781
+ kind: "mutation",
39782
+ auth: "admin",
39783
+ timeoutMs: 30 * 6e4
39784
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
39785
+ kind: "mutation",
39786
+ auth: "admin",
39787
+ timeoutMs: 12e4
39788
+ }), method(IdInput, TrainingJobSchema, {
39789
+ kind: "mutation",
39790
+ auth: "admin",
39791
+ timeoutMs: 12e4
39792
+ }), method(IdInput, TrainingJobSchema, {
39793
+ kind: "mutation",
39794
+ auth: "admin"
39795
+ });
36675
39796
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
36676
39797
  Object.freeze({
36677
39798
  person: .5,
@@ -36857,6 +39978,12 @@ Object.freeze({
36857
39978
  addonId: null,
36858
39979
  access: "view"
36859
39980
  },
39981
+ "addons.listInstallations": {
39982
+ capName: "addons",
39983
+ capScope: "system",
39984
+ addonId: null,
39985
+ access: "view"
39986
+ },
36860
39987
  "addons.listJobs": {
36861
39988
  capName: "addons",
36862
39989
  capScope: "system",
@@ -37289,6 +40416,12 @@ Object.freeze({
37289
40416
  addonId: null,
37290
40417
  access: "create"
37291
40418
  },
40419
+ "backup.checkBackupKey": {
40420
+ capName: "backup",
40421
+ capScope: "system",
40422
+ addonId: null,
40423
+ access: "create"
40424
+ },
37292
40425
  "backup.delete": {
37293
40426
  capName: "backup",
37294
40427
  capScope: "system",
@@ -37301,6 +40434,18 @@ Object.freeze({
37301
40434
  addonId: null,
37302
40435
  access: "delete"
37303
40436
  },
40437
+ "backup.disableEncryption": {
40438
+ capName: "backup",
40439
+ capScope: "system",
40440
+ addonId: null,
40441
+ access: "create"
40442
+ },
40443
+ "backup.getEncryption": {
40444
+ capName: "backup",
40445
+ capScope: "system",
40446
+ addonId: null,
40447
+ access: "view"
40448
+ },
37304
40449
  "backup.getEntries": {
37305
40450
  capName: "backup",
37306
40451
  capScope: "system",
@@ -37355,6 +40500,12 @@ Object.freeze({
37355
40500
  addonId: null,
37356
40501
  access: "create"
37357
40502
  },
40503
+ "backup.setupEncryption": {
40504
+ capName: "backup",
40505
+ capScope: "system",
40506
+ addonId: null,
40507
+ access: "create"
40508
+ },
37358
40509
  "backup.trigger": {
37359
40510
  capName: "backup",
37360
40511
  capScope: "system",
@@ -37907,6 +41058,12 @@ Object.freeze({
37907
41058
  addonId: null,
37908
41059
  access: "create"
37909
41060
  },
41061
+ "customModelRegistry.importModelBundle": {
41062
+ capName: "custom-model-registry",
41063
+ capScope: "system",
41064
+ addonId: null,
41065
+ access: "create"
41066
+ },
37910
41067
  "customModelRegistry.listModels": {
37911
41068
  capName: "custom-model-registry",
37912
41069
  capScope: "system",
@@ -39317,6 +42474,108 @@ Object.freeze({
39317
42474
  addonId: null,
39318
42475
  access: "create"
39319
42476
  },
42477
+ "keychain.delete": {
42478
+ capName: "keychain",
42479
+ capScope: "system",
42480
+ addonId: null,
42481
+ access: "delete"
42482
+ },
42483
+ "keychain.getState": {
42484
+ capName: "keychain",
42485
+ capScope: "system",
42486
+ addonId: null,
42487
+ access: "view"
42488
+ },
42489
+ "keychain.listMeta": {
42490
+ capName: "keychain",
42491
+ capScope: "system",
42492
+ addonId: null,
42493
+ access: "view"
42494
+ },
42495
+ "keychain.put": {
42496
+ capName: "keychain",
42497
+ capScope: "system",
42498
+ addonId: null,
42499
+ access: "create"
42500
+ },
42501
+ "keychain.resolve": {
42502
+ capName: "keychain",
42503
+ capScope: "system",
42504
+ addonId: null,
42505
+ access: "view"
42506
+ },
42507
+ "keychainAdmin.acknowledgeReset": {
42508
+ capName: "keychain-admin",
42509
+ capScope: "system",
42510
+ addonId: null,
42511
+ access: "create"
42512
+ },
42513
+ "keychainAdmin.deleteOrphans": {
42514
+ capName: "keychain-admin",
42515
+ capScope: "system",
42516
+ addonId: null,
42517
+ access: "delete"
42518
+ },
42519
+ "keychainAdmin.downloadRecoveryKey": {
42520
+ capName: "keychain-admin",
42521
+ capScope: "system",
42522
+ addonId: null,
42523
+ access: "create"
42524
+ },
42525
+ "keychainAdmin.listAudit": {
42526
+ capName: "keychain-admin",
42527
+ capScope: "system",
42528
+ addonId: null,
42529
+ access: "view"
42530
+ },
42531
+ "keychainAdmin.listSecrets": {
42532
+ capName: "keychain-admin",
42533
+ capScope: "system",
42534
+ addonId: null,
42535
+ access: "view"
42536
+ },
42537
+ "keychainAdmin.purgeRetiredKeys": {
42538
+ capName: "keychain-admin",
42539
+ capScope: "system",
42540
+ addonId: null,
42541
+ access: "delete"
42542
+ },
42543
+ "keychainAdmin.resetKeychain": {
42544
+ capName: "keychain-admin",
42545
+ capScope: "system",
42546
+ addonId: null,
42547
+ access: "delete"
42548
+ },
42549
+ "keychainAdmin.resetReport": {
42550
+ capName: "keychain-admin",
42551
+ capScope: "system",
42552
+ addonId: null,
42553
+ access: "delete"
42554
+ },
42555
+ "keychainAdmin.reveal": {
42556
+ capName: "keychain-admin",
42557
+ capScope: "system",
42558
+ addonId: null,
42559
+ access: "create"
42560
+ },
42561
+ "keychainAdmin.rotateMasterKey": {
42562
+ capName: "keychain-admin",
42563
+ capScope: "system",
42564
+ addonId: null,
42565
+ access: "create"
42566
+ },
42567
+ "keychainAdmin.setSystemSecret": {
42568
+ capName: "keychain-admin",
42569
+ capScope: "system",
42570
+ addonId: null,
42571
+ access: "create"
42572
+ },
42573
+ "keychainAdmin.status": {
42574
+ capName: "keychain-admin",
42575
+ capScope: "system",
42576
+ addonId: null,
42577
+ access: "view"
42578
+ },
39320
42579
  "lawnMowerControl.dock": {
39321
42580
  capName: "lawn-mower-control",
39322
42581
  capScope: "device",
@@ -40691,6 +43950,18 @@ Object.freeze({
40691
43950
  addonId: null,
40692
43951
  access: "create"
40693
43952
  },
43953
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
43954
+ capName: "pipeline-analytics",
43955
+ capScope: "device",
43956
+ addonId: null,
43957
+ access: "create"
43958
+ },
43959
+ "pipelineAnalytics.addRetrainFramesToCollection": {
43960
+ capName: "pipeline-analytics",
43961
+ capScope: "device",
43962
+ addonId: null,
43963
+ access: "create"
43964
+ },
40694
43965
  "pipelineAnalytics.applyDeviceSettingsPatch": {
40695
43966
  capName: "pipeline-analytics",
40696
43967
  capScope: "device",
@@ -40739,12 +44010,36 @@ Object.freeze({
40739
44010
  addonId: null,
40740
44011
  access: "view"
40741
44012
  },
44013
+ "pipelineAnalytics.createRetrainCollection": {
44014
+ capName: "pipeline-analytics",
44015
+ capScope: "device",
44016
+ addonId: null,
44017
+ access: "create"
44018
+ },
44019
+ "pipelineAnalytics.createRetrainDatasetVersion": {
44020
+ capName: "pipeline-analytics",
44021
+ capScope: "device",
44022
+ addonId: null,
44023
+ access: "create"
44024
+ },
40742
44025
  "pipelineAnalytics.deleteDeviceEvents": {
40743
44026
  capName: "pipeline-analytics",
40744
44027
  capScope: "device",
40745
44028
  addonId: null,
40746
44029
  access: "delete"
40747
44030
  },
44031
+ "pipelineAnalytics.deleteRetrainCollection": {
44032
+ capName: "pipeline-analytics",
44033
+ capScope: "device",
44034
+ addonId: null,
44035
+ access: "delete"
44036
+ },
44037
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
44038
+ capName: "pipeline-analytics",
44039
+ capScope: "device",
44040
+ addonId: null,
44041
+ access: "delete"
44042
+ },
40748
44043
  "pipelineAnalytics.deleteTracks": {
40749
44044
  capName: "pipeline-analytics",
40750
44045
  capScope: "device",
@@ -40949,6 +44244,30 @@ Object.freeze({
40949
44244
  addonId: null,
40950
44245
  access: "view"
40951
44246
  },
44247
+ "pipelineAnalytics.listRetrainAssistProfiles": {
44248
+ capName: "pipeline-analytics",
44249
+ capScope: "device",
44250
+ addonId: null,
44251
+ access: "view"
44252
+ },
44253
+ "pipelineAnalytics.listRetrainCollectionFrames": {
44254
+ capName: "pipeline-analytics",
44255
+ capScope: "device",
44256
+ addonId: null,
44257
+ access: "view"
44258
+ },
44259
+ "pipelineAnalytics.listRetrainCollections": {
44260
+ capName: "pipeline-analytics",
44261
+ capScope: "device",
44262
+ addonId: null,
44263
+ access: "view"
44264
+ },
44265
+ "pipelineAnalytics.listRetrainDatasetVersions": {
44266
+ capName: "pipeline-analytics",
44267
+ capScope: "device",
44268
+ addonId: null,
44269
+ access: "view"
44270
+ },
40952
44271
  "pipelineAnalytics.listRetrainFrames": {
40953
44272
  capName: "pipeline-analytics",
40954
44273
  capScope: "device",
@@ -40979,6 +44298,12 @@ Object.freeze({
40979
44298
  addonId: null,
40980
44299
  access: "view"
40981
44300
  },
44301
+ "pipelineAnalytics.offerRetrainArchive": {
44302
+ capName: "pipeline-analytics",
44303
+ capScope: "device",
44304
+ addonId: null,
44305
+ access: "create"
44306
+ },
40982
44307
  "pipelineAnalytics.ownersWithMedia": {
40983
44308
  capName: "pipeline-analytics",
40984
44309
  capScope: "device",
@@ -40991,12 +44316,24 @@ Object.freeze({
40991
44316
  addonId: null,
40992
44317
  access: "create"
40993
44318
  },
44319
+ "pipelineAnalytics.previewRetrainDataset": {
44320
+ capName: "pipeline-analytics",
44321
+ capScope: "device",
44322
+ addonId: null,
44323
+ access: "view"
44324
+ },
40994
44325
  "pipelineAnalytics.proposeRetrainAnnotations": {
40995
44326
  capName: "pipeline-analytics",
40996
44327
  capScope: "device",
40997
44328
  addonId: null,
40998
44329
  access: "create"
40999
44330
  },
44331
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
44332
+ capName: "pipeline-analytics",
44333
+ capScope: "device",
44334
+ addonId: null,
44335
+ access: "create"
44336
+ },
41000
44337
  "pipelineAnalytics.pruneEvents": {
41001
44338
  capName: "pipeline-analytics",
41002
44339
  capScope: "device",
@@ -41051,6 +44388,18 @@ Object.freeze({
41051
44388
  addonId: null,
41052
44389
  access: "create"
41053
44390
  },
44391
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
44392
+ capName: "pipeline-analytics",
44393
+ capScope: "device",
44394
+ addonId: null,
44395
+ access: "delete"
44396
+ },
44397
+ "pipelineAnalytics.renameRetrainCollection": {
44398
+ capName: "pipeline-analytics",
44399
+ capScope: "device",
44400
+ addonId: null,
44401
+ access: "create"
44402
+ },
41054
44403
  "pipelineAnalytics.restageRetrainTrack": {
41055
44404
  capName: "pipeline-analytics",
41056
44405
  capScope: "device",
@@ -41081,6 +44430,12 @@ Object.freeze({
41081
44430
  addonId: null,
41082
44431
  access: "create"
41083
44432
  },
44433
+ "pipelineAnalytics.setRetrainFrameComplete": {
44434
+ capName: "pipeline-analytics",
44435
+ capScope: "device",
44436
+ addonId: null,
44437
+ access: "create"
44438
+ },
41084
44439
  "pipelineAnalytics.setTrackFlags": {
41085
44440
  capName: "pipeline-analytics",
41086
44441
  capScope: "device",
@@ -41105,6 +44460,12 @@ Object.freeze({
41105
44460
  addonId: null,
41106
44461
  access: "create"
41107
44462
  },
44463
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
44464
+ capName: "pipeline-analytics",
44465
+ capScope: "device",
44466
+ addonId: null,
44467
+ access: "view"
44468
+ },
41108
44469
  "pipelineAnalytics.wipeAllAnalytics": {
41109
44470
  capName: "pipeline-analytics",
41110
44471
  capScope: "device",
@@ -41117,6 +44478,12 @@ Object.freeze({
41117
44478
  addonId: null,
41118
44479
  access: "delete"
41119
44480
  },
44481
+ "pipelineAnalytics.writeRetrainArchive": {
44482
+ capName: "pipeline-analytics",
44483
+ capScope: "device",
44484
+ addonId: null,
44485
+ access: "create"
44486
+ },
41120
44487
  "pipelineExecutor.cacheFrameInPool": {
41121
44488
  capName: "pipeline-executor",
41122
44489
  capScope: "system",
@@ -41327,6 +44694,12 @@ Object.freeze({
41327
44694
  addonId: null,
41328
44695
  access: "view"
41329
44696
  },
44697
+ "pipelineOrchestrator.abortNodeBenchmark": {
44698
+ capName: "pipeline-orchestrator",
44699
+ capScope: "system",
44700
+ addonId: null,
44701
+ access: "create"
44702
+ },
41330
44703
  "pipelineOrchestrator.applyAutoTune": {
41331
44704
  capName: "pipeline-orchestrator",
41332
44705
  capScope: "system",
@@ -41351,6 +44724,12 @@ Object.freeze({
41351
44724
  addonId: null,
41352
44725
  access: "create"
41353
44726
  },
44727
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
44728
+ capName: "pipeline-orchestrator",
44729
+ capScope: "system",
44730
+ addonId: null,
44731
+ access: "delete"
44732
+ },
41354
44733
  "pipelineOrchestrator.getAgentLoad": {
41355
44734
  capName: "pipeline-orchestrator",
41356
44735
  capScope: "system",
@@ -41459,6 +44838,24 @@ Object.freeze({
41459
44838
  addonId: null,
41460
44839
  access: "view"
41461
44840
  },
44841
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
44842
+ capName: "pipeline-orchestrator",
44843
+ capScope: "system",
44844
+ addonId: null,
44845
+ access: "view"
44846
+ },
44847
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
44848
+ capName: "pipeline-orchestrator",
44849
+ capScope: "system",
44850
+ addonId: null,
44851
+ access: "view"
44852
+ },
44853
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
44854
+ capName: "pipeline-orchestrator",
44855
+ capScope: "system",
44856
+ addonId: null,
44857
+ access: "view"
44858
+ },
41462
44859
  "pipelineOrchestrator.getNodeInferenceDevices": {
41463
44860
  capName: "pipeline-orchestrator",
41464
44861
  capScope: "system",
@@ -41501,6 +44898,12 @@ Object.freeze({
41501
44898
  addonId: null,
41502
44899
  access: "view"
41503
44900
  },
44901
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
44902
+ capName: "pipeline-orchestrator",
44903
+ capScope: "system",
44904
+ addonId: null,
44905
+ access: "view"
44906
+ },
41504
44907
  "pipelineOrchestrator.pauseForStorageMigration": {
41505
44908
  capName: "pipeline-orchestrator",
41506
44909
  capScope: "system",
@@ -41645,6 +45048,12 @@ Object.freeze({
41645
45048
  addonId: null,
41646
45049
  access: "create"
41647
45050
  },
45051
+ "pipelineOrchestrator.startNodeBenchmark": {
45052
+ capName: "pipeline-orchestrator",
45053
+ capScope: "system",
45054
+ addonId: null,
45055
+ access: "create"
45056
+ },
41648
45057
  "pipelineOrchestrator.suggestShares": {
41649
45058
  capName: "pipeline-orchestrator",
41650
45059
  capScope: "system",
@@ -41663,6 +45072,12 @@ Object.freeze({
41663
45072
  addonId: null,
41664
45073
  access: "create"
41665
45074
  },
45075
+ "pipelineRunner.abortNodeBench": {
45076
+ capName: "pipeline-runner",
45077
+ capScope: "system",
45078
+ addonId: null,
45079
+ access: "create"
45080
+ },
41666
45081
  "pipelineRunner.attachCamera": {
41667
45082
  capName: "pipeline-runner",
41668
45083
  capScope: "system",
@@ -41711,6 +45126,12 @@ Object.freeze({
41711
45126
  addonId: null,
41712
45127
  access: "view"
41713
45128
  },
45129
+ "pipelineRunner.getNodeBenchStatus": {
45130
+ capName: "pipeline-runner",
45131
+ capScope: "system",
45132
+ addonId: null,
45133
+ access: "view"
45134
+ },
41714
45135
  "pipelineRunner.getParkedTrackFrame": {
41715
45136
  capName: "pipeline-runner",
41716
45137
  capScope: "system",
@@ -41753,6 +45174,12 @@ Object.freeze({
41753
45174
  addonId: null,
41754
45175
  access: "create"
41755
45176
  },
45177
+ "pipelineRunner.startNodeBench": {
45178
+ capName: "pipeline-runner",
45179
+ capScope: "system",
45180
+ addonId: null,
45181
+ access: "create"
45182
+ },
41756
45183
  "plateGallery.assignPlate": {
41757
45184
  capName: "plate-gallery",
41758
45185
  capScope: "system",
@@ -43415,6 +46842,174 @@ Object.freeze({
43415
46842
  addonId: null,
43416
46843
  access: "view"
43417
46844
  },
46845
+ "training.canaryResult": {
46846
+ capName: "training",
46847
+ capScope: "system",
46848
+ addonId: null,
46849
+ access: "create"
46850
+ },
46851
+ "training.cancelJob": {
46852
+ capName: "training",
46853
+ capScope: "system",
46854
+ addonId: null,
46855
+ access: "create"
46856
+ },
46857
+ "training.discardResult": {
46858
+ capName: "training",
46859
+ capScope: "system",
46860
+ addonId: null,
46861
+ access: "create"
46862
+ },
46863
+ "training.findDatasetVersionIdByName": {
46864
+ capName: "training",
46865
+ capScope: "system",
46866
+ addonId: null,
46867
+ access: "view"
46868
+ },
46869
+ "training.getDatasetVersion": {
46870
+ capName: "training",
46871
+ capScope: "system",
46872
+ addonId: null,
46873
+ access: "view"
46874
+ },
46875
+ "training.getJob": {
46876
+ capName: "training",
46877
+ capScope: "system",
46878
+ addonId: null,
46879
+ access: "view"
46880
+ },
46881
+ "training.getJobResult": {
46882
+ capName: "training",
46883
+ capScope: "system",
46884
+ addonId: null,
46885
+ access: "view"
46886
+ },
46887
+ "training.listBaseModels": {
46888
+ capName: "training",
46889
+ capScope: "system",
46890
+ addonId: null,
46891
+ access: "view"
46892
+ },
46893
+ "training.listDatasetVersions": {
46894
+ capName: "training",
46895
+ capScope: "system",
46896
+ addonId: null,
46897
+ access: "view"
46898
+ },
46899
+ "training.listJobs": {
46900
+ capName: "training",
46901
+ capScope: "system",
46902
+ addonId: null,
46903
+ access: "view"
46904
+ },
46905
+ "training.planJob": {
46906
+ capName: "training",
46907
+ capScope: "system",
46908
+ addonId: null,
46909
+ access: "view"
46910
+ },
46911
+ "training.putDatasetVersion": {
46912
+ capName: "training",
46913
+ capScope: "system",
46914
+ addonId: null,
46915
+ access: "create"
46916
+ },
46917
+ "training.registerResult": {
46918
+ capName: "training",
46919
+ capScope: "system",
46920
+ addonId: null,
46921
+ access: "create"
46922
+ },
46923
+ "training.removeDatasetVersion": {
46924
+ capName: "training",
46925
+ capScope: "system",
46926
+ addonId: null,
46927
+ access: "delete"
46928
+ },
46929
+ "training.rollbackCanary": {
46930
+ capName: "training",
46931
+ capScope: "system",
46932
+ addonId: null,
46933
+ access: "create"
46934
+ },
46935
+ "training.startJob": {
46936
+ capName: "training",
46937
+ capScope: "system",
46938
+ addonId: null,
46939
+ access: "create"
46940
+ },
46941
+ "trainingProvider.cancelJob": {
46942
+ capName: "training-provider",
46943
+ capScope: "system",
46944
+ addonId: null,
46945
+ access: "create"
46946
+ },
46947
+ "trainingProvider.cleanupJob": {
46948
+ capName: "training-provider",
46949
+ capScope: "system",
46950
+ addonId: null,
46951
+ access: "create"
46952
+ },
46953
+ "trainingProvider.describe": {
46954
+ capName: "training-provider",
46955
+ capScope: "system",
46956
+ addonId: null,
46957
+ access: "view"
46958
+ },
46959
+ "trainingProvider.estimateJob": {
46960
+ capName: "training-provider",
46961
+ capScope: "system",
46962
+ addonId: null,
46963
+ access: "view"
46964
+ },
46965
+ "trainingProvider.getJob": {
46966
+ capName: "training-provider",
46967
+ capScope: "system",
46968
+ addonId: null,
46969
+ access: "view"
46970
+ },
46971
+ "trainingProvider.listJobEvents": {
46972
+ capName: "training-provider",
46973
+ capScope: "system",
46974
+ addonId: null,
46975
+ access: "view"
46976
+ },
46977
+ "trainingProvider.listJobs": {
46978
+ capName: "training-provider",
46979
+ capScope: "system",
46980
+ addonId: null,
46981
+ access: "view"
46982
+ },
46983
+ "trainingProvider.offerArtifact": {
46984
+ capName: "training-provider",
46985
+ capScope: "system",
46986
+ addonId: null,
46987
+ access: "create"
46988
+ },
46989
+ "trainingProvider.readResult": {
46990
+ capName: "training-provider",
46991
+ capScope: "system",
46992
+ addonId: null,
46993
+ access: "create"
46994
+ },
46995
+ "trainingProvider.submitJob": {
46996
+ capName: "training-provider",
46997
+ capScope: "system",
46998
+ addonId: null,
46999
+ access: "create"
47000
+ },
47001
+ "trainingProvider.uploadDataset": {
47002
+ capName: "training-provider",
47003
+ capScope: "system",
47004
+ addonId: null,
47005
+ access: "create"
47006
+ },
47007
+ "trainingProvider.validateCredentials": {
47008
+ capName: "training-provider",
47009
+ capScope: "system",
47010
+ addonId: null,
47011
+ access: "create"
47012
+ },
43418
47013
  "turnProvider.getTurnServers": {
43419
47014
  capName: "turn-provider",
43420
47015
  capScope: "system",
@@ -43439,12 +47034,6 @@ Object.freeze({
43439
47034
  addonId: null,
43440
47035
  access: "create"
43441
47036
  },
43442
- "userManagement.createApiKey": {
43443
- capName: "user-management",
43444
- capScope: "system",
43445
- addonId: null,
43446
- access: "create"
43447
- },
43448
47037
  "userManagement.createScopedToken": {
43449
47038
  capName: "user-management",
43450
47039
  capScope: "system",
@@ -43469,6 +47058,12 @@ Object.freeze({
43469
47058
  addonId: null,
43470
47059
  access: "delete"
43471
47060
  },
47061
+ "userManagement.findUserByExternalIdentity": {
47062
+ capName: "user-management",
47063
+ capScope: "system",
47064
+ addonId: null,
47065
+ access: "view"
47066
+ },
43472
47067
  "userManagement.getTotpStatus": {
43473
47068
  capName: "user-management",
43474
47069
  capScope: "system",
@@ -43481,6 +47076,12 @@ Object.freeze({
43481
47076
  addonId: null,
43482
47077
  access: "view"
43483
47078
  },
47079
+ "userManagement.listExternalIdentities": {
47080
+ capName: "user-management",
47081
+ capScope: "system",
47082
+ addonId: null,
47083
+ access: "view"
47084
+ },
43484
47085
  "userManagement.listOauthSessions": {
43485
47086
  capName: "user-management",
43486
47087
  capScope: "system",
@@ -43559,17 +47160,17 @@ Object.freeze({
43559
47160
  addonId: null,
43560
47161
  access: "create"
43561
47162
  },
43562
- "userManagement.updateUser": {
47163
+ "userManagement.unlinkExternalIdentity": {
43563
47164
  capName: "user-management",
43564
47165
  capScope: "system",
43565
47166
  addonId: null,
43566
- access: "create"
47167
+ access: "delete"
43567
47168
  },
43568
- "userManagement.validateApiKey": {
47169
+ "userManagement.updateUser": {
43569
47170
  capName: "user-management",
43570
47171
  capScope: "system",
43571
47172
  addonId: null,
43572
- access: "view"
47173
+ access: "create"
43573
47174
  },
43574
47175
  "userManagement.validateCredentials": {
43575
47176
  capName: "user-management",
@@ -46658,6 +50259,11 @@ Object.freeze({
46658
50259
  form: "single",
46659
50260
  optional: false
46660
50261
  }],
50262
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
50263
+ name: "deviceId",
50264
+ form: "single",
50265
+ optional: false
50266
+ }],
46661
50267
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
46662
50268
  name: "deviceId",
46663
50269
  form: "single",
@@ -46848,6 +50454,11 @@ Object.freeze({
46848
50454
  form: "single",
46849
50455
  optional: false
46850
50456
  }],
50457
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
50458
+ name: "deviceId",
50459
+ form: "single",
50460
+ optional: false
50461
+ }],
46851
50462
  "pipelineAnalytics.pruneEventsBefore": [{
46852
50463
  name: "deviceId",
46853
50464
  form: "single",
@@ -46898,6 +50509,11 @@ Object.freeze({
46898
50509
  form: "single",
46899
50510
  optional: false
46900
50511
  }],
50512
+ "pipelineAnalytics.setRetrainFrameComplete": [{
50513
+ name: "deviceId",
50514
+ form: "single",
50515
+ optional: false
50516
+ }],
46901
50517
  "pipelineAnalytics.setTrackFlags": [{
46902
50518
  name: "deviceId",
46903
50519
  form: "single",
@@ -47669,6 +51285,11 @@ Object.freeze({
47669
51285
  form: "single",
47670
51286
  optional: false
47671
51287
  }],
51288
+ "training.canaryResult": [{
51289
+ name: "deviceIds",
51290
+ form: "array",
51291
+ optional: false
51292
+ }],
47672
51293
  "update.getStatus": [{
47673
51294
  name: "deviceId",
47674
51295
  form: "single",