@camstack/addon-model-studio 1.1.218 → 1.1.220

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 (19) hide show
  1. package/dist/{MotionZonesSettings-Capre9Um.mjs → MotionZonesSettings-RLi86Dlo.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-CTeuaW76.mjs → PrivacyMaskSettings-BLFXfOAe.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-B_wS3Aqg.mjs → SceneMonitorEditor-iPKa6teM.mjs} +3 -3
  4. package/dist/_stub.js +4228 -4228
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-WTUyarUL.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-CTVSBRdm.mjs} +3 -3
  6. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-TGkmHscN.mjs +26 -0
  7. package/dist/addon-model-studio.css +1 -1
  8. package/dist/{hostInit-N-aNmJfG.mjs → hostInit-_Xl3Xebm.mjs} +2 -2
  9. package/dist/model-studio.addon.js +1904 -55
  10. package/dist/model-studio.addon.mjs +1904 -55
  11. package/dist/{player-overlays-CYNFSDYV.mjs → player-overlays-DFRwweAg.mjs} +1 -1
  12. package/dist/remoteEntry.js +1 -1
  13. package/dist/{responsive-oZzHP3lx.mjs → responsive-Bsh36MLy.mjs} +1 -1
  14. package/dist/{scene-monitor-copy-C2YKn7wo.mjs → scene-monitor-copy-DT36bTgI.mjs} +1 -1
  15. package/dist/{square-DUBjO0Wq.mjs → square-Bixsl2bJ.mjs} +1 -1
  16. package/dist/{trash-2-DpaexsRt.mjs → trash-2-dJ4x-ifm.mjs} +1 -1
  17. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-BA6FOYZy.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-BHni-aXq.mjs} +1 -1
  18. package/package.json +1 -1
  19. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CE6l15x5.mjs +0 -26
@@ -393,7 +393,7 @@ function buildScryptedRegistryDescriptor(entry) {
393
393
  };
394
394
  }
395
395
  //#endregion
396
- //#region ../types/dist/event-category-B_0XEcLF.mjs
396
+ //#region ../types/dist/event-category-DaIZi00R.mjs
397
397
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
398
398
  EventCategory["SystemBoot"] = "system.boot";
399
399
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -472,6 +472,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
472
472
  */
473
473
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
474
474
  /**
475
+ * A keychain value was stored or removed (D787). Carries the ref, its
476
+ * owner and the new version — NEVER the value. A process holding the ref
477
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
478
+ * Telemetry (D8): a process that misses it still revalidates by version.
479
+ */
480
+ EventCategory["KeychainChanged"] = "keychain.changed";
481
+ /**
475
482
  * Addon recovered from a previous failure. Emitted when an addon
476
483
  * transitions from `failed` back to `healthy` (typically via the
477
484
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5764,7 +5771,7 @@ var ZodIssueCode = {
5764
5771
  var ZodFirstPartyTypeKind;
5765
5772
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5766
5773
  //#endregion
5767
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5774
+ //#region ../types/dist/sleep-DujUvOcb.mjs
5768
5775
  /**
5769
5776
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5770
5777
  * window to float samples (D455).
@@ -5843,6 +5850,97 @@ function buildAlawTable() {
5843
5850
  }
5844
5851
  buildUlawTable();
5845
5852
  buildAlawTable();
5853
+ /** Is this field's stored value a credential? */
5854
+ function isSecretConfigField(field) {
5855
+ if (field.type === "password") return true;
5856
+ return "secret" in field && field.secret === true;
5857
+ }
5858
+ /**
5859
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5860
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5861
+ */
5862
+ function isKeychainStoredField(field) {
5863
+ if (!isSecretConfigField(field)) return false;
5864
+ if (field.type === "textarea" && field.isJson === true) return false;
5865
+ return !("storage" in field && field.storage === "inline");
5866
+ }
5867
+ /**
5868
+ * What a settings blob holds where a secret used to be.
5869
+ *
5870
+ * A keychain-stored field never holds its value. It holds a self-describing
5871
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5872
+ * code can mistake it for a credential and no form can send it to a camera as
5873
+ * a password. The empty state is `null` / absent, never `''`.
5874
+ *
5875
+ * The same shapes travel to and from the admin UI:
5876
+ *
5877
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5878
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5879
+ * value is set, never the value.
5880
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5881
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5882
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5883
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5884
+ * treating it as "clear" is how a save destroyed a stored credential before.
5885
+ *
5886
+ * Pure and browser-safe.
5887
+ */
5888
+ var SECRET_CLEAR = { $secretClear: true };
5889
+ /** The `'***'` token D634 redaction writes for non-admins. */
5890
+ var LEGACY_DEVICE_REDACTION = "***";
5891
+ function isRecord$1(value) {
5892
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5893
+ }
5894
+ function makeSecretMarker(ref) {
5895
+ return {
5896
+ $secret: ref,
5897
+ v: 1
5898
+ };
5899
+ }
5900
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5901
+ function isSecretMarker(value) {
5902
+ if (!isRecord$1(value)) return false;
5903
+ const ref = value["$secret"];
5904
+ return typeof ref === "string" && ref.length > 0;
5905
+ }
5906
+ function isSecretClear(value) {
5907
+ return isRecord$1(value) && value["$secretClear"] === true;
5908
+ }
5909
+ /**
5910
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5911
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5912
+ * survives this function.
5913
+ */
5914
+ function toSecretFieldView(stored) {
5915
+ if (isSecretMarker(stored)) return {
5916
+ $secret: stored.$secret,
5917
+ v: 1,
5918
+ set: true
5919
+ };
5920
+ if (typeof stored === "string" && stored.length > 0) return {
5921
+ $secret: null,
5922
+ v: 1,
5923
+ set: true,
5924
+ inline: true
5925
+ };
5926
+ return null;
5927
+ }
5928
+ /**
5929
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5930
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5931
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5932
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5933
+ */
5934
+ function classifySecretWrite(incoming) {
5935
+ if (isSecretClear(incoming)) return { kind: "clear" };
5936
+ if (typeof incoming !== "string") return { kind: "keep" };
5937
+ if (incoming.length === 0) return { kind: "keep" };
5938
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5939
+ return {
5940
+ kind: "set",
5941
+ value: incoming
5942
+ };
5943
+ }
5846
5944
  Object.fromEntries([
5847
5945
  {
5848
5946
  id: "overview",
@@ -6014,33 +6112,19 @@ Object.fromEntries([
6014
6112
  function isValuelessField(field) {
6015
6113
  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";
6016
6114
  }
6017
- /**
6018
- * Merge a `ConfigUISchema` with a raw `values` record into a
6019
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
6020
- * before returning to the admin UI. Groups are walked recursively.
6021
- *
6022
- * For each leaf field:
6023
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
6024
- * - other fields get `value = values[key] ?? field.default ?? null`
6025
- *
6026
- * Unknown keys in `values` (keys not declared in the schema) are silently
6027
- * ignored — they don't contribute to the output. Missing keys fall back to
6028
- * the schema default or `null`. This mirrors the old backend behaviour where
6029
- * `FormBuilder` rendered `values[key] ?? field.default`.
6030
- */
6031
- function hydrateSchema(schema, values) {
6115
+ function hydrateSchema(schema, values, options = {}) {
6032
6116
  return {
6033
6117
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
6034
6118
  sections: schema.sections.map((section) => ({
6035
6119
  ...section,
6036
- fields: section.fields.map((field) => hydrateField(field, values))
6120
+ fields: section.fields.map((field) => hydrateField(field, values, options))
6037
6121
  }))
6038
6122
  };
6039
6123
  }
6040
- function hydrateField(field, values) {
6124
+ function hydrateField(field, values, options) {
6041
6125
  if (isValuelessField(field)) return field;
6042
6126
  if (field.type === "group") {
6043
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
6127
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
6044
6128
  return {
6045
6129
  ...field,
6046
6130
  fields: hydratedChildren
@@ -6049,7 +6133,7 @@ function hydrateField(field, values) {
6049
6133
  if (field.type === "sub-tabs") {
6050
6134
  const hydratedTabs = field.tabs.map((tab) => ({
6051
6135
  ...tab,
6052
- fields: tab.fields.map((child) => hydrateField(child, values))
6136
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
6053
6137
  }));
6054
6138
  return {
6055
6139
  ...field,
@@ -6059,6 +6143,33 @@ function hydrateField(field, values) {
6059
6143
  const key = field.key;
6060
6144
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
6061
6145
  const defaultValue = field.default;
6146
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
6147
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
6148
+ ...field,
6149
+ value: toSecretFieldView(storedValue)
6150
+ };
6151
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
6152
+ ...field,
6153
+ value: null
6154
+ };
6155
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
6156
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
6157
+ if (secretItemKeys.length > 0) {
6158
+ const rows = storedValue.map((row) => {
6159
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
6160
+ const out = { ...row };
6161
+ for (const k of secretItemKeys) {
6162
+ const v = Reflect.get(row, k);
6163
+ if (asView(v)) out[k] = toSecretFieldView(v);
6164
+ }
6165
+ return out;
6166
+ });
6167
+ return {
6168
+ ...field,
6169
+ value: rows
6170
+ };
6171
+ }
6172
+ }
6062
6173
  if (field.multiple) {
6063
6174
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
6064
6175
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -6301,6 +6412,431 @@ function projectStore(store, perNodeKeys, nodeId) {
6301
6412
  }
6302
6413
  return out;
6303
6414
  }
6415
+ var GLOBAL_SCOPE = { kind: "global" };
6416
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6417
+ function globalSecretScope() {
6418
+ return GLOBAL_SCOPE;
6419
+ }
6420
+ function encodeSegment(value) {
6421
+ return encodeURIComponent(value);
6422
+ }
6423
+ /**
6424
+ * The field path of a value inside an array item, addressed by the item's id:
6425
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6426
+ * `providers[authentik].clientSecret`.
6427
+ */
6428
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6429
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6430
+ }
6431
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6432
+ var KeychainWriteRefusedError = class extends Error {
6433
+ fieldPath;
6434
+ constructor(fieldPath, cause) {
6435
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6436
+ this.fieldPath = fieldPath;
6437
+ this.name = "KeychainWriteRefusedError";
6438
+ }
6439
+ };
6440
+ var KEEP = { kind: "keep" };
6441
+ function isRecord$2(value) {
6442
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6443
+ }
6444
+ function defaultMintId() {
6445
+ return globalThis.crypto.randomUUID();
6446
+ }
6447
+ /** Every marker ref anywhere under `value`. */
6448
+ function collectSecretMarkerRefs(value, out = []) {
6449
+ if (isSecretMarker(value)) {
6450
+ out.push(value.$secret);
6451
+ return out;
6452
+ }
6453
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6454
+ else if (isRecord$2(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6455
+ return out;
6456
+ }
6457
+ async function storedValueEquals(secrets, marker, candidate) {
6458
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6459
+ return resolved?.kind === "value" && resolved.value === candidate;
6460
+ }
6461
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6462
+ const intent = classifySecretWrite(incoming);
6463
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6464
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6465
+ if (intent.kind === "keep") return KEEP;
6466
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6467
+ if (intent.kind === "clear") {
6468
+ if (storedIsOurs) ctx.deletes.push(ref);
6469
+ return {
6470
+ kind: "value",
6471
+ value: null
6472
+ };
6473
+ }
6474
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6475
+ kind: "value",
6476
+ value: stored
6477
+ };
6478
+ try {
6479
+ await ctx.secrets.put(ref, intent.value);
6480
+ } catch (err) {
6481
+ throw new KeychainWriteRefusedError(fieldPath, err);
6482
+ }
6483
+ return {
6484
+ kind: "value",
6485
+ value: makeSecretMarker(ref)
6486
+ };
6487
+ }
6488
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6489
+ function applyMember(out, key, result, storedParent) {
6490
+ if (result.kind === "value") {
6491
+ out[key] = result.value;
6492
+ return;
6493
+ }
6494
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6495
+ else delete out[key];
6496
+ }
6497
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6498
+ const out = { ...incoming };
6499
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6500
+ return out;
6501
+ }
6502
+ function rowId(row, idKey) {
6503
+ const raw = row[idKey];
6504
+ if (typeof raw === "string" && raw.length > 0) return raw;
6505
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6506
+ return null;
6507
+ }
6508
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6509
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$2) : [];
6510
+ if (!Array.isArray(incoming)) {
6511
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6512
+ return {
6513
+ kind: "value",
6514
+ value: incoming
6515
+ };
6516
+ }
6517
+ const storedById = /* @__PURE__ */ new Map();
6518
+ for (const row of storedRows) {
6519
+ const id = rowId(row, node.idKey);
6520
+ if (id !== null) storedById.set(id, row);
6521
+ }
6522
+ const kept = /* @__PURE__ */ new Set();
6523
+ const rows = [];
6524
+ for (const row of incoming) {
6525
+ if (!isRecord$2(row)) {
6526
+ rows.push(row);
6527
+ continue;
6528
+ }
6529
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6530
+ kept.add(id);
6531
+ const withId = {
6532
+ ...row,
6533
+ [node.idKey]: row[node.idKey] ?? id
6534
+ };
6535
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6536
+ const storedRow = storedById.get(id) ?? {};
6537
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6538
+ }
6539
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6540
+ return {
6541
+ kind: "value",
6542
+ value: rows
6543
+ };
6544
+ }
6545
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6546
+ switch (node.kind) {
6547
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6548
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6549
+ case "object": {
6550
+ if (!isRecord$2(incoming)) {
6551
+ if (incoming === void 0) return KEEP;
6552
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6553
+ return {
6554
+ kind: "value",
6555
+ value: incoming
6556
+ };
6557
+ }
6558
+ const storedObj = isRecord$2(stored) ? stored : {};
6559
+ return {
6560
+ kind: "value",
6561
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6562
+ };
6563
+ }
6564
+ }
6565
+ }
6566
+ /** Split a perNode-scoped key (`key@nodeId`). */
6567
+ function splitNodeKey(key) {
6568
+ const at = key.indexOf("@");
6569
+ return at <= 0 ? {
6570
+ base: key,
6571
+ nodeId: null
6572
+ } : {
6573
+ base: key.slice(0, at),
6574
+ nodeId: key.slice(at + 1)
6575
+ };
6576
+ }
6577
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6578
+ async function transformSecretWrite(input) {
6579
+ const deletes = [];
6580
+ const base = {
6581
+ secrets: input.secrets,
6582
+ mintId: input.mintId ?? defaultMintId,
6583
+ deletes,
6584
+ operatorWrite: input.operatorWrite === true
6585
+ };
6586
+ const out = {};
6587
+ for (const [key, incoming] of Object.entries(input.patch)) {
6588
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6589
+ const node = input.tree.get(baseKey);
6590
+ if (node === void 0) {
6591
+ out[key] = incoming;
6592
+ continue;
6593
+ }
6594
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6595
+ kind: "node",
6596
+ nodeId
6597
+ } : input.scope ?? globalSecretScope();
6598
+ const result = await writeNode({
6599
+ ...base,
6600
+ scope
6601
+ }, node, incoming, input.stored[key], baseKey);
6602
+ if (result.kind === "value") out[key] = result.value;
6603
+ }
6604
+ return {
6605
+ patch: out,
6606
+ afterWrite: async () => {
6607
+ if (deletes.length === 0) return { orphaned: [] };
6608
+ try {
6609
+ await input.secrets.delete([...new Set(deletes)]);
6610
+ return { orphaned: [] };
6611
+ } catch {
6612
+ return { orphaned: [...new Set(deletes)] };
6613
+ }
6614
+ }
6615
+ };
6616
+ }
6617
+ /**
6618
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6619
+ * reference when there is no marker (no allocation, no keychain call).
6620
+ */
6621
+ async function resolveSecretMarkers(value, secrets) {
6622
+ const refs = collectSecretMarkerRefs(value);
6623
+ if (refs.length === 0) return {
6624
+ value,
6625
+ unresolved: []
6626
+ };
6627
+ const answers = await secrets.resolve(refs);
6628
+ const unresolved = [];
6629
+ for (const ref of new Set(refs)) {
6630
+ const answer = answers[ref];
6631
+ if (answer === void 0) unresolved.push({
6632
+ ref,
6633
+ reason: "not-initialized"
6634
+ });
6635
+ else if (answer.kind === "unavailable") unresolved.push({
6636
+ ref,
6637
+ reason: answer.reason
6638
+ });
6639
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6640
+ ref,
6641
+ reason: answer.kind
6642
+ });
6643
+ }
6644
+ const substitute = (v) => {
6645
+ if (isSecretMarker(v)) {
6646
+ const answer = answers[v.$secret];
6647
+ return answer?.kind === "value" ? {
6648
+ keep: true,
6649
+ value: answer.value
6650
+ } : {
6651
+ keep: false,
6652
+ value: void 0
6653
+ };
6654
+ }
6655
+ if (Array.isArray(v)) {
6656
+ const items = [];
6657
+ for (const item of v) {
6658
+ const s = substitute(item);
6659
+ if (s.keep) items.push(s.value);
6660
+ }
6661
+ return {
6662
+ keep: true,
6663
+ value: items
6664
+ };
6665
+ }
6666
+ if (isRecord$2(v)) {
6667
+ const out = {};
6668
+ for (const [k, child] of Object.entries(v)) {
6669
+ const s = substitute(child);
6670
+ if (s.keep) out[k] = s.value;
6671
+ }
6672
+ return {
6673
+ keep: true,
6674
+ value: out
6675
+ };
6676
+ }
6677
+ return {
6678
+ keep: true,
6679
+ value: v
6680
+ };
6681
+ };
6682
+ return {
6683
+ value: substitute(value).value,
6684
+ unresolved
6685
+ };
6686
+ }
6687
+ function touchesTree(tree, patch) {
6688
+ if (tree.size === 0) return false;
6689
+ for (const key of Object.keys(patch)) {
6690
+ const at = key.indexOf("@");
6691
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6692
+ }
6693
+ return false;
6694
+ }
6695
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6696
+ async function readStoredAddonBlob(raw) {
6697
+ const threeWay = raw.readAddonStoreResult;
6698
+ if (threeWay === void 0) return raw.readAddonStore();
6699
+ const result = await threeWay.call(raw);
6700
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6701
+ return result.kind === "missing" ? {} : result.value;
6702
+ }
6703
+ function createSecretAwareSettings(raw, opts) {
6704
+ const chains = /* @__PURE__ */ new Map();
6705
+ const serialize = (key, fn) => {
6706
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6707
+ const tail = next.catch(() => void 0);
6708
+ chains.set(key, tail);
6709
+ tail.then(() => {
6710
+ if (chains.get(key) === tail) chains.delete(key);
6711
+ });
6712
+ return next;
6713
+ };
6714
+ const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6715
+ if (!touchesTree(tree, patch)) return rawWrite(patch);
6716
+ return serialize(chainKey, async () => {
6717
+ const stored = await readStored();
6718
+ const result = await transformSecretWrite({
6719
+ tree,
6720
+ secrets: opts.secrets,
6721
+ patch,
6722
+ stored,
6723
+ ...scope !== void 0 ? { scope } : {},
6724
+ operatorWrite: opts.isOperatorWrite?.() === true
6725
+ });
6726
+ if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6727
+ const { orphaned } = await result.afterWrite();
6728
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6729
+ });
6730
+ };
6731
+ const wrapped = {
6732
+ writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6733
+ writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6734
+ kind: "device",
6735
+ deviceId
6736
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6737
+ };
6738
+ return new Proxy(raw, { get(target, prop, receiver) {
6739
+ if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6740
+ if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6741
+ const value = Reflect.get(target, prop, receiver);
6742
+ return typeof value === "function" ? value.bind(target) : value;
6743
+ } });
6744
+ }
6745
+ /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6746
+ function withSecretAwareSettings(context, opts) {
6747
+ const raw = context.settings;
6748
+ if (raw === void 0) return context;
6749
+ const settings = createSecretAwareSettings(raw, opts);
6750
+ return new Proxy(context, { get(target, prop, receiver) {
6751
+ if (prop === "settings") return settings;
6752
+ return Reflect.get(target, prop, receiver);
6753
+ } });
6754
+ }
6755
+ var LEAF = { kind: "leaf" };
6756
+ var DEFAULT_ITEM_ID_KEY = "id";
6757
+ function collectFields(fields, out) {
6758
+ for (const field of fields) {
6759
+ if (field.type === "group") {
6760
+ collectFields(field.fields, out);
6761
+ continue;
6762
+ }
6763
+ if (field.type === "sub-tabs") {
6764
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6765
+ continue;
6766
+ }
6767
+ if (field.type === "editable-array") {
6768
+ const item = /* @__PURE__ */ new Map();
6769
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6770
+ if (item.size > 0) out.set(field.key, {
6771
+ kind: "array",
6772
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6773
+ item
6774
+ });
6775
+ continue;
6776
+ }
6777
+ if (!("key" in field) || typeof field.key !== "string") continue;
6778
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6779
+ }
6780
+ }
6781
+ /** The secret tree a settings schema declares. */
6782
+ function secretTreeFromSchema(schema) {
6783
+ const out = /* @__PURE__ */ new Map();
6784
+ if (schema === null) return out;
6785
+ for (const section of schema.sections) collectFields(section.fields, out);
6786
+ return out;
6787
+ }
6788
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6789
+ function parseSecretStatePath(path) {
6790
+ const segments = [];
6791
+ for (const raw of path.split(".")) {
6792
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6793
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6794
+ segments.push(m[2] !== void 0 ? {
6795
+ key: m[1],
6796
+ idKey: m[2]
6797
+ } : { key: m[1] });
6798
+ }
6799
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6800
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6801
+ return segments;
6802
+ }
6803
+ function insert(into, segments) {
6804
+ const [head, ...rest] = segments;
6805
+ if (head === void 0) return;
6806
+ if (rest.length === 0) {
6807
+ into.set(head.key, LEAF);
6808
+ return;
6809
+ }
6810
+ const existing = into.get(head.key);
6811
+ if (head.idKey !== void 0) {
6812
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6813
+ insert(item, rest);
6814
+ into.set(head.key, {
6815
+ kind: "array",
6816
+ idKey: head.idKey,
6817
+ item
6818
+ });
6819
+ return;
6820
+ }
6821
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6822
+ insert(children, rest);
6823
+ into.set(head.key, {
6824
+ kind: "object",
6825
+ children
6826
+ });
6827
+ }
6828
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6829
+ function mergeSecretStatePaths(tree, paths) {
6830
+ if (paths.length === 0) return tree;
6831
+ const out = new Map(tree);
6832
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6833
+ return out;
6834
+ }
6835
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6836
+ var SECRET_RETRY_FIRST_MS = 5e3;
6837
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6838
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6839
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
6304
6840
  /**
6305
6841
  * Base class for CamStack addons. Eliminates settings boilerplate:
6306
6842
  *
@@ -6370,6 +6906,25 @@ var BaseAddon = class {
6370
6906
  settingsStoreReady = false;
6371
6907
  /** Default config values. Provided via constructor. */
6372
6908
  defaults;
6909
+ /**
6910
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6911
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6912
+ * Stored in the keychain exactly like a `password` field. Syntax:
6913
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6914
+ * (`key[<id field>]` addresses array items by id, never by index).
6915
+ */
6916
+ secretStatePaths = [];
6917
+ _addonSecretTree = null;
6918
+ _deviceSecretTree = null;
6919
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6920
+ _configSecretRefs = /* @__PURE__ */ new Set();
6921
+ _unresolvedSecrets = [];
6922
+ _secretRetryTimer = null;
6923
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6924
+ _secretChangeTimer = null;
6925
+ _secretChangeUnsub = null;
6926
+ /** >0 while an OPERATOR's settings write is being applied. */
6927
+ _operatorWriteDepth = 0;
6373
6928
  constructor(defaults) {
6374
6929
  this.defaults = defaults;
6375
6930
  this._config = { ...defaults };
@@ -6405,8 +6960,18 @@ var BaseAddon = class {
6405
6960
  return this._config;
6406
6961
  }
6407
6962
  async initialize(context) {
6408
- this._ctx = context;
6963
+ const secrets = context.secrets;
6964
+ this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6965
+ secrets,
6966
+ addonTree: () => this.addonSecretTree(),
6967
+ deviceTree: () => this.deviceSecretTree(),
6968
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6969
+ isOperatorWrite: () => this._operatorWriteDepth > 0
6970
+ }) : context;
6409
6971
  await this.resolveConfig();
6972
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6973
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6974
+ });
6410
6975
  const result = await this.onInitialize();
6411
6976
  this.emitLifecycle(EventCategory.AddonStarted);
6412
6977
  const normalized = normalizeAddonInitResult(result);
@@ -6439,6 +7004,12 @@ var BaseAddon = class {
6439
7004
  */
6440
7005
  async onHubReachable() {}
6441
7006
  async shutdown() {
7007
+ this._secretChangeUnsub?.();
7008
+ this._secretChangeUnsub = null;
7009
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
7010
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
7011
+ this._secretRetryTimer = null;
7012
+ this._secretChangeTimer = null;
6442
7013
  this.emitLifecycle(EventCategory.AddonStopped);
6443
7014
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6444
7015
  await this.onShutdown();
@@ -6517,7 +7088,7 @@ var BaseAddon = class {
6517
7088
  return hydrateSchema(schema, overlay ? {
6518
7089
  ...projected,
6519
7090
  ...overlay
6520
- } : projected);
7091
+ } : projected, { inlineSecretsAsViews: true });
6521
7092
  }
6522
7093
  /**
6523
7094
  * The integration-level view of this addon's settings: exactly the sections
@@ -6566,7 +7137,7 @@ var BaseAddon = class {
6566
7137
  return hydrateSchema({
6567
7138
  ...schema,
6568
7139
  sections
6569
- }, projected);
7140
+ }, projected, { inlineSecretsAsViews: true });
6570
7141
  }
6571
7142
  /**
6572
7143
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6620,18 +7191,50 @@ var BaseAddon = class {
6620
7191
  value: result.value[key]
6621
7192
  };
6622
7193
  }
7194
+ /**
7195
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7196
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7197
+ * the operator sends is stored as sent even when it equals a pre-keychain
7198
+ * inline value: the operator re-entering a password is a change, an addon
7199
+ * writing back what it read is not (D787).
7200
+ */
7201
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7202
+ this._operatorWriteDepth++;
7203
+ try {
7204
+ await this.applyGlobalPatch(patch, nodeId);
7205
+ } finally {
7206
+ this._operatorWriteDepth--;
7207
+ }
7208
+ }
6623
7209
  async updateGlobalSettings(patch, nodeId) {
7210
+ await this.applyGlobalPatch(patch, nodeId);
7211
+ }
7212
+ /**
7213
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7214
+ *
7215
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7216
+ * what a defaults fallback writes back, and it must never destroy a
7217
+ * credential), so code that means "forget this token" says so here. Without
7218
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7219
+ */
7220
+ async clearSecrets(keys, nodeId) {
7221
+ const tree = this.addonSecretTree();
7222
+ const keychain = this._ctx?.secrets !== void 0;
7223
+ const patch = {};
7224
+ for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7225
+ await this.applyGlobalPatch(patch, nodeId);
7226
+ }
7227
+ async applyGlobalPatch(barePatch, nodeId) {
6624
7228
  const keys = this.perNodeKeys();
6625
7229
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6626
7230
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6627
- const barePatch = patch;
6628
7231
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6629
7232
  await this._ctx?.settings?.writeAddonStore(scoped);
6630
7233
  if (target !== localNode) return;
6631
7234
  await this.resolveConfig();
6632
7235
  await this.onConfigChanged();
6633
7236
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6634
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7237
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6635
7238
  }
6636
7239
  /**
6637
7240
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6656,7 +7259,7 @@ var BaseAddon = class {
6656
7259
  * time to return its response before the addon is torn down and
6657
7260
  * re-initialised by `AddonRegistryService.restartAddon`.
6658
7261
  */
6659
- maybeAutoRestart(patch, schema) {
7262
+ maybeAutoRestart(patchKeys, schema) {
6660
7263
  if (!schema) return;
6661
7264
  const restartKeys = /* @__PURE__ */ new Set();
6662
7265
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6664,13 +7267,13 @@ var BaseAddon = class {
6664
7267
  if (field.requiresRestart) restartKeys.add(field.key);
6665
7268
  }
6666
7269
  if (restartKeys.size === 0) return;
6667
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7270
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6668
7271
  const ctx = this._ctx;
6669
7272
  if (!ctx) return;
6670
7273
  const addonId = ctx.id;
6671
7274
  setImmediate(() => {
6672
7275
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6673
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7276
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6674
7277
  }).catch((err) => {
6675
7278
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6676
7279
  });
@@ -6679,7 +7282,7 @@ var BaseAddon = class {
6679
7282
  async getDeviceSettings(deviceId) {
6680
7283
  const schema = this.deviceSettingsSchema();
6681
7284
  if (!schema) return { sections: [] };
6682
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7285
+ return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6683
7286
  }
6684
7287
  async updateDeviceSettings(deviceId, patch) {
6685
7288
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6809,7 +7412,7 @@ var BaseAddon = class {
6809
7412
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6810
7413
  */
6811
7414
  async resolveConfig() {
6812
- const stored = await this.readAddonStoreWithRetry();
7415
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6813
7416
  const perNode = this.perNodeKeys();
6814
7417
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6815
7418
  const resolved = { ...this.defaults };
@@ -6834,7 +7437,7 @@ var BaseAddon = class {
6834
7437
  key,
6835
7438
  schema,
6836
7439
  fallback,
6837
- read: () => this.readAddonStoreWithRetry(),
7440
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6838
7441
  write: async (patch) => {
6839
7442
  await this._ctx?.settings?.writeAddonStore(patch);
6840
7443
  },
@@ -6851,7 +7454,7 @@ var BaseAddon = class {
6851
7454
  key,
6852
7455
  schema,
6853
7456
  fallback,
6854
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7457
+ read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
6855
7458
  write: async (patch) => {
6856
7459
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6857
7460
  },
@@ -6863,6 +7466,70 @@ var BaseAddon = class {
6863
7466
  } })
6864
7467
  });
6865
7468
  }
7469
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7470
+ addonSecretTree() {
7471
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7472
+ return this._addonSecretTree;
7473
+ }
7474
+ deviceSecretTree() {
7475
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7476
+ return this._deviceSecretTree;
7477
+ }
7478
+ /**
7479
+ * Secrets of this addon's stored config that could not be resolved on the
7480
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7481
+ * an addon whose function needs one should report itself degraded rather
7482
+ * than start on an empty credential.
7483
+ */
7484
+ get unresolvedSecrets() {
7485
+ return this._unresolvedSecrets;
7486
+ }
7487
+ /**
7488
+ * Substitute every keychain marker in a stored blob with its value. With no
7489
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7490
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7491
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7492
+ * ever written back from here.
7493
+ */
7494
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7495
+ const secrets = this._ctx?.secrets;
7496
+ if (secrets === void 0) return blob;
7497
+ const refs = collectSecretMarkerRefs(blob);
7498
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7499
+ if (refs.length === 0) {
7500
+ if (trackForConfig) this._unresolvedSecrets = [];
7501
+ return blob;
7502
+ }
7503
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7504
+ if (trackForConfig) {
7505
+ this._unresolvedSecrets = unresolved;
7506
+ if (unresolved.length > 0) {
7507
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7508
+ ref: u.ref,
7509
+ reason: u.reason
7510
+ })) } });
7511
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7512
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7513
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7514
+ }
7515
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7516
+ }
7517
+ return value;
7518
+ }
7519
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7520
+ scheduleSecretReresolve(delayMs) {
7521
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7522
+ if (this[timerOf] !== null) return;
7523
+ const timer = setTimeout(() => {
7524
+ this[timerOf] = null;
7525
+ if (this._ctx === null) return;
7526
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7527
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7528
+ });
7529
+ }, delayMs);
7530
+ timer.unref?.();
7531
+ this[timerOf] = timer;
7532
+ }
6866
7533
  /**
6867
7534
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6868
7535
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -14605,6 +15272,196 @@ id: union([string(), number()]) }), {
14605
15272
  kind: "mutation",
14606
15273
  auth: "admin"
14607
15274
  });
15275
+ /**
15276
+ * `keychain` — the hub's encrypted store of secret values (D787).
15277
+ *
15278
+ * Settings blobs never hold a secret: they hold a marker
15279
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15280
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15281
+ * is the OWNER's door to its own values: every method is owner-checked
15282
+ * against the CALLER, never against anything the caller claims.
15283
+ *
15284
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15285
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15286
+ * connection, the agent from its child's connection carried in
15287
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15288
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15289
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15290
+ * identity against BUGS and misrouting, not against a malicious addon (every
15291
+ * runner is the same OS user): see the threat model in
15292
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15293
+ *
15294
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15295
+ * parses the input, so a session can never supply it, and the internal mount
15296
+ * floors every method to admin anyway (D240).
15297
+ *
15298
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15299
+ */
15300
+ /** Why a value cannot be served right now. Never folded into "missing". */
15301
+ var KeychainUnavailableReasonSchema = _enum([
15302
+ "key-missing",
15303
+ "wrong-key",
15304
+ "key-file-unreadable",
15305
+ "store-unavailable",
15306
+ "not-initialized",
15307
+ "decrypt-failed"
15308
+ ]);
15309
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15310
+ state: literal("locked"),
15311
+ reason: KeychainUnavailableReasonSchema
15312
+ })]);
15313
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15314
+ object({
15315
+ kind: literal("value"),
15316
+ value: string(),
15317
+ version: number().int()
15318
+ }),
15319
+ object({ kind: literal("missing") }),
15320
+ object({
15321
+ kind: literal("unavailable"),
15322
+ reason: KeychainUnavailableReasonSchema
15323
+ }),
15324
+ object({ kind: literal("forbidden") })
15325
+ ]);
15326
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15327
+ /** Metadata of one stored value — never the value. */
15328
+ var KeychainSecretMetaSchema = object({
15329
+ ref: string(),
15330
+ owner: string(),
15331
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15332
+ scope: string(),
15333
+ fieldPath: string(),
15334
+ version: number().int(),
15335
+ createdAt: number(),
15336
+ updatedAt: number(),
15337
+ /** `addon:<id>` | `user:<id>` | `system`. */
15338
+ updatedBy: string(),
15339
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15340
+ lastReadAt: number().nullable()
15341
+ });
15342
+ var RefListSchema = array(string().min(1)).max(512);
15343
+ method(object({
15344
+ ref: string().min(1),
15345
+ value: string().min(1)
15346
+ }), object({
15347
+ ref: string(),
15348
+ version: number().int()
15349
+ }), {
15350
+ kind: "mutation",
15351
+ auth: "admin"
15352
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15353
+ kind: "mutation",
15354
+ auth: "admin"
15355
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15356
+ var KeychainKeySourceSchema = object({
15357
+ kind: _enum([
15358
+ "config-file",
15359
+ "previous-config-file",
15360
+ "platform",
15361
+ "default-file"
15362
+ ]),
15363
+ /** File sources only — a path is not a secret. */
15364
+ path: string().optional(),
15365
+ /**
15366
+ * True when a whole-volume backup of the data directory carries this key
15367
+ * next to the database it protects (the default file). The page warns.
15368
+ */
15369
+ sharesBackupWithDatabase: boolean()
15370
+ });
15371
+ var KeychainStatusSchema = object({
15372
+ keychain: KeychainStateSchema,
15373
+ /** The source of the master key in use; `null` while locked. */
15374
+ keySource: KeychainKeySourceSchema.nullable(),
15375
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15376
+ configuredSource: KeychainKeySourceSchema,
15377
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15378
+ fingerprint: string().nullable(),
15379
+ activeKeyId: string().nullable(),
15380
+ /**
15381
+ * The keychain unlocked with a NON-primary source: the configured primary
15382
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15383
+ */
15384
+ rotationPending: boolean(),
15385
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15386
+ retiredWraps: number().int(),
15387
+ recoveryKeyDownloadedAt: number().nullable(),
15388
+ secretCount: number().int()
15389
+ });
15390
+ /**
15391
+ * Whether a stored value is still pointed at by its owner's settings.
15392
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15393
+ * never reported as an orphan (and never deleted as one).
15394
+ */
15395
+ var KeychainSecretUsageSchema = _enum([
15396
+ "in-use",
15397
+ "orphan",
15398
+ "unknown"
15399
+ ]);
15400
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15401
+ var KeychainAuditActionSchema = _enum([
15402
+ "put",
15403
+ "delete",
15404
+ "reveal",
15405
+ "rotate-master-key",
15406
+ "purge-retired-keys",
15407
+ "download-recovery-key",
15408
+ "delete-orphans",
15409
+ "reset",
15410
+ "initialize"
15411
+ ]);
15412
+ var KeychainAuditEntrySchema = object({
15413
+ id: string(),
15414
+ at: number(),
15415
+ action: KeychainAuditActionSchema,
15416
+ /** `addon:<id>` | `user:<id>` | `system`. */
15417
+ actor: string(),
15418
+ ref: string().nullable(),
15419
+ detail: string().nullable()
15420
+ });
15421
+ 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({
15422
+ value: string(),
15423
+ version: number().int()
15424
+ }), {
15425
+ kind: "mutation",
15426
+ auth: "admin",
15427
+ caller: "required"
15428
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15429
+ deleted: array(string()).readonly(),
15430
+ kept: array(object({
15431
+ ref: string(),
15432
+ usage: KeychainSecretUsageSchema
15433
+ })).readonly()
15434
+ }), {
15435
+ kind: "mutation",
15436
+ auth: "admin",
15437
+ caller: "required"
15438
+ }), method(object({}), object({
15439
+ fingerprint: string(),
15440
+ keySource: KeychainKeySourceSchema
15441
+ }), {
15442
+ kind: "mutation",
15443
+ auth: "admin",
15444
+ caller: "required"
15445
+ }), method(object({}), object({ purged: number().int() }), {
15446
+ kind: "mutation",
15447
+ auth: "admin",
15448
+ caller: "required"
15449
+ }), method(object({}), object({
15450
+ key: string(),
15451
+ fingerprint: string(),
15452
+ keySource: KeychainKeySourceSchema
15453
+ }), {
15454
+ kind: "mutation",
15455
+ auth: "admin",
15456
+ caller: "required"
15457
+ }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15458
+ archivedCollection: string().nullable(),
15459
+ archived: number().int()
15460
+ }), {
15461
+ kind: "mutation",
15462
+ auth: "admin",
15463
+ caller: "required"
15464
+ });
14608
15465
  method(_void(), object({
14609
15466
  id: string(),
14610
15467
  name: string(),
@@ -15642,7 +16499,11 @@ var DeviceRegisterPayloadSchema = object({
15642
16499
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15643
16500
  var DevicePersistConfigPayloadSchema = object({
15644
16501
  deviceId: number(),
15645
- data: record(string(), unknown())
16502
+ data: record(string(), unknown()),
16503
+ /** The paths the device's schema declares secret (D783), when the caller
16504
+ * knows them — those values are kept in the keychain, not the blob (D787).
16505
+ * Absent: the paths the device last reported at `registerDevice` apply. */
16506
+ secretConfigPaths: array(string()).optional()
15646
16507
  });
15647
16508
  /** What a migration actually did, per switch. `unreachable` is a first-class
15648
16509
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -22627,8 +23488,23 @@ var RetrainMacroClassSchema = _enum([
22627
23488
  ]);
22628
23489
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22629
23490
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22630
- /** Did a human draw this box, or did the assist propose it? */
22631
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
23491
+ /**
23492
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
23493
+ * the operator confirms it; once saved it keeps its source as provenance.
23494
+ *
23495
+ * - `operator` — drawn by hand.
23496
+ * - `assist` — proposed by a detector run on the copy (the camera's own
23497
+ * model, or a larger teacher model).
23498
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
23499
+ * back from the track store (never a re-run).
23500
+ * - `llm` — proposed by a vision-capable LLM profile.
23501
+ */
23502
+ var RetrainAnnotationSourceSchema = _enum([
23503
+ "operator",
23504
+ "assist",
23505
+ "pipeline",
23506
+ "llm"
23507
+ ]);
22632
23508
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22633
23509
  var RetrainBboxSchema = object({
22634
23510
  x: number(),
@@ -22646,7 +23522,8 @@ var RetrainBboxSchema = object({
22646
23522
  */
22647
23523
  var RetrainAnnotationSchema = object({
22648
23524
  id: string(),
22649
- trackId: string(),
23525
+ /** The frame's track. Absent on a recording still, which has none. */
23526
+ trackId: string().optional(),
22650
23527
  deviceId: number(),
22651
23528
  /** The COPY in retrain storage — never the source track's media key. */
22652
23529
  mediaKey: string(),
@@ -22695,13 +23572,47 @@ var RetrainFrameCandidateSchema = object({
22695
23572
  * fail, whatever became of the original. */
22696
23573
  copied: boolean()
22697
23574
  });
23575
+ /**
23576
+ * One box the live pipeline drew on a copied frame — what a correction starts
23577
+ * from. Derived when the frame is listed, from the track store: the subject
23578
+ * box recorded on the source media row when there is one, else the track
23579
+ * position nearest the frame's capture time. Never stored as an annotation
23580
+ * until the operator confirms it.
23581
+ */
23582
+ var RetrainPipelineBoxSchema = object({
23583
+ /** Normalised `[0,1]` against the full frame. */
23584
+ bbox: RetrainBboxSchema,
23585
+ macroClass: RetrainMacroClassSchema,
23586
+ label: string().optional(),
23587
+ subLabel: string().optional(),
23588
+ /** The detection score of the position used, when it was recorded. */
23589
+ score: number().optional(),
23590
+ /** The root model that produced the track, when it was recorded. */
23591
+ modelId: string().optional(),
23592
+ trackId: string(),
23593
+ /** `subject-box`: recorded on this very frame. `position`: the track's
23594
+ * position nearest the capture time, `deltaMs` away. */
23595
+ basis: _enum(["subject-box", "position"]),
23596
+ deltaMs: number()
23597
+ });
23598
+ /**
23599
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
23600
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
23601
+ * track at all.
23602
+ */
23603
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22698
23604
  /** A frame the dataset OWNS: bytes copied at selection time. */
22699
23605
  var RetrainFrameSchema = object({
22700
23606
  frameId: string(),
22701
23607
  deviceId: number(),
22702
- trackId: string(),
22703
- /** Provenance only. It may already point at nothing — that is expected. */
22704
- sourceMediaId: number().int(),
23608
+ origin: RetrainFrameOriginSchema,
23609
+ /** The track it was copied from. Absent on a recording still. */
23610
+ trackId: string().optional(),
23611
+ /** Provenance only. It may already point at nothing — that is expected.
23612
+ * Absent on a recording still. */
23613
+ sourceMediaId: number().int().optional(),
23614
+ /** A recording still: the playhead instant it was taken at. */
23615
+ epochMs: number().optional(),
22705
23616
  sourceKind: MediaFileKindEnum,
22706
23617
  sizeBytes: number().int(),
22707
23618
  width: number().int(),
@@ -22712,7 +23623,12 @@ var RetrainFrameSchema = object({
22712
23623
  /** The operator's "every subject in this frame is boxed". Detector
22713
23624
  * evaluation keeps only complete frames: an unboxed subject would count as
22714
23625
  * a false positive. */
22715
- complete: boolean()
23626
+ complete: boolean(),
23627
+ /** The boxes the pipeline drew on this frame. Present on list answers;
23628
+ * empty when nothing the track store holds can be placed on it. */
23629
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
23630
+ /** The named collections this frame belongs to. Present on list answers. */
23631
+ collectionIds: array(string()).readonly().optional()
22716
23632
  });
22717
23633
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22718
23634
  var RetrainCopyRefusalSchema = _enum([
@@ -22743,6 +23659,11 @@ var RetrainFrameListSchema = object({
22743
23659
  var RetrainExportFilterSchema = object({
22744
23660
  deviceIds: array(number()).optional(),
22745
23661
  frameIds: array(string()).max(2e4).optional(),
23662
+ /** Only frames in at least one of these named collections. */
23663
+ collectionIds: array(string()).max(200).optional(),
23664
+ /** Exactly the frames of this dataset version (and its completeOnly). An
23665
+ * unknown id selects nothing. */
23666
+ datasetVersionId: string().optional(),
22746
23667
  batchId: string().optional(),
22747
23668
  /** Only frames the operator marked complete (all subjects boxed). */
22748
23669
  completeOnly: boolean().optional()
@@ -22807,6 +23728,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22807
23728
  reason: string(),
22808
23729
  detail: string().optional()
22809
23730
  })]);
23731
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
23732
+ var RetrainCollectionSchema = object({
23733
+ id: string(),
23734
+ name: string(),
23735
+ createdAt: number(),
23736
+ frameCount: number().int()
23737
+ });
23738
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
23739
+ kind: literal("created"),
23740
+ collection: RetrainCollectionSchema
23741
+ }), object({
23742
+ kind: literal("refused"),
23743
+ reason: _enum(["empty-name", "duplicate-name"])
23744
+ })]);
23745
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
23746
+ kind: literal("renamed"),
23747
+ collection: RetrainCollectionSchema
23748
+ }), object({
23749
+ kind: literal("refused"),
23750
+ reason: _enum([
23751
+ "empty-name",
23752
+ "duplicate-name",
23753
+ "unknown-collection"
23754
+ ])
23755
+ })]);
23756
+ /**
23757
+ * The outcome of adding the frame at a recording instant. Every refusal is
23758
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
23759
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
23760
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
23761
+ */
23762
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
23763
+ kind: literal("added"),
23764
+ collectionId: string(),
23765
+ frame: RetrainFrameSchema,
23766
+ /** The moment was already in the dataset; nothing was decoded. */
23767
+ reused: boolean()
23768
+ }), object({
23769
+ kind: literal("refused"),
23770
+ reason: _enum([
23771
+ "unknown-collection",
23772
+ "still-unavailable",
23773
+ "still-busy",
23774
+ "unreadable-image",
23775
+ "write-failed"
23776
+ ]),
23777
+ detail: string().optional()
23778
+ })]);
23779
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
23780
+ var RetrainAssistProfileSchema = object({
23781
+ id: string(),
23782
+ name: string(),
23783
+ model: string(),
23784
+ kind: string(),
23785
+ /** `true` when the frame would leave the house (a cloud vendor, or an
23786
+ * endpoint that is not on the local network). The page confirms each such
23787
+ * run, and the provider refuses one without `allowCloud`. */
23788
+ leavesHouse: boolean()
23789
+ });
23790
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
23791
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
23792
+ /** What the AI assist said about a box that was already on the canvas. */
23793
+ var RetrainLlmReviewSchema = object({
23794
+ /** The `ref` the page sent the box under. */
23795
+ ref: string(),
23796
+ verdict: _enum([
23797
+ "confirmed",
23798
+ "wrong-class",
23799
+ "not-an-object",
23800
+ "uncertain"
23801
+ ]),
23802
+ suggestedClass: RetrainMacroClassSchema.optional(),
23803
+ reason: string()
23804
+ });
23805
+ /**
23806
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
23807
+ * model and its confidence) and reviews; items the model got wrong (a box off
23808
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
23809
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
23810
+ */
23811
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23812
+ kind: literal("proposed"),
23813
+ profileId: string(),
23814
+ model: string(),
23815
+ /** The frame was sent outside the house for this answer. */
23816
+ leftHouse: boolean(),
23817
+ proposals: array(RetrainLlmProposalSchema).readonly(),
23818
+ reviews: array(RetrainLlmReviewSchema).readonly(),
23819
+ rejected: number().int()
23820
+ }), object({
23821
+ kind: literal("refused"),
23822
+ reason: _enum([
23823
+ "unknown-frame",
23824
+ "unreadable-frame",
23825
+ "unknown-profile",
23826
+ "profile-disabled",
23827
+ "no-vision",
23828
+ "cloud-not-confirmed",
23829
+ "llm-error",
23830
+ "malformed-answer"
23831
+ ]),
23832
+ detail: string().optional()
23833
+ })]);
23834
+ /** What a dataset version is cut from. Every field narrows. */
23835
+ var RetrainDatasetSelectionSchema = object({
23836
+ deviceIds: array(number()).readonly().optional(),
23837
+ collectionIds: array(string()).max(200).readonly().optional(),
23838
+ frameIds: array(string()).max(2e4).readonly().optional()
23839
+ });
23840
+ /** The counts a dataset is judged by. */
23841
+ var RetrainDatasetStatsSchema = object({
23842
+ frames: number().int(),
23843
+ completeFrames: number().int(),
23844
+ /** `completeFrames / frames`, 0..1. */
23845
+ completeness: number(),
23846
+ /** Boxes to learn (model errors excluded). */
23847
+ subjects: number().int(),
23848
+ modelErrors: number().int(),
23849
+ /** Complete frames with no subject. */
23850
+ hardNegatives: number().int(),
23851
+ /** Subjects per class × camera × day/night. */
23852
+ cells: array(object({
23853
+ macroClass: string(),
23854
+ deviceId: number(),
23855
+ lighting: _enum([
23856
+ "day",
23857
+ "night",
23858
+ "unknown"
23859
+ ]),
23860
+ subjects: number().int(),
23861
+ frames: number().int()
23862
+ })).readonly(),
23863
+ cameras: array(object({
23864
+ deviceId: number(),
23865
+ frames: number().int(),
23866
+ completeFrames: number().int()
23867
+ })).readonly()
23868
+ });
23869
+ /** An immutable dataset version, without its frame list. */
23870
+ var RetrainDatasetVersionSchema = object({
23871
+ id: string(),
23872
+ name: string(),
23873
+ createdAt: number(),
23874
+ selection: RetrainDatasetSelectionSchema,
23875
+ layout: RetrainExportLayoutSchema,
23876
+ completeOnly: boolean(),
23877
+ frameCount: number().int(),
23878
+ /** sha256 of what the frames taught when the version was frozen. */
23879
+ annotationHash: string(),
23880
+ /** The export manifest schema the version was cut under. */
23881
+ manifestSchema: string(),
23882
+ stats: RetrainDatasetStatsSchema
23883
+ });
23884
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
23885
+ kind: literal("created"),
23886
+ version: RetrainDatasetVersionSchema
23887
+ }), object({
23888
+ kind: literal("refused"),
23889
+ reason: _enum([
23890
+ "empty-name",
23891
+ "duplicate-name",
23892
+ "no-frames"
23893
+ ])
23894
+ })]);
22810
23895
  /** The outcome of a lifecycle move owned by the retrain page. */
22811
23896
  var RetrainTransitionResultSchema = object({
22812
23897
  trackId: string(),
@@ -23524,7 +24609,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23524
24609
  auth: "admin"
23525
24610
  }), method(object({
23526
24611
  deviceId: number(),
23527
- trackId: string(),
24612
+ trackId: string().optional(),
23528
24613
  frameId: string()
23529
24614
  }), object({
23530
24615
  removed: boolean(),
@@ -23541,7 +24626,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23541
24626
  auth: "admin"
23542
24627
  }), method(object({
23543
24628
  deviceId: number(),
23544
- trackId: string(),
24629
+ /** The frame's track, when it has one — checked against the frame. */
24630
+ trackId: string().optional(),
23545
24631
  frameId: string(),
23546
24632
  subject: RetrainAssistSubjectSchema,
23547
24633
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -23549,12 +24635,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23549
24635
  }), RetrainAssistResultSchema, {
23550
24636
  kind: "mutation",
23551
24637
  auth: "admin"
23552
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
24638
+ }), method(object({
24639
+ trackId: string().optional(),
24640
+ frameIds: array(string()).max(2e3).optional()
24641
+ }), array(RetrainAnnotationSchema).readonly(), {
23553
24642
  kind: "query",
23554
24643
  auth: "admin"
23555
24644
  }), method(object({
23556
24645
  deviceId: number(),
23557
- trackId: string(),
24646
+ /** The frame's track, when it has one — checked against the frame. */
24647
+ trackId: string().optional(),
23558
24648
  frameId: string(),
23559
24649
  annotations: array(RetrainAnnotationDraftSchema)
23560
24650
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -23577,7 +24667,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23577
24667
  auth: "admin"
23578
24668
  }), method(object({
23579
24669
  deviceId: number(),
23580
- trackId: string(),
24670
+ trackId: string().optional(),
23581
24671
  frameId: string(),
23582
24672
  complete: boolean()
23583
24673
  }), RetrainFrameSchema, {
@@ -23591,6 +24681,104 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23591
24681
  kind: "mutation",
23592
24682
  auth: "admin",
23593
24683
  timeoutMs: 60 * 6e4
24684
+ }), method(object({
24685
+ selection: RetrainDatasetSelectionSchema,
24686
+ completeOnly: boolean().optional()
24687
+ }), RetrainDatasetStatsSchema, {
24688
+ kind: "query",
24689
+ auth: "admin"
24690
+ }), method(object({
24691
+ name: string().max(120),
24692
+ selection: RetrainDatasetSelectionSchema,
24693
+ layout: RetrainExportLayoutSchema,
24694
+ completeOnly: boolean()
24695
+ }), CreateRetrainDatasetVersionResultSchema, {
24696
+ kind: "mutation",
24697
+ auth: "admin",
24698
+ timeoutMs: 12e4
24699
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
24700
+ kind: "query",
24701
+ auth: "admin"
24702
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
24703
+ kind: "mutation",
24704
+ auth: "admin"
24705
+ }), method(object({ id: string() }), object({
24706
+ found: boolean(),
24707
+ annotationHash: string(),
24708
+ matches: boolean(),
24709
+ missingFrames: number().int()
24710
+ }), {
24711
+ kind: "query",
24712
+ auth: "admin",
24713
+ timeoutMs: 12e4
24714
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24715
+ kind: "query",
24716
+ auth: "admin"
24717
+ }), method(object({
24718
+ deviceId: number(),
24719
+ trackId: string().optional(),
24720
+ frameId: string(),
24721
+ profileId: string(),
24722
+ classes: array(RetrainMacroClassSchema).min(1),
24723
+ boxes: array(object({
24724
+ ref: string(),
24725
+ bbox: RetrainBboxSchema,
24726
+ macroClass: RetrainMacroClassSchema,
24727
+ label: string().optional()
24728
+ })).max(50),
24729
+ allowCloud: boolean()
24730
+ }), RetrainLlmAssistResultSchema, {
24731
+ kind: "mutation",
24732
+ auth: "admin",
24733
+ timeoutMs: 18e4
24734
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
24735
+ kind: "mutation",
24736
+ auth: "admin"
24737
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
24738
+ kind: "query",
24739
+ auth: "admin"
24740
+ }), method(object({
24741
+ id: string(),
24742
+ name: string().max(120)
24743
+ }), RetrainCollectionRenameResultSchema, {
24744
+ kind: "mutation",
24745
+ auth: "admin"
24746
+ }), method(object({ id: string() }), object({
24747
+ deleted: boolean(),
24748
+ removedFrames: number().int()
24749
+ }), {
24750
+ kind: "mutation",
24751
+ auth: "admin"
24752
+ }), method(object({
24753
+ collectionId: string(),
24754
+ deviceId: number(),
24755
+ epochMs: number()
24756
+ }), AddRetrainFrameFromRecordingResultSchema, {
24757
+ kind: "mutation",
24758
+ auth: "admin",
24759
+ timeoutMs: 6e4
24760
+ }), method(object({
24761
+ collectionId: string(),
24762
+ frameIds: array(string()).min(1).max(500)
24763
+ }), object({
24764
+ added: number().int(),
24765
+ alreadyMember: number().int(),
24766
+ unknownFrameIds: array(string()).readonly()
24767
+ }), {
24768
+ kind: "mutation",
24769
+ auth: "admin"
24770
+ }), method(object({
24771
+ collectionId: string(),
24772
+ frameId: string()
24773
+ }), object({
24774
+ removed: boolean(),
24775
+ deletedFrame: boolean()
24776
+ }), {
24777
+ kind: "mutation",
24778
+ auth: "admin"
24779
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
24780
+ kind: "query",
24781
+ auth: "admin"
23594
24782
  }), method(object({
23595
24783
  /** Which of the three event tables owns the row. */
23596
24784
  ownerType: EventOwnerTypeSchema,
@@ -24214,13 +25402,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
24214
25402
  object({
24215
25403
  kind: literal("no-family-build"),
24216
25404
  format: ModelFormatSchema$1
25405
+ }),
25406
+ object({
25407
+ kind: literal("kept-custom-pin"),
25408
+ modelId: string(),
25409
+ deviceKey: string()
24217
25410
  })
24218
25411
  ]);
25412
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
25413
+ var KeptReasonSchema = _enum(["custom-pin"]);
25414
+ /**
25415
+ * Where a choice's latency came from (D791): this node's own benchmark
25416
+ * result, or the hardware-class table. Measured on the node beats the table.
25417
+ */
25418
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
25419
+ kind: literal("node-benchmark"),
25420
+ resultId: string(),
25421
+ measuredAtMs: number()
25422
+ })]);
24219
25423
  var DeviceModelChoiceSchema = object({
24220
25424
  modelId: string(),
24221
25425
  p50Ms: number(),
24222
25426
  fps: number(),
24223
25427
  measured: boolean(),
25428
+ /** Absent on a plan from before D791 — read as the table. */
25429
+ source: LatencySourceSchema.optional(),
24224
25430
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
24225
25431
  capacitySessions: number(),
24226
25432
  personRecall: number()
@@ -24231,6 +25437,8 @@ var DeviceRecommendationSchema = object({
24231
25437
  enabled: boolean(),
24232
25438
  available: boolean(),
24233
25439
  chosen: DeviceModelChoiceSchema.nullable(),
25440
+ /** Present when the device is kept as is: Apply writes nothing on it. */
25441
+ kept: KeptReasonSchema.optional(),
24234
25442
  reasons: array(RecommendationReasonSchema).readonly()
24235
25443
  });
24236
25444
  var NodeRecommendationSchema = object({
@@ -24284,6 +25492,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
24284
25492
  kind: literal("coral-enabled"),
24285
25493
  nodeId: string(),
24286
25494
  deviceKey: string()
25495
+ }),
25496
+ object({
25497
+ kind: literal("custom-pin-kept"),
25498
+ nodeId: string(),
25499
+ deviceKey: string().nullable(),
25500
+ deviceId: number().nullable(),
25501
+ modelId: string()
25502
+ }),
25503
+ object({
25504
+ kind: literal("custom-registry-unreadable"),
25505
+ error: string()
24287
25506
  })
24288
25507
  ]);
24289
25508
  var AutoTuneOptionsSchema = object({
@@ -24462,13 +25681,14 @@ var SuggestSharesResultSchema = object({
24462
25681
  nodes: array(SuggestedNodeShareSchema).readonly()
24463
25682
  });
24464
25683
  /**
24465
- * Where the node and device shares come from (D750, D755).
24466
- * - `hardware` (default) — computed by the system from each node's static
24467
- * capacity (its accelerators at their Auto tune models, from the measured
24468
- * latency table), recomputed whenever a node or device joins, leaves, is
24469
- * switched on or off, or changes model. No load input.
24470
- * - `benchmark` — the same, from each node's measured capacity (node
24471
- * benchmark results); a node without results falls back to `hardware`.
25684
+ * Where the node and device shares come from (D750, D755, D791).
25685
+ * - `benchmark` (default since D791) — each node's capacity as its own node
25686
+ * benchmark measured it; a node without fresh results is sized from
25687
+ * `hardware` and says so. Measured on the node beats the table.
25688
+ * - `hardware` — computed from each node's static capacity only (its
25689
+ * accelerators at their Auto tune models, from the latency table).
25690
+ * Both are recomputed whenever a node or device joins, leaves, is switched
25691
+ * on or off, changes model, or a benchmark result is written. No load input.
24472
25692
  * - `manual` — the operator's stored sliders.
24473
25693
  * Either way a node or device that cannot take sessions gives its share to
24474
25694
  * the others in proportion; the stored values are never rewritten for that.
@@ -24517,6 +25737,362 @@ var EffectiveSharesSchema = object({
24517
25737
  nodeWeights: record(string(), number()),
24518
25738
  deviceWeights: record(string(), record(string(), number()))
24519
25739
  });
25740
+ /**
25741
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
25742
+ * preflight the confirmation shows, the run the orchestrator owns, what the
25743
+ * measuring runner reports, and the result rows Auto tune and the automatic
25744
+ * shares read.
25745
+ *
25746
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
25747
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
25748
+ * detection candidate, camera pins naming it are ignored so its sessions move
25749
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
25750
+ * restart too (a persisted manifest, reconciled against the registry).
25751
+ *
25752
+ * Two measurements, both on the node, driven by its own runner (frames never
25753
+ * cross a process at frame rate, D9):
25754
+ * - `device` — one accelerator × one candidate detector, root only, open
25755
+ * loop: how many streams at the camera rate it carries inside the frame
25756
+ * interval;
25757
+ * - `pipeline` — the chosen detector plus the operator's detail steps
25758
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
25759
+ * clip: how many parallel sessions the node carries before latency, drops,
25760
+ * CPU, RAM or the event loop give out.
25761
+ */
25762
+ /** Defaults and bounds, one place. */
25763
+ var NODE_BENCHMARK_DEFAULTS = {
25764
+ fpsPerStream: 10,
25765
+ budgetMinutes: 45,
25766
+ minBudgetMinutes: 10,
25767
+ maxBudgetMinutes: 120,
25768
+ /** A result older than this no longer beats the table. */
25769
+ staleAfterDays: 30,
25770
+ /** Warm-in per ramp step (not accounted). */
25771
+ settleSec: 5,
25772
+ /** Accounted window per ramp step. */
25773
+ measureSec: 20,
25774
+ /** Longest the drain may take before the run is refused. */
25775
+ drainTimeoutSec: 120,
25776
+ /** Candidate models per device in one run. */
25777
+ maxModelsPerDevice: 6
25778
+ };
25779
+ /** The two measurements a run can make. */
25780
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
25781
+ var NodeBenchmarkDevicePlanSchema = object({
25782
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
25783
+ deviceKey: string().min(1),
25784
+ /**
25785
+ * Root detector candidates for the `device` measurement, in the order
25786
+ * measured. The FIRST is the one the `pipeline` measurement runs.
25787
+ */
25788
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
25789
+ });
25790
+ /** What the operator confirmed. */
25791
+ var NodeBenchmarkPlanSchema = object({
25792
+ nodeId: string().min(1),
25793
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
25794
+ /** Which measurements run. At least one. */
25795
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
25796
+ /**
25797
+ * Detail steps (catalog step ids under the root: faces, plates,
25798
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
25799
+ * detector always runs.
25800
+ */
25801
+ steps: array(string().min(1)).default([]),
25802
+ /** Offered rate of one stream / session. */
25803
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
25804
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
25805
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
25806
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
25807
+ keepDownloadedModels: boolean().default(false),
25808
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
25809
+ acceptInsufficientHeadroom: boolean().default(false)
25810
+ });
25811
+ var NodeBenchmarkRefusalSchema = object({
25812
+ kind: _enum([
25813
+ "benchmark-active",
25814
+ "node-offline",
25815
+ "unknown-device",
25816
+ "no-phase",
25817
+ "insufficient-headroom"
25818
+ ]),
25819
+ detail: string(),
25820
+ overridable: boolean()
25821
+ });
25822
+ /** A camera whose detection leaves the node for the run. */
25823
+ var NodeBenchmarkMovingCameraSchema = object({
25824
+ deviceId: number(),
25825
+ /** Placed on the node now (a standing attach or a running session). */
25826
+ placedOnNode: boolean(),
25827
+ /** A node pin naming this node, ignored for the run. */
25828
+ pinnedToNode: boolean()
25829
+ });
25830
+ /** A camera that cannot leave: no other node can obtain its frames. */
25831
+ var NodeBenchmarkStayingCameraSchema = object({
25832
+ deviceId: number(),
25833
+ reason: literal("only-frame-source")
25834
+ });
25835
+ var NodeBenchmarkPreflightSchema = object({
25836
+ nodeId: string(),
25837
+ online: boolean(),
25838
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
25839
+ /** Keep running on the node during the run; the result is flagged contaminated. */
25840
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
25841
+ estimatedDurationMs: number(),
25842
+ /** The run ends and the cluster is restored at the latest after this long. */
25843
+ budgetMs: number(),
25844
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
25845
+ steps: array(string()).readonly(),
25846
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
25847
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
25848
+ headroom: object({
25849
+ sessionsNow: number(),
25850
+ otherNodesCapacitySessions: number().nullable()
25851
+ }),
25852
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
25853
+ canStart: boolean()
25854
+ });
25855
+ /** Where the measuring runner is. */
25856
+ var NodeBenchProgressSchema = object({
25857
+ phase: _enum([
25858
+ "preparing",
25859
+ "device",
25860
+ "pipeline",
25861
+ "cleanup"
25862
+ ]),
25863
+ deviceKey: string().nullable(),
25864
+ modelId: string().nullable(),
25865
+ /** Streams (device) or sessions (pipeline) of the step running now. */
25866
+ load: number().nullable(),
25867
+ cellsDone: number(),
25868
+ cellsTotal: number(),
25869
+ message: string()
25870
+ });
25871
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
25872
+ var NodeBenchLimitSchema = _enum([
25873
+ "p95",
25874
+ "drops",
25875
+ "errors",
25876
+ "stall",
25877
+ "cpu",
25878
+ "ram",
25879
+ "none"
25880
+ ]);
25881
+ var NodeBenchRampStepSchema = object({
25882
+ load: number(),
25883
+ pass: boolean(),
25884
+ p95Ms: number(),
25885
+ dropRatio: number(),
25886
+ /** Completed frames per second over the accounted window. */
25887
+ fps: number(),
25888
+ cpuPct: number().nullable(),
25889
+ ramFreePct: number().nullable(),
25890
+ failReasons: array(string()).readonly()
25891
+ });
25892
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
25893
+ phase: literal("device"),
25894
+ deviceKey: string(),
25895
+ modelId: string(),
25896
+ /** Single-stream latency (the K = 1 step). */
25897
+ p50Ms: number(),
25898
+ p95Ms: number(),
25899
+ p99Ms: number(),
25900
+ /** Frames per second sustained at the last passing step. */
25901
+ fps: number(),
25902
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
25903
+ kMax: number(),
25904
+ limitedBy: NodeBenchLimitSchema,
25905
+ /** First call (model load + warm-up). */
25906
+ warmupMs: number(),
25907
+ ramp: array(NodeBenchRampStepSchema).readonly()
25908
+ }), object({
25909
+ phase: literal("pipeline"),
25910
+ deviceKey: string(),
25911
+ modelId: string(),
25912
+ steps: array(string()).readonly(),
25913
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
25914
+ maxSessions: number(),
25915
+ limitedBy: NodeBenchLimitSchema,
25916
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
25917
+ stepsFired: array(string()).readonly(),
25918
+ warmupMs: number(),
25919
+ ramp: array(NodeBenchRampStepSchema).readonly()
25920
+ })]);
25921
+ /**
25922
+ * What a result was measured ON. A result whose fingerprint no longer matches
25923
+ * the node no longer beats the table.
25924
+ */
25925
+ var NodeBenchFingerprintSchema = object({
25926
+ pipelineVersion: string().nullable(),
25927
+ cpuModel: string().nullable(),
25928
+ ramGb: number().nullable(),
25929
+ os: string().nullable(),
25930
+ /** Per device: the pool the cells ran on (runtime + tuning). */
25931
+ pools: record(string(), object({
25932
+ runtime: string(),
25933
+ numWorkers: number(),
25934
+ concurrency: number(),
25935
+ batchMode: string()
25936
+ })).default({})
25937
+ });
25938
+ /** The frames the run used. */
25939
+ var NodeBenchClipSchema = object({
25940
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
25941
+ id: string(),
25942
+ revision: string().nullable(),
25943
+ frames: number(),
25944
+ width: number(),
25945
+ height: number()
25946
+ });
25947
+ var NodeBenchRunnerInputSchema = object({
25948
+ runId: string().min(1),
25949
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
25950
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
25951
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
25952
+ steps: array(string()).default([]),
25953
+ fpsPerStream: number().int().min(1).max(30),
25954
+ /** The runner stops on its own past this instant, whatever the hub does. */
25955
+ deadlineAtMs: number(),
25956
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
25957
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
25958
+ keepDownloadedModels: boolean().default(false)
25959
+ });
25960
+ var NodeBenchRunnerStateSchema = _enum([
25961
+ "running",
25962
+ "done",
25963
+ "failed",
25964
+ "aborted"
25965
+ ]);
25966
+ var NodeBenchRunnerStatusSchema = object({
25967
+ runId: string(),
25968
+ nodeId: string(),
25969
+ state: NodeBenchRunnerStateSchema,
25970
+ progress: NodeBenchProgressSchema.nullable(),
25971
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
25972
+ cells: array(NodeBenchCellSchema).readonly(),
25973
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
25974
+ clip: NodeBenchClipSchema.nullable(),
25975
+ /** Cameras seen running on the node during the run (they share its pools). */
25976
+ activeCameraIds: array(number()).readonly(),
25977
+ /** Models the run downloaded and then deleted (not installed before). */
25978
+ deletedModels: array(string()).readonly(),
25979
+ error: string().nullable(),
25980
+ startedAtMs: number(),
25981
+ finishedAtMs: number().nullable()
25982
+ });
25983
+ var NodeBenchmarkStateSchema = _enum([
25984
+ "draining",
25985
+ "measuring",
25986
+ "restoring",
25987
+ "done",
25988
+ "failed",
25989
+ "aborted"
25990
+ ]);
25991
+ /** Why a run ended. */
25992
+ var NodeBenchmarkEndReasonSchema = _enum([
25993
+ "completed",
25994
+ "operator-abort",
25995
+ "deadline",
25996
+ "node-lost",
25997
+ "runner-lost",
25998
+ "hub-restart",
25999
+ "drain-timeout",
26000
+ "failed"
26001
+ ]);
26002
+ var NodeBenchmarkRunSchema = object({
26003
+ runId: string(),
26004
+ nodeId: string(),
26005
+ state: NodeBenchmarkStateSchema,
26006
+ plan: NodeBenchmarkPlanSchema,
26007
+ startedAtMs: number(),
26008
+ deadlineAtMs: number(),
26009
+ finishedAtMs: number().nullable(),
26010
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26011
+ error: string().nullable(),
26012
+ /** Cameras moved off the node for the run. */
26013
+ moved: array(number()).readonly(),
26014
+ /** Cameras that stayed (their only frame source is the node). */
26015
+ staying: array(number()).readonly(),
26016
+ /** Something else ran on the node's pools during the run. */
26017
+ contaminated: boolean(),
26018
+ progress: NodeBenchProgressSchema.nullable(),
26019
+ resultIds: array(string()).readonly()
26020
+ });
26021
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26022
+ var NodeBenchmarkStatusSchema = object({
26023
+ /** The node the cluster is in benchmark mode for; null = none. */
26024
+ modeNodeId: string().nullable(),
26025
+ run: NodeBenchmarkRunSchema.nullable()
26026
+ });
26027
+ /**
26028
+ * One stored measurement — the only authority Auto tune and the automatic
26029
+ * shares read measured capacity from. Written by the orchestrator when a run
26030
+ * ends, never by anyone else.
26031
+ */
26032
+ var NodeBenchmarkResultSchema = object({
26033
+ id: string(),
26034
+ runId: string(),
26035
+ nodeId: string(),
26036
+ cell: NodeBenchCellSchema,
26037
+ fpsPerStream: number(),
26038
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26039
+ clip: NodeBenchClipSchema.nullable(),
26040
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26041
+ contaminated: boolean(),
26042
+ stayingCameras: array(number()).readonly(),
26043
+ /** The run ended early; the cell itself completed. */
26044
+ partialRun: boolean(),
26045
+ measuredAtMs: number()
26046
+ });
26047
+ var ListNodeBenchmarkResultsInputSchema = object({
26048
+ nodeId: string().optional(),
26049
+ deviceKey: string().optional()
26050
+ });
26051
+ /** A result with its standing today: does it still beat the table? */
26052
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26053
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26054
+ standing: _enum([
26055
+ "fresh",
26056
+ "stale",
26057
+ "superseded"
26058
+ ]),
26059
+ staleWhy: _enum([
26060
+ "age",
26061
+ "runtime",
26062
+ "pool-tuning"
26063
+ ]).nullable()
26064
+ });
26065
+ object({
26066
+ runId: string(),
26067
+ nodeId: string(),
26068
+ startedAtMs: number(),
26069
+ deadlineAtMs: number(),
26070
+ plan: NodeBenchmarkPlanSchema,
26071
+ moved: array(number()).readonly(),
26072
+ staying: array(number()).readonly()
26073
+ });
26074
+ /** Candidate detectors per device, for the plan editor. */
26075
+ var NodeBenchmarkCandidatesSchema = object({
26076
+ nodeId: string(),
26077
+ reachable: boolean(),
26078
+ devices: array(object({
26079
+ deviceKey: string(),
26080
+ enabled: boolean(),
26081
+ available: boolean(),
26082
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26083
+ suggested: array(string()).readonly(),
26084
+ /** Every root detector the device has a build for. */
26085
+ all: array(string()).readonly(),
26086
+ /** The model the device runs now, when pinned. */
26087
+ currentModelId: string().nullable()
26088
+ })).readonly(),
26089
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26090
+ steps: array(object({
26091
+ id: string(),
26092
+ name: string(),
26093
+ slot: string()
26094
+ })).readonly()
26095
+ });
24520
26096
  object({
24521
26097
  activeCameras: number(),
24522
26098
  throttledCameras: number(),
@@ -25605,7 +27181,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25605
27181
  }), ParkedTrackFrameSchema.nullable()), method(object({
25606
27182
  deviceId: number(),
25607
27183
  trackId: string()
25608
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
27184
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
27185
+ accepted: literal(true),
27186
+ runId: string()
27187
+ }), {
27188
+ kind: "mutation",
27189
+ auth: "admin"
27190
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27191
+ kind: "mutation",
27192
+ auth: "admin"
27193
+ });
25609
27194
  var CameraPipelineConfigSchema = object({
25610
27195
  engine: PipelineEngineChoiceSchema.optional(),
25611
27196
  steps: array(PipelineStepInputSchema).readonly(),
@@ -26244,6 +27829,21 @@ method(object({
26244
27829
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
26245
27830
  kind: "mutation",
26246
27831
  auth: "admin"
27832
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
27833
+ kind: literal("started"),
27834
+ runId: string()
27835
+ }), object({
27836
+ kind: literal("refused"),
27837
+ preflight: NodeBenchmarkPreflightSchema
27838
+ })]), {
27839
+ kind: "mutation",
27840
+ auth: "admin"
27841
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27842
+ kind: "mutation",
27843
+ auth: "admin"
27844
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
27845
+ kind: "mutation",
27846
+ auth: "admin"
26247
27847
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
26248
27848
  deviceId: number(),
26249
27849
  addonId: string(),
@@ -31325,6 +32925,9 @@ var CreateIntegrationInputSchema = object({
31325
32925
  enabled: boolean().optional(),
31326
32926
  info: record(string(), unknown()).optional(),
31327
32927
  settings: record(string(), unknown()).optional(),
32928
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
32929
+ * the keychain, not the table (D787). */
32930
+ secretKeys: array(string()).optional(),
31328
32931
  skipRestart: boolean().optional()
31329
32932
  });
31330
32933
  var UpdateIntegrationInputSchema = object({
@@ -31348,7 +32951,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
31348
32951
  auth: "admin"
31349
32952
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
31350
32953
  id: string(),
31351
- settings: record(string(), unknown())
32954
+ settings: record(string(), unknown()),
32955
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
32956
+ secretKeys: array(string()).optional()
31352
32957
  }), object({ success: boolean() }), {
31353
32958
  kind: "mutation",
31354
32959
  auth: "admin"
@@ -40151,6 +41756,90 @@ Object.freeze({
40151
41756
  addonId: null,
40152
41757
  access: "create"
40153
41758
  },
41759
+ "keychain.delete": {
41760
+ capName: "keychain",
41761
+ capScope: "system",
41762
+ addonId: null,
41763
+ access: "delete"
41764
+ },
41765
+ "keychain.getState": {
41766
+ capName: "keychain",
41767
+ capScope: "system",
41768
+ addonId: null,
41769
+ access: "view"
41770
+ },
41771
+ "keychain.listMeta": {
41772
+ capName: "keychain",
41773
+ capScope: "system",
41774
+ addonId: null,
41775
+ access: "view"
41776
+ },
41777
+ "keychain.put": {
41778
+ capName: "keychain",
41779
+ capScope: "system",
41780
+ addonId: null,
41781
+ access: "create"
41782
+ },
41783
+ "keychain.resolve": {
41784
+ capName: "keychain",
41785
+ capScope: "system",
41786
+ addonId: null,
41787
+ access: "view"
41788
+ },
41789
+ "keychainAdmin.deleteOrphans": {
41790
+ capName: "keychain-admin",
41791
+ capScope: "system",
41792
+ addonId: null,
41793
+ access: "delete"
41794
+ },
41795
+ "keychainAdmin.downloadRecoveryKey": {
41796
+ capName: "keychain-admin",
41797
+ capScope: "system",
41798
+ addonId: null,
41799
+ access: "create"
41800
+ },
41801
+ "keychainAdmin.listAudit": {
41802
+ capName: "keychain-admin",
41803
+ capScope: "system",
41804
+ addonId: null,
41805
+ access: "view"
41806
+ },
41807
+ "keychainAdmin.listSecrets": {
41808
+ capName: "keychain-admin",
41809
+ capScope: "system",
41810
+ addonId: null,
41811
+ access: "view"
41812
+ },
41813
+ "keychainAdmin.purgeRetiredKeys": {
41814
+ capName: "keychain-admin",
41815
+ capScope: "system",
41816
+ addonId: null,
41817
+ access: "delete"
41818
+ },
41819
+ "keychainAdmin.resetKeychain": {
41820
+ capName: "keychain-admin",
41821
+ capScope: "system",
41822
+ addonId: null,
41823
+ access: "delete"
41824
+ },
41825
+ "keychainAdmin.reveal": {
41826
+ capName: "keychain-admin",
41827
+ capScope: "system",
41828
+ addonId: null,
41829
+ access: "create"
41830
+ },
41831
+ "keychainAdmin.rotateMasterKey": {
41832
+ capName: "keychain-admin",
41833
+ capScope: "system",
41834
+ addonId: null,
41835
+ access: "create"
41836
+ },
41837
+ "keychainAdmin.status": {
41838
+ capName: "keychain-admin",
41839
+ capScope: "system",
41840
+ addonId: null,
41841
+ access: "view"
41842
+ },
40154
41843
  "lawnMowerControl.dock": {
40155
41844
  capName: "lawn-mower-control",
40156
41845
  capScope: "device",
@@ -41525,6 +43214,18 @@ Object.freeze({
41525
43214
  addonId: null,
41526
43215
  access: "create"
41527
43216
  },
43217
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
43218
+ capName: "pipeline-analytics",
43219
+ capScope: "device",
43220
+ addonId: null,
43221
+ access: "create"
43222
+ },
43223
+ "pipelineAnalytics.addRetrainFramesToCollection": {
43224
+ capName: "pipeline-analytics",
43225
+ capScope: "device",
43226
+ addonId: null,
43227
+ access: "create"
43228
+ },
41528
43229
  "pipelineAnalytics.applyDeviceSettingsPatch": {
41529
43230
  capName: "pipeline-analytics",
41530
43231
  capScope: "device",
@@ -41573,12 +43274,36 @@ Object.freeze({
41573
43274
  addonId: null,
41574
43275
  access: "view"
41575
43276
  },
43277
+ "pipelineAnalytics.createRetrainCollection": {
43278
+ capName: "pipeline-analytics",
43279
+ capScope: "device",
43280
+ addonId: null,
43281
+ access: "create"
43282
+ },
43283
+ "pipelineAnalytics.createRetrainDatasetVersion": {
43284
+ capName: "pipeline-analytics",
43285
+ capScope: "device",
43286
+ addonId: null,
43287
+ access: "create"
43288
+ },
41576
43289
  "pipelineAnalytics.deleteDeviceEvents": {
41577
43290
  capName: "pipeline-analytics",
41578
43291
  capScope: "device",
41579
43292
  addonId: null,
41580
43293
  access: "delete"
41581
43294
  },
43295
+ "pipelineAnalytics.deleteRetrainCollection": {
43296
+ capName: "pipeline-analytics",
43297
+ capScope: "device",
43298
+ addonId: null,
43299
+ access: "delete"
43300
+ },
43301
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
43302
+ capName: "pipeline-analytics",
43303
+ capScope: "device",
43304
+ addonId: null,
43305
+ access: "delete"
43306
+ },
41582
43307
  "pipelineAnalytics.deleteTracks": {
41583
43308
  capName: "pipeline-analytics",
41584
43309
  capScope: "device",
@@ -41783,6 +43508,30 @@ Object.freeze({
41783
43508
  addonId: null,
41784
43509
  access: "view"
41785
43510
  },
43511
+ "pipelineAnalytics.listRetrainAssistProfiles": {
43512
+ capName: "pipeline-analytics",
43513
+ capScope: "device",
43514
+ addonId: null,
43515
+ access: "view"
43516
+ },
43517
+ "pipelineAnalytics.listRetrainCollectionFrames": {
43518
+ capName: "pipeline-analytics",
43519
+ capScope: "device",
43520
+ addonId: null,
43521
+ access: "view"
43522
+ },
43523
+ "pipelineAnalytics.listRetrainCollections": {
43524
+ capName: "pipeline-analytics",
43525
+ capScope: "device",
43526
+ addonId: null,
43527
+ access: "view"
43528
+ },
43529
+ "pipelineAnalytics.listRetrainDatasetVersions": {
43530
+ capName: "pipeline-analytics",
43531
+ capScope: "device",
43532
+ addonId: null,
43533
+ access: "view"
43534
+ },
41786
43535
  "pipelineAnalytics.listRetrainFrames": {
41787
43536
  capName: "pipeline-analytics",
41788
43537
  capScope: "device",
@@ -41825,12 +43574,24 @@ Object.freeze({
41825
43574
  addonId: null,
41826
43575
  access: "create"
41827
43576
  },
43577
+ "pipelineAnalytics.previewRetrainDataset": {
43578
+ capName: "pipeline-analytics",
43579
+ capScope: "device",
43580
+ addonId: null,
43581
+ access: "view"
43582
+ },
41828
43583
  "pipelineAnalytics.proposeRetrainAnnotations": {
41829
43584
  capName: "pipeline-analytics",
41830
43585
  capScope: "device",
41831
43586
  addonId: null,
41832
43587
  access: "create"
41833
43588
  },
43589
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
43590
+ capName: "pipeline-analytics",
43591
+ capScope: "device",
43592
+ addonId: null,
43593
+ access: "create"
43594
+ },
41834
43595
  "pipelineAnalytics.pruneEvents": {
41835
43596
  capName: "pipeline-analytics",
41836
43597
  capScope: "device",
@@ -41885,6 +43646,18 @@ Object.freeze({
41885
43646
  addonId: null,
41886
43647
  access: "create"
41887
43648
  },
43649
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
43650
+ capName: "pipeline-analytics",
43651
+ capScope: "device",
43652
+ addonId: null,
43653
+ access: "delete"
43654
+ },
43655
+ "pipelineAnalytics.renameRetrainCollection": {
43656
+ capName: "pipeline-analytics",
43657
+ capScope: "device",
43658
+ addonId: null,
43659
+ access: "create"
43660
+ },
41888
43661
  "pipelineAnalytics.restageRetrainTrack": {
41889
43662
  capName: "pipeline-analytics",
41890
43663
  capScope: "device",
@@ -41945,6 +43718,12 @@ Object.freeze({
41945
43718
  addonId: null,
41946
43719
  access: "create"
41947
43720
  },
43721
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
43722
+ capName: "pipeline-analytics",
43723
+ capScope: "device",
43724
+ addonId: null,
43725
+ access: "view"
43726
+ },
41948
43727
  "pipelineAnalytics.wipeAllAnalytics": {
41949
43728
  capName: "pipeline-analytics",
41950
43729
  capScope: "device",
@@ -42173,6 +43952,12 @@ Object.freeze({
42173
43952
  addonId: null,
42174
43953
  access: "view"
42175
43954
  },
43955
+ "pipelineOrchestrator.abortNodeBenchmark": {
43956
+ capName: "pipeline-orchestrator",
43957
+ capScope: "system",
43958
+ addonId: null,
43959
+ access: "create"
43960
+ },
42176
43961
  "pipelineOrchestrator.applyAutoTune": {
42177
43962
  capName: "pipeline-orchestrator",
42178
43963
  capScope: "system",
@@ -42197,6 +43982,12 @@ Object.freeze({
42197
43982
  addonId: null,
42198
43983
  access: "create"
42199
43984
  },
43985
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
43986
+ capName: "pipeline-orchestrator",
43987
+ capScope: "system",
43988
+ addonId: null,
43989
+ access: "delete"
43990
+ },
42200
43991
  "pipelineOrchestrator.getAgentLoad": {
42201
43992
  capName: "pipeline-orchestrator",
42202
43993
  capScope: "system",
@@ -42305,6 +44096,24 @@ Object.freeze({
42305
44096
  addonId: null,
42306
44097
  access: "view"
42307
44098
  },
44099
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
44100
+ capName: "pipeline-orchestrator",
44101
+ capScope: "system",
44102
+ addonId: null,
44103
+ access: "view"
44104
+ },
44105
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
44106
+ capName: "pipeline-orchestrator",
44107
+ capScope: "system",
44108
+ addonId: null,
44109
+ access: "view"
44110
+ },
44111
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
44112
+ capName: "pipeline-orchestrator",
44113
+ capScope: "system",
44114
+ addonId: null,
44115
+ access: "view"
44116
+ },
42308
44117
  "pipelineOrchestrator.getNodeInferenceDevices": {
42309
44118
  capName: "pipeline-orchestrator",
42310
44119
  capScope: "system",
@@ -42347,6 +44156,12 @@ Object.freeze({
42347
44156
  addonId: null,
42348
44157
  access: "view"
42349
44158
  },
44159
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
44160
+ capName: "pipeline-orchestrator",
44161
+ capScope: "system",
44162
+ addonId: null,
44163
+ access: "view"
44164
+ },
42350
44165
  "pipelineOrchestrator.pauseForStorageMigration": {
42351
44166
  capName: "pipeline-orchestrator",
42352
44167
  capScope: "system",
@@ -42491,6 +44306,12 @@ Object.freeze({
42491
44306
  addonId: null,
42492
44307
  access: "create"
42493
44308
  },
44309
+ "pipelineOrchestrator.startNodeBenchmark": {
44310
+ capName: "pipeline-orchestrator",
44311
+ capScope: "system",
44312
+ addonId: null,
44313
+ access: "create"
44314
+ },
42494
44315
  "pipelineOrchestrator.suggestShares": {
42495
44316
  capName: "pipeline-orchestrator",
42496
44317
  capScope: "system",
@@ -42509,6 +44330,12 @@ Object.freeze({
42509
44330
  addonId: null,
42510
44331
  access: "create"
42511
44332
  },
44333
+ "pipelineRunner.abortNodeBench": {
44334
+ capName: "pipeline-runner",
44335
+ capScope: "system",
44336
+ addonId: null,
44337
+ access: "create"
44338
+ },
42512
44339
  "pipelineRunner.attachCamera": {
42513
44340
  capName: "pipeline-runner",
42514
44341
  capScope: "system",
@@ -42557,6 +44384,12 @@ Object.freeze({
42557
44384
  addonId: null,
42558
44385
  access: "view"
42559
44386
  },
44387
+ "pipelineRunner.getNodeBenchStatus": {
44388
+ capName: "pipeline-runner",
44389
+ capScope: "system",
44390
+ addonId: null,
44391
+ access: "view"
44392
+ },
42560
44393
  "pipelineRunner.getParkedTrackFrame": {
42561
44394
  capName: "pipeline-runner",
42562
44395
  capScope: "system",
@@ -42599,6 +44432,12 @@ Object.freeze({
42599
44432
  addonId: null,
42600
44433
  access: "create"
42601
44434
  },
44435
+ "pipelineRunner.startNodeBench": {
44436
+ capName: "pipeline-runner",
44437
+ capScope: "system",
44438
+ addonId: null,
44439
+ access: "create"
44440
+ },
42602
44441
  "plateGallery.assignPlate": {
42603
44442
  capName: "plate-gallery",
42604
44443
  capScope: "system",
@@ -47528,6 +49367,11 @@ Object.freeze({
47528
49367
  form: "single",
47529
49368
  optional: false
47530
49369
  }],
49370
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
49371
+ name: "deviceId",
49372
+ form: "single",
49373
+ optional: false
49374
+ }],
47531
49375
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
47532
49376
  name: "deviceId",
47533
49377
  form: "single",
@@ -47718,6 +49562,11 @@ Object.freeze({
47718
49562
  form: "single",
47719
49563
  optional: false
47720
49564
  }],
49565
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
49566
+ name: "deviceId",
49567
+ form: "single",
49568
+ optional: false
49569
+ }],
47721
49570
  "pipelineAnalytics.pruneEventsBefore": [{
47722
49571
  name: "deviceId",
47723
49572
  form: "single",