@camstack/system 1.2.376 → 1.2.377

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 (92) hide show
  1. package/dist/addon-runner.js +9 -4
  2. package/dist/addon-runner.mjs +10 -5
  3. package/dist/addon-utils.js +1 -1
  4. package/dist/addon-utils.mjs +1 -1
  5. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  8. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  9. package/dist/builtins/alerts/alerts.addon.js +1 -1
  10. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  11. package/dist/builtins/autotrack/index.js +1 -1
  12. package/dist/builtins/autotrack/index.mjs +1 -1
  13. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  14. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  15. package/dist/builtins/calendars/calendars.addon.js +1 -1
  16. package/dist/builtins/calendars/calendars.addon.mjs +1 -1
  17. package/dist/builtins/camera-grid/index.js +1 -1
  18. package/dist/builtins/camera-grid/index.mjs +1 -1
  19. package/dist/builtins/composer/composer.addon.js +2 -2
  20. package/dist/builtins/composer/composer.addon.mjs +2 -2
  21. package/dist/builtins/console-logging/index.js +1 -1
  22. package/dist/builtins/console-logging/index.mjs +1 -1
  23. package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  24. package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  25. package/dist/builtins/device-manager/device-config-secrets.d.ts +21 -0
  26. package/dist/builtins/device-manager/device-manager.addon.js +85 -6
  27. package/dist/builtins/device-manager/device-manager.addon.mjs +85 -6
  28. package/dist/builtins/hub-forwarder/index.js +1 -1
  29. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  30. package/dist/builtins/keychain/index.d.ts +1 -0
  31. package/dist/builtins/keychain/index.js +1416 -0
  32. package/dist/builtins/keychain/index.mjs +1409 -0
  33. package/dist/builtins/keychain/key-sources.d.ts +37 -0
  34. package/dist/builtins/keychain/keychain-crypto.d.ts +28 -0
  35. package/dist/builtins/keychain/keychain-service.d.ts +103 -0
  36. package/dist/builtins/keychain/keychain-store.d.ts +82 -0
  37. package/dist/builtins/keychain/keychain-usage.d.ts +6 -0
  38. package/dist/builtins/keychain/keychain.addon.d.ts +11 -0
  39. package/dist/builtins/keychain/platform-key-source.d.ts +24 -0
  40. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  41. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  42. package/dist/builtins/local-auth/local-auth.addon.js +19 -2
  43. package/dist/builtins/local-auth/local-auth.addon.mjs +19 -2
  44. package/dist/builtins/local-network/local-network.addon.js +1 -1
  45. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  46. package/dist/builtins/loki-logging/index.js +1 -1
  47. package/dist/builtins/loki-logging/index.mjs +1 -1
  48. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  49. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  50. package/dist/builtins/platform-probe/index.js +1 -1
  51. package/dist/builtins/platform-probe/index.mjs +1 -1
  52. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  53. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  54. package/dist/builtins/snapshot/index.js +1 -1
  55. package/dist/builtins/snapshot/index.mjs +1 -1
  56. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  57. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  58. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  59. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  60. package/dist/builtins/storage-orchestrator/location-store.d.ts +6 -0
  61. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +15 -0
  62. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +74 -14
  63. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +74 -14
  64. package/dist/builtins/system-config/system-config.addon.js +1 -1
  65. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  66. package/dist/builtins/winston-logging/index.js +1 -1
  67. package/dist/builtins/winston-logging/index.mjs +1 -1
  68. package/dist/{child-cap-dispatch-8qMgog1O.mjs → child-cap-dispatch-CgmOo0yl.mjs} +170 -27
  69. package/dist/{child-cap-dispatch-BWtaSmWf.js → child-cap-dispatch-DlDSoqm1.js} +198 -25
  70. package/dist/{composition-sources-DW7CgMsg.js → composition-sources-BNyXPSs_.js} +1 -1
  71. package/dist/{composition-sources-zxQPPtP_.mjs → composition-sources-D39bl0nP.mjs} +1 -1
  72. package/dist/{dist-D732NygW.mjs → dist-BWNoS-1S.mjs} +2195 -105
  73. package/dist/{dist-BcUWQGr9.js → dist-D_a9mUiM.js} +2260 -104
  74. package/dist/{event-loop-stall-monitor-8W4yWNVW.mjs → event-loop-stall-monitor-ClPhfx7Y.mjs} +1 -1
  75. package/dist/{event-loop-stall-monitor-QX4RjNe7.js → event-loop-stall-monitor-DuOn8H1n.js} +1 -1
  76. package/dist/{hub-cap-forward-BdT320dq.mjs → hub-cap-forward-CH6_VWVO.mjs} +13 -4
  77. package/dist/{hub-cap-forward-DmHNjbB0.js → hub-cap-forward-COCmYaup.js} +13 -4
  78. package/dist/index.d.ts +2 -0
  79. package/dist/index.js +20 -6
  80. package/dist/index.mjs +13 -7
  81. package/dist/kernel/config-schema.d.ts +4 -0
  82. package/dist/kernel/moleculer/child-addon-call-dispatch.d.ts +6 -0
  83. package/dist/kernel/transport/cap-route-resolver.d.ts +19 -0
  84. package/dist/kernel/transport/hub-cap-forward.d.ts +22 -1
  85. package/dist/kernel/transport/index.d.ts +2 -2
  86. package/dist/kernel/transport/local-child-registry.d.ts +4 -3
  87. package/dist/logging/log-redactor.d.ts +9 -0
  88. package/dist/platform-key-source-BWlq0jjn.mjs +23 -0
  89. package/dist/platform-key-source-Di7HrlGR.js +40 -0
  90. package/dist/{retired-settings-keys-MaESpO18.js → retired-settings-keys-CDyOGAje.js} +1 -1
  91. package/dist/{retired-settings-keys-CxPOg7BF.mjs → retired-settings-keys-iGcmzwLV.mjs} +1 -1
  92. package/package.json +17 -1
@@ -1,6 +1,6 @@
1
1
  let zod = require("zod");
2
2
  require("node:crypto");
3
- //#region ../types/dist/event-category-B_0XEcLF.mjs
3
+ //#region ../types/dist/event-category-DaIZi00R.mjs
4
4
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
5
5
  EventCategory["SystemBoot"] = "system.boot";
6
6
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -79,6 +79,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
79
79
  */
80
80
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
81
81
  /**
82
+ * A keychain value was stored or removed (D787). Carries the ref, its
83
+ * owner and the new version — NEVER the value. A process holding the ref
84
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
85
+ * Telemetry (D8): a process that misses it still revalidates by version.
86
+ */
87
+ EventCategory["KeychainChanged"] = "keychain.changed";
88
+ /**
82
89
  * Addon recovered from a previous failure. Emitted when an addon
83
90
  * transitions from `failed` back to `healthy` (typically via the
84
91
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -701,7 +708,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
701
708
  return EventCategory;
702
709
  }({});
703
710
  //#endregion
704
- //#region ../types/dist/sleep-B0JG7-_F.mjs
711
+ //#region ../types/dist/sleep-Cr5YOk3m.mjs
705
712
  /**
706
713
  * The audio chunk plane's byte format, and the ONE expansion from a coded
707
714
  * window to float samples (D455).
@@ -780,6 +787,144 @@ function buildAlawTable() {
780
787
  }
781
788
  buildUlawTable();
782
789
  buildAlawTable();
790
+ /**
791
+ * The value a redacted secret is replaced with on every read surface.
792
+ *
793
+ * It is also the WRITE-BACK token: an `upsertLocation` that sends this value
794
+ * back for a key means "keep what is stored", which is what lets an operator
795
+ * rename a location without retyping its password. A literal an operator could
796
+ * plausibly choose as a real password would turn that convenience into a way
797
+ * to lock yourself out, hence the sentinel shape.
798
+ */
799
+ var REDACTED_SECRET = "__camstack_redacted__";
800
+ /** Is this field's stored value a credential? */
801
+ function isSecretConfigField(field) {
802
+ if (field.type === "password") return true;
803
+ return "secret" in field && field.secret === true;
804
+ }
805
+ /**
806
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
807
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
808
+ */
809
+ function isKeychainStoredField(field) {
810
+ if (!isSecretConfigField(field)) return false;
811
+ if (field.type === "textarea" && field.isJson === true) return false;
812
+ return !("storage" in field && field.storage === "inline");
813
+ }
814
+ /**
815
+ * Every config key in `schema` whose value is a secret, including keys nested
816
+ * inside `group` / `sub-tabs` containers.
817
+ */
818
+ function collectSecretConfigKeys(schema) {
819
+ const keys = /* @__PURE__ */ new Set();
820
+ for (const section of sectionsOf(schema)) for (const field of fieldsOf(section)) walkField(field, keys);
821
+ return keys;
822
+ }
823
+ function isRecord$2(value) {
824
+ return typeof value === "object" && value !== null && !Array.isArray(value);
825
+ }
826
+ function sectionsOf(schema) {
827
+ if (!isRecord$2(schema)) return [];
828
+ const sections = schema["sections"];
829
+ return Array.isArray(sections) ? sections : [];
830
+ }
831
+ function fieldsOf(node) {
832
+ if (!isRecord$2(node)) return [];
833
+ const fields = node["fields"];
834
+ return Array.isArray(fields) ? fields : [];
835
+ }
836
+ function walkField(field, out) {
837
+ if (!isRecord$2(field)) return;
838
+ const type = field["type"];
839
+ const key = field["key"];
840
+ if ((type === "password" || field["secret"] === true) && typeof key === "string" && key.length > 0) out.add(key);
841
+ if (type === "group") {
842
+ for (const child of fieldsOf(field)) walkField(child, out);
843
+ return;
844
+ }
845
+ if (type === "sub-tabs") {
846
+ const tabs = field["tabs"];
847
+ if (!Array.isArray(tabs)) return;
848
+ for (const tab of tabs) for (const child of fieldsOf(tab)) walkField(child, out);
849
+ }
850
+ }
851
+ /**
852
+ * What a settings blob holds where a secret used to be.
853
+ *
854
+ * A keychain-stored field never holds its value. It holds a self-describing
855
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
856
+ * code can mistake it for a credential and no form can send it to a camera as
857
+ * a password. The empty state is `null` / absent, never `''`.
858
+ *
859
+ * The same shapes travel to and from the admin UI:
860
+ *
861
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
862
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
863
+ * value is set, never the value.
864
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
865
+ * value is a plain non-empty string (CHANGE); the Clear button submits
866
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
867
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
868
+ * treating it as "clear" is how a save destroyed a stored credential before.
869
+ *
870
+ * Pure and browser-safe.
871
+ */
872
+ var SECRET_CLEAR = { $secretClear: true };
873
+ /** The `'***'` token D634 redaction writes for non-admins. */
874
+ var LEGACY_DEVICE_REDACTION = "***";
875
+ function isRecord$1(value) {
876
+ return typeof value === "object" && value !== null && !Array.isArray(value);
877
+ }
878
+ function makeSecretMarker(ref) {
879
+ return {
880
+ $secret: ref,
881
+ v: 1
882
+ };
883
+ }
884
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
885
+ function isSecretMarker(value) {
886
+ if (!isRecord$1(value)) return false;
887
+ const ref = value["$secret"];
888
+ return typeof ref === "string" && ref.length > 0;
889
+ }
890
+ function isSecretClear(value) {
891
+ return isRecord$1(value) && value["$secretClear"] === true;
892
+ }
893
+ /**
894
+ * The UI view of a stored secret field value: a marker becomes "set", inline
895
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
896
+ * survives this function.
897
+ */
898
+ function toSecretFieldView(stored) {
899
+ if (isSecretMarker(stored)) return {
900
+ $secret: stored.$secret,
901
+ v: 1,
902
+ set: true
903
+ };
904
+ if (typeof stored === "string" && stored.length > 0) return {
905
+ $secret: null,
906
+ v: 1,
907
+ set: true,
908
+ inline: true
909
+ };
910
+ return null;
911
+ }
912
+ /**
913
+ * Classify an incoming value for a secret path. Only a non-empty string that is
914
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
915
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
916
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
917
+ */
918
+ function classifySecretWrite(incoming) {
919
+ if (isSecretClear(incoming)) return { kind: "clear" };
920
+ if (typeof incoming !== "string") return { kind: "keep" };
921
+ if (incoming.length === 0) return { kind: "keep" };
922
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
923
+ return {
924
+ kind: "set",
925
+ value: incoming
926
+ };
927
+ }
783
928
  /** Lookup map for well-known tabs by ID. */
784
929
  var WELL_KNOWN_TAB_MAP = Object.fromEntries([
785
930
  {
@@ -952,33 +1097,19 @@ var WELL_KNOWN_TAB_MAP = Object.fromEntries([
952
1097
  function isValuelessField(field) {
953
1098
  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";
954
1099
  }
955
- /**
956
- * Merge a `ConfigUISchema` with a raw `values` record into a
957
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
958
- * before returning to the admin UI. Groups are walked recursively.
959
- *
960
- * For each leaf field:
961
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
962
- * - other fields get `value = values[key] ?? field.default ?? null`
963
- *
964
- * Unknown keys in `values` (keys not declared in the schema) are silently
965
- * ignored — they don't contribute to the output. Missing keys fall back to
966
- * the schema default or `null`. This mirrors the old backend behaviour where
967
- * `FormBuilder` rendered `values[key] ?? field.default`.
968
- */
969
- function hydrateSchema(schema, values) {
1100
+ function hydrateSchema(schema, values, options = {}) {
970
1101
  return {
971
1102
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
972
1103
  sections: schema.sections.map((section) => ({
973
1104
  ...section,
974
- fields: section.fields.map((field) => hydrateField(field, values))
1105
+ fields: section.fields.map((field) => hydrateField(field, values, options))
975
1106
  }))
976
1107
  };
977
1108
  }
978
- function hydrateField(field, values) {
1109
+ function hydrateField(field, values, options) {
979
1110
  if (isValuelessField(field)) return field;
980
1111
  if (field.type === "group") {
981
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
1112
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
982
1113
  return {
983
1114
  ...field,
984
1115
  fields: hydratedChildren
@@ -987,7 +1118,7 @@ function hydrateField(field, values) {
987
1118
  if (field.type === "sub-tabs") {
988
1119
  const hydratedTabs = field.tabs.map((tab) => ({
989
1120
  ...tab,
990
- fields: tab.fields.map((child) => hydrateField(child, values))
1121
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
991
1122
  }));
992
1123
  return {
993
1124
  ...field,
@@ -997,6 +1128,33 @@ function hydrateField(field, values) {
997
1128
  const key = field.key;
998
1129
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
999
1130
  const defaultValue = field.default;
1131
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
1132
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
1133
+ ...field,
1134
+ value: toSecretFieldView(storedValue)
1135
+ };
1136
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
1137
+ ...field,
1138
+ value: null
1139
+ };
1140
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
1141
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
1142
+ if (secretItemKeys.length > 0) {
1143
+ const rows = storedValue.map((row) => {
1144
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
1145
+ const out = { ...row };
1146
+ for (const k of secretItemKeys) {
1147
+ const v = Reflect.get(row, k);
1148
+ if (asView(v)) out[k] = toSecretFieldView(v);
1149
+ }
1150
+ return out;
1151
+ });
1152
+ return {
1153
+ ...field,
1154
+ value: rows
1155
+ };
1156
+ }
1157
+ }
1000
1158
  if (field.multiple) {
1001
1159
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
1002
1160
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -1255,6 +1413,538 @@ function projectStore(store, perNodeKeys, nodeId) {
1255
1413
  }
1256
1414
  return out;
1257
1415
  }
1416
+ var GLOBAL_SCOPE = { kind: "global" };
1417
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
1418
+ function globalSecretScope() {
1419
+ return GLOBAL_SCOPE;
1420
+ }
1421
+ /**
1422
+ * An addon id as a ref owner. A hub in-process builtin's context id is
1423
+ * `addon:<id>`; the owner of its secrets is `<id>`, exactly as for the same
1424
+ * addon running forked.
1425
+ */
1426
+ function normalizeSecretOwner(addonId) {
1427
+ return addonId.startsWith("addon:") ? addonId.slice(6) : addonId;
1428
+ }
1429
+ function encodeSegment(value) {
1430
+ return encodeURIComponent(value);
1431
+ }
1432
+ function decodeSegment(value) {
1433
+ try {
1434
+ return decodeURIComponent(value);
1435
+ } catch {
1436
+ return null;
1437
+ }
1438
+ }
1439
+ /** The scope as it appears inside a ref (`global`, `node/<id>`, …). */
1440
+ function formatSecretScope(scope) {
1441
+ switch (scope.kind) {
1442
+ case "global": return "global";
1443
+ case "node": return `node/${encodeSegment(scope.nodeId)}`;
1444
+ case "device": return `device/${scope.deviceId}`;
1445
+ case "integration": return `integration/${encodeSegment(scope.integrationId)}`;
1446
+ case "row": return `row/${encodeSegment(scope.collection)}/${encodeSegment(scope.rowId)}`;
1447
+ }
1448
+ }
1449
+ /**
1450
+ * The field path of a value inside an array item, addressed by the item's id:
1451
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
1452
+ * `providers[authentik].clientSecret`.
1453
+ */
1454
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
1455
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
1456
+ }
1457
+ function parseScope(segments) {
1458
+ switch (segments[0]) {
1459
+ case "global": return {
1460
+ scope: GLOBAL_SCOPE,
1461
+ used: 1
1462
+ };
1463
+ case "node": {
1464
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
1465
+ return nodeId === null || nodeId.length === 0 ? null : {
1466
+ scope: {
1467
+ kind: "node",
1468
+ nodeId
1469
+ },
1470
+ used: 2
1471
+ };
1472
+ }
1473
+ case "device": {
1474
+ const raw = segments[1];
1475
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
1476
+ return {
1477
+ scope: {
1478
+ kind: "device",
1479
+ deviceId: Number(raw)
1480
+ },
1481
+ used: 2
1482
+ };
1483
+ }
1484
+ case "integration": {
1485
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
1486
+ return id === null || id.length === 0 ? null : {
1487
+ scope: {
1488
+ kind: "integration",
1489
+ integrationId: id
1490
+ },
1491
+ used: 2
1492
+ };
1493
+ }
1494
+ case "row": {
1495
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
1496
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
1497
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
1498
+ return {
1499
+ scope: {
1500
+ kind: "row",
1501
+ collection,
1502
+ rowId
1503
+ },
1504
+ used: 3
1505
+ };
1506
+ }
1507
+ default: return null;
1508
+ }
1509
+ }
1510
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
1511
+ function parseSecretRef(ref) {
1512
+ if (!ref.startsWith("secret://")) return null;
1513
+ const segments = ref.slice(9).split("/");
1514
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
1515
+ if (owner === null || owner.length === 0) return null;
1516
+ const parsed = parseScope(segments.slice(1));
1517
+ if (parsed === null) return null;
1518
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
1519
+ if (fieldPath.length === 0) return null;
1520
+ return {
1521
+ owner,
1522
+ scope: parsed.scope,
1523
+ fieldPath
1524
+ };
1525
+ }
1526
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
1527
+ var KeychainWriteRefusedError = class extends Error {
1528
+ fieldPath;
1529
+ constructor(fieldPath, cause) {
1530
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
1531
+ this.fieldPath = fieldPath;
1532
+ this.name = "KeychainWriteRefusedError";
1533
+ }
1534
+ };
1535
+ var KEEP = { kind: "keep" };
1536
+ function isRecord(value) {
1537
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1538
+ }
1539
+ function defaultMintId() {
1540
+ return globalThis.crypto.randomUUID();
1541
+ }
1542
+ /** Every marker ref anywhere under `value`. */
1543
+ function collectSecretMarkerRefs(value, out = []) {
1544
+ if (isSecretMarker(value)) {
1545
+ out.push(value.$secret);
1546
+ return out;
1547
+ }
1548
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
1549
+ else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
1550
+ return out;
1551
+ }
1552
+ async function storedValueEquals(secrets, marker, candidate) {
1553
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
1554
+ return resolved?.kind === "value" && resolved.value === candidate;
1555
+ }
1556
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
1557
+ const intent = classifySecretWrite(incoming);
1558
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
1559
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
1560
+ if (intent.kind === "keep") return KEEP;
1561
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
1562
+ if (intent.kind === "clear") {
1563
+ if (storedIsOurs) ctx.deletes.push(ref);
1564
+ return {
1565
+ kind: "value",
1566
+ value: null
1567
+ };
1568
+ }
1569
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
1570
+ kind: "value",
1571
+ value: stored
1572
+ };
1573
+ try {
1574
+ await ctx.secrets.put(ref, intent.value);
1575
+ } catch (err) {
1576
+ throw new KeychainWriteRefusedError(fieldPath, err);
1577
+ }
1578
+ return {
1579
+ kind: "value",
1580
+ value: makeSecretMarker(ref)
1581
+ };
1582
+ }
1583
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
1584
+ function applyMember(out, key, result, storedParent) {
1585
+ if (result.kind === "value") {
1586
+ out[key] = result.value;
1587
+ return;
1588
+ }
1589
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
1590
+ else delete out[key];
1591
+ }
1592
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
1593
+ const out = { ...incoming };
1594
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
1595
+ return out;
1596
+ }
1597
+ function rowId(row, idKey) {
1598
+ const raw = row[idKey];
1599
+ if (typeof raw === "string" && raw.length > 0) return raw;
1600
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
1601
+ return null;
1602
+ }
1603
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
1604
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
1605
+ if (!Array.isArray(incoming)) {
1606
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
1607
+ return {
1608
+ kind: "value",
1609
+ value: incoming
1610
+ };
1611
+ }
1612
+ const storedById = /* @__PURE__ */ new Map();
1613
+ for (const row of storedRows) {
1614
+ const id = rowId(row, node.idKey);
1615
+ if (id !== null) storedById.set(id, row);
1616
+ }
1617
+ const kept = /* @__PURE__ */ new Set();
1618
+ const rows = [];
1619
+ for (const row of incoming) {
1620
+ if (!isRecord(row)) {
1621
+ rows.push(row);
1622
+ continue;
1623
+ }
1624
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
1625
+ kept.add(id);
1626
+ const withId = {
1627
+ ...row,
1628
+ [node.idKey]: row[node.idKey] ?? id
1629
+ };
1630
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
1631
+ const storedRow = storedById.get(id) ?? {};
1632
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
1633
+ }
1634
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
1635
+ return {
1636
+ kind: "value",
1637
+ value: rows
1638
+ };
1639
+ }
1640
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
1641
+ switch (node.kind) {
1642
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
1643
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
1644
+ case "object": {
1645
+ if (!isRecord(incoming)) {
1646
+ if (incoming === void 0) return KEEP;
1647
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
1648
+ return {
1649
+ kind: "value",
1650
+ value: incoming
1651
+ };
1652
+ }
1653
+ const storedObj = isRecord(stored) ? stored : {};
1654
+ return {
1655
+ kind: "value",
1656
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
1657
+ };
1658
+ }
1659
+ }
1660
+ }
1661
+ /** Split a perNode-scoped key (`key@nodeId`). */
1662
+ function splitNodeKey(key) {
1663
+ const at = key.indexOf("@");
1664
+ return at <= 0 ? {
1665
+ base: key,
1666
+ nodeId: null
1667
+ } : {
1668
+ base: key.slice(0, at),
1669
+ nodeId: key.slice(at + 1)
1670
+ };
1671
+ }
1672
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
1673
+ async function transformSecretWrite(input) {
1674
+ const deletes = [];
1675
+ const base = {
1676
+ secrets: input.secrets,
1677
+ mintId: input.mintId ?? defaultMintId,
1678
+ deletes,
1679
+ operatorWrite: input.operatorWrite === true
1680
+ };
1681
+ const out = {};
1682
+ for (const [key, incoming] of Object.entries(input.patch)) {
1683
+ const { base: baseKey, nodeId } = splitNodeKey(key);
1684
+ const node = input.tree.get(baseKey);
1685
+ if (node === void 0) {
1686
+ out[key] = incoming;
1687
+ continue;
1688
+ }
1689
+ const scope = nodeId !== null && nodeId.length > 0 ? {
1690
+ kind: "node",
1691
+ nodeId
1692
+ } : input.scope ?? globalSecretScope();
1693
+ const result = await writeNode({
1694
+ ...base,
1695
+ scope
1696
+ }, node, incoming, input.stored[key], baseKey);
1697
+ if (result.kind === "value") out[key] = result.value;
1698
+ }
1699
+ return {
1700
+ patch: out,
1701
+ afterWrite: async () => {
1702
+ if (deletes.length === 0) return { orphaned: [] };
1703
+ try {
1704
+ await input.secrets.delete([...new Set(deletes)]);
1705
+ return { orphaned: [] };
1706
+ } catch {
1707
+ return { orphaned: [...new Set(deletes)] };
1708
+ }
1709
+ }
1710
+ };
1711
+ }
1712
+ /**
1713
+ * Replace every marker in `value` with its keychain value. Returns the SAME
1714
+ * reference when there is no marker (no allocation, no keychain call).
1715
+ */
1716
+ async function resolveSecretMarkers(value, secrets) {
1717
+ const refs = collectSecretMarkerRefs(value);
1718
+ if (refs.length === 0) return {
1719
+ value,
1720
+ unresolved: []
1721
+ };
1722
+ const answers = await secrets.resolve(refs);
1723
+ const unresolved = [];
1724
+ for (const ref of new Set(refs)) {
1725
+ const answer = answers[ref];
1726
+ if (answer === void 0) unresolved.push({
1727
+ ref,
1728
+ reason: "not-initialized"
1729
+ });
1730
+ else if (answer.kind === "unavailable") unresolved.push({
1731
+ ref,
1732
+ reason: answer.reason
1733
+ });
1734
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
1735
+ ref,
1736
+ reason: answer.kind
1737
+ });
1738
+ }
1739
+ const substitute = (v) => {
1740
+ if (isSecretMarker(v)) {
1741
+ const answer = answers[v.$secret];
1742
+ return answer?.kind === "value" ? {
1743
+ keep: true,
1744
+ value: answer.value
1745
+ } : {
1746
+ keep: false,
1747
+ value: void 0
1748
+ };
1749
+ }
1750
+ if (Array.isArray(v)) {
1751
+ const items = [];
1752
+ for (const item of v) {
1753
+ const s = substitute(item);
1754
+ if (s.keep) items.push(s.value);
1755
+ }
1756
+ return {
1757
+ keep: true,
1758
+ value: items
1759
+ };
1760
+ }
1761
+ if (isRecord(v)) {
1762
+ const out = {};
1763
+ for (const [k, child] of Object.entries(v)) {
1764
+ const s = substitute(child);
1765
+ if (s.keep) out[k] = s.value;
1766
+ }
1767
+ return {
1768
+ keep: true,
1769
+ value: out
1770
+ };
1771
+ }
1772
+ return {
1773
+ keep: true,
1774
+ value: v
1775
+ };
1776
+ };
1777
+ return {
1778
+ value: substitute(value).value,
1779
+ unresolved
1780
+ };
1781
+ }
1782
+ function touchesTree(tree, patch) {
1783
+ if (tree.size === 0) return false;
1784
+ for (const key of Object.keys(patch)) {
1785
+ const at = key.indexOf("@");
1786
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
1787
+ }
1788
+ return false;
1789
+ }
1790
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
1791
+ async function readStoredAddonBlob(raw) {
1792
+ const threeWay = raw.readAddonStoreResult;
1793
+ if (threeWay === void 0) return raw.readAddonStore();
1794
+ const result = await threeWay.call(raw);
1795
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
1796
+ return result.kind === "missing" ? {} : result.value;
1797
+ }
1798
+ function createSecretAwareSettings(raw, opts) {
1799
+ const chains = /* @__PURE__ */ new Map();
1800
+ const serialize = (key, fn) => {
1801
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
1802
+ const tail = next.catch(() => void 0);
1803
+ chains.set(key, tail);
1804
+ tail.then(() => {
1805
+ if (chains.get(key) === tail) chains.delete(key);
1806
+ });
1807
+ return next;
1808
+ };
1809
+ const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
1810
+ if (!touchesTree(tree, patch)) return rawWrite(patch);
1811
+ return serialize(chainKey, async () => {
1812
+ const stored = await readStored();
1813
+ const result = await transformSecretWrite({
1814
+ tree,
1815
+ secrets: opts.secrets,
1816
+ patch,
1817
+ stored,
1818
+ ...scope !== void 0 ? { scope } : {},
1819
+ operatorWrite: opts.isOperatorWrite?.() === true
1820
+ });
1821
+ if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
1822
+ const { orphaned } = await result.afterWrite();
1823
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
1824
+ });
1825
+ };
1826
+ const wrapped = {
1827
+ writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
1828
+ writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
1829
+ kind: "device",
1830
+ deviceId
1831
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
1832
+ };
1833
+ return new Proxy(raw, { get(target, prop, receiver) {
1834
+ if (prop === "writeAddonStore") return wrapped.writeAddonStore;
1835
+ if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
1836
+ const value = Reflect.get(target, prop, receiver);
1837
+ return typeof value === "function" ? value.bind(target) : value;
1838
+ } });
1839
+ }
1840
+ /** The context the addon sees: identical, except that its settings writes are secret-aware. */
1841
+ function withSecretAwareSettings(context, opts) {
1842
+ const raw = context.settings;
1843
+ if (raw === void 0) return context;
1844
+ const settings = createSecretAwareSettings(raw, opts);
1845
+ return new Proxy(context, { get(target, prop, receiver) {
1846
+ if (prop === "settings") return settings;
1847
+ return Reflect.get(target, prop, receiver);
1848
+ } });
1849
+ }
1850
+ var LEAF = { kind: "leaf" };
1851
+ var DEFAULT_ITEM_ID_KEY = "id";
1852
+ function collectFields(fields, out) {
1853
+ for (const field of fields) {
1854
+ if (field.type === "group") {
1855
+ collectFields(field.fields, out);
1856
+ continue;
1857
+ }
1858
+ if (field.type === "sub-tabs") {
1859
+ for (const tab of field.tabs) collectFields(tab.fields, out);
1860
+ continue;
1861
+ }
1862
+ if (field.type === "editable-array") {
1863
+ const item = /* @__PURE__ */ new Map();
1864
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
1865
+ if (item.size > 0) out.set(field.key, {
1866
+ kind: "array",
1867
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
1868
+ item
1869
+ });
1870
+ continue;
1871
+ }
1872
+ if (!("key" in field) || typeof field.key !== "string") continue;
1873
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
1874
+ }
1875
+ }
1876
+ /** The secret tree a settings schema declares. */
1877
+ function secretTreeFromSchema(schema) {
1878
+ const out = /* @__PURE__ */ new Map();
1879
+ if (schema === null) return out;
1880
+ for (const section of schema.sections) collectFields(section.fields, out);
1881
+ return out;
1882
+ }
1883
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
1884
+ function parseSecretStatePath(path) {
1885
+ const segments = [];
1886
+ for (const raw of path.split(".")) {
1887
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
1888
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
1889
+ segments.push(m[2] !== void 0 ? {
1890
+ key: m[1],
1891
+ idKey: m[2]
1892
+ } : { key: m[1] });
1893
+ }
1894
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
1895
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
1896
+ return segments;
1897
+ }
1898
+ function insert(into, segments) {
1899
+ const [head, ...rest] = segments;
1900
+ if (head === void 0) return;
1901
+ if (rest.length === 0) {
1902
+ into.set(head.key, LEAF);
1903
+ return;
1904
+ }
1905
+ const existing = into.get(head.key);
1906
+ if (head.idKey !== void 0) {
1907
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
1908
+ insert(item, rest);
1909
+ into.set(head.key, {
1910
+ kind: "array",
1911
+ idKey: head.idKey,
1912
+ item
1913
+ });
1914
+ return;
1915
+ }
1916
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
1917
+ insert(children, rest);
1918
+ into.set(head.key, {
1919
+ kind: "object",
1920
+ children
1921
+ });
1922
+ }
1923
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
1924
+ function mergeSecretStatePaths(tree, paths) {
1925
+ if (paths.length === 0) return tree;
1926
+ const out = new Map(tree);
1927
+ for (const path of paths) insert(out, parseSecretStatePath(path));
1928
+ return out;
1929
+ }
1930
+ /**
1931
+ * The tree of a DECLARED path list — a device's `secretConfigPaths`
1932
+ * (`collectZodSecretPaths`: dotted, `[]` for array items). An array segment
1933
+ * without a named id field is addressed by the item's `id`.
1934
+ */
1935
+ function secretTreeFromPaths(paths) {
1936
+ const out = /* @__PURE__ */ new Map();
1937
+ for (const path of paths) {
1938
+ if (path.length === 0) continue;
1939
+ insert(out, parseSecretStatePath(path.replace(/\[\]/g, `[${DEFAULT_ITEM_ID_KEY}]`)));
1940
+ }
1941
+ return out;
1942
+ }
1943
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
1944
+ var SECRET_RETRY_FIRST_MS = 5e3;
1945
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
1946
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
1947
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
1258
1948
  /**
1259
1949
  * Base class for CamStack addons. Eliminates settings boilerplate:
1260
1950
  *
@@ -1324,6 +2014,25 @@ var BaseAddon = class {
1324
2014
  settingsStoreReady = false;
1325
2015
  /** Default config values. Provided via constructor. */
1326
2016
  defaults;
2017
+ /**
2018
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
2019
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
2020
+ * Stored in the keychain exactly like a `password` field. Syntax:
2021
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
2022
+ * (`key[<id field>]` addresses array items by id, never by index).
2023
+ */
2024
+ secretStatePaths = [];
2025
+ _addonSecretTree = null;
2026
+ _deviceSecretTree = null;
2027
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
2028
+ _configSecretRefs = /* @__PURE__ */ new Set();
2029
+ _unresolvedSecrets = [];
2030
+ _secretRetryTimer = null;
2031
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
2032
+ _secretChangeTimer = null;
2033
+ _secretChangeUnsub = null;
2034
+ /** >0 while an OPERATOR's settings write is being applied. */
2035
+ _operatorWriteDepth = 0;
1327
2036
  constructor(defaults) {
1328
2037
  this.defaults = defaults;
1329
2038
  this._config = { ...defaults };
@@ -1359,8 +2068,18 @@ var BaseAddon = class {
1359
2068
  return this._config;
1360
2069
  }
1361
2070
  async initialize(context) {
1362
- this._ctx = context;
2071
+ const secrets = context.secrets;
2072
+ this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
2073
+ secrets,
2074
+ addonTree: () => this.addonSecretTree(),
2075
+ deviceTree: () => this.deviceSecretTree(),
2076
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
2077
+ isOperatorWrite: () => this._operatorWriteDepth > 0
2078
+ }) : context;
1363
2079
  await this.resolveConfig();
2080
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
2081
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
2082
+ });
1364
2083
  const result = await this.onInitialize();
1365
2084
  this.emitLifecycle(EventCategory.AddonStarted);
1366
2085
  const normalized = normalizeAddonInitResult(result);
@@ -1393,6 +2112,12 @@ var BaseAddon = class {
1393
2112
  */
1394
2113
  async onHubReachable() {}
1395
2114
  async shutdown() {
2115
+ this._secretChangeUnsub?.();
2116
+ this._secretChangeUnsub = null;
2117
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
2118
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
2119
+ this._secretRetryTimer = null;
2120
+ this._secretChangeTimer = null;
1396
2121
  this.emitLifecycle(EventCategory.AddonStopped);
1397
2122
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
1398
2123
  await this.onShutdown();
@@ -1471,7 +2196,7 @@ var BaseAddon = class {
1471
2196
  return hydrateSchema(schema, overlay ? {
1472
2197
  ...projected,
1473
2198
  ...overlay
1474
- } : projected);
2199
+ } : projected, { inlineSecretsAsViews: true });
1475
2200
  }
1476
2201
  /**
1477
2202
  * The integration-level view of this addon's settings: exactly the sections
@@ -1520,7 +2245,7 @@ var BaseAddon = class {
1520
2245
  return hydrateSchema({
1521
2246
  ...schema,
1522
2247
  sections
1523
- }, projected);
2248
+ }, projected, { inlineSecretsAsViews: true });
1524
2249
  }
1525
2250
  /**
1526
2251
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -1574,18 +2299,50 @@ var BaseAddon = class {
1574
2299
  value: result.value[key]
1575
2300
  };
1576
2301
  }
2302
+ /**
2303
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
2304
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
2305
+ * the operator sends is stored as sent even when it equals a pre-keychain
2306
+ * inline value: the operator re-entering a password is a change, an addon
2307
+ * writing back what it read is not (D787).
2308
+ */
2309
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
2310
+ this._operatorWriteDepth++;
2311
+ try {
2312
+ await this.applyGlobalPatch(patch, nodeId);
2313
+ } finally {
2314
+ this._operatorWriteDepth--;
2315
+ }
2316
+ }
1577
2317
  async updateGlobalSettings(patch, nodeId) {
2318
+ await this.applyGlobalPatch(patch, nodeId);
2319
+ }
2320
+ /**
2321
+ * REMOVE stored secrets — their keychain values and their markers (D787).
2322
+ *
2323
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
2324
+ * what a defaults fallback writes back, and it must never destroy a
2325
+ * credential), so code that means "forget this token" says so here. Without
2326
+ * a keychain (an older kernel) it writes `''`, as such code always did.
2327
+ */
2328
+ async clearSecrets(keys, nodeId) {
2329
+ const tree = this.addonSecretTree();
2330
+ const keychain = this._ctx?.secrets !== void 0;
2331
+ const patch = {};
2332
+ for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
2333
+ await this.applyGlobalPatch(patch, nodeId);
2334
+ }
2335
+ async applyGlobalPatch(barePatch, nodeId) {
1578
2336
  const keys = this.perNodeKeys();
1579
2337
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
1580
2338
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
1581
- const barePatch = patch;
1582
2339
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
1583
2340
  await this._ctx?.settings?.writeAddonStore(scoped);
1584
2341
  if (target !== localNode) return;
1585
2342
  await this.resolveConfig();
1586
2343
  await this.onConfigChanged();
1587
2344
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
1588
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
2345
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
1589
2346
  }
1590
2347
  /**
1591
2348
  * The set of field keys the global settings schema declares `perNode: true`
@@ -1610,7 +2367,7 @@ var BaseAddon = class {
1610
2367
  * time to return its response before the addon is torn down and
1611
2368
  * re-initialised by `AddonRegistryService.restartAddon`.
1612
2369
  */
1613
- maybeAutoRestart(patch, schema) {
2370
+ maybeAutoRestart(patchKeys, schema) {
1614
2371
  if (!schema) return;
1615
2372
  const restartKeys = /* @__PURE__ */ new Set();
1616
2373
  for (const section of schema.sections) for (const field of section.fields) {
@@ -1618,13 +2375,13 @@ var BaseAddon = class {
1618
2375
  if (field.requiresRestart) restartKeys.add(field.key);
1619
2376
  }
1620
2377
  if (restartKeys.size === 0) return;
1621
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
2378
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
1622
2379
  const ctx = this._ctx;
1623
2380
  if (!ctx) return;
1624
2381
  const addonId = ctx.id;
1625
2382
  setImmediate(() => {
1626
2383
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
1627
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
2384
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
1628
2385
  }).catch((err) => {
1629
2386
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
1630
2387
  });
@@ -1633,7 +2390,7 @@ var BaseAddon = class {
1633
2390
  async getDeviceSettings(deviceId) {
1634
2391
  const schema = this.deviceSettingsSchema();
1635
2392
  if (!schema) return { sections: [] };
1636
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
2393
+ return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
1637
2394
  }
1638
2395
  async updateDeviceSettings(deviceId, patch) {
1639
2396
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -1763,7 +2520,7 @@ var BaseAddon = class {
1763
2520
  * selection at boot (absent scoped key ⇒ the constructor default wins).
1764
2521
  */
1765
2522
  async resolveConfig() {
1766
- const stored = await this.readAddonStoreWithRetry();
2523
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
1767
2524
  const perNode = this.perNodeKeys();
1768
2525
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
1769
2526
  const resolved = { ...this.defaults };
@@ -1788,7 +2545,7 @@ var BaseAddon = class {
1788
2545
  key,
1789
2546
  schema,
1790
2547
  fallback,
1791
- read: () => this.readAddonStoreWithRetry(),
2548
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
1792
2549
  write: async (patch) => {
1793
2550
  await this._ctx?.settings?.writeAddonStore(patch);
1794
2551
  },
@@ -1805,7 +2562,7 @@ var BaseAddon = class {
1805
2562
  key,
1806
2563
  schema,
1807
2564
  fallback,
1808
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
2565
+ read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
1809
2566
  write: async (patch) => {
1810
2567
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
1811
2568
  },
@@ -1817,6 +2574,70 @@ var BaseAddon = class {
1817
2574
  } })
1818
2575
  });
1819
2576
  }
2577
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
2578
+ addonSecretTree() {
2579
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
2580
+ return this._addonSecretTree;
2581
+ }
2582
+ deviceSecretTree() {
2583
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
2584
+ return this._deviceSecretTree;
2585
+ }
2586
+ /**
2587
+ * Secrets of this addon's stored config that could not be resolved on the
2588
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
2589
+ * an addon whose function needs one should report itself degraded rather
2590
+ * than start on an empty credential.
2591
+ */
2592
+ get unresolvedSecrets() {
2593
+ return this._unresolvedSecrets;
2594
+ }
2595
+ /**
2596
+ * Substitute every keychain marker in a stored blob with its value. With no
2597
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
2598
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
2599
+ * value — and, when the cause can pass, retried with backoff. Nothing is
2600
+ * ever written back from here.
2601
+ */
2602
+ async resolveStoredSecrets(blob, trackForConfig = true) {
2603
+ const secrets = this._ctx?.secrets;
2604
+ if (secrets === void 0) return blob;
2605
+ const refs = collectSecretMarkerRefs(blob);
2606
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
2607
+ if (refs.length === 0) {
2608
+ if (trackForConfig) this._unresolvedSecrets = [];
2609
+ return blob;
2610
+ }
2611
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
2612
+ if (trackForConfig) {
2613
+ this._unresolvedSecrets = unresolved;
2614
+ if (unresolved.length > 0) {
2615
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
2616
+ ref: u.ref,
2617
+ reason: u.reason
2618
+ })) } });
2619
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
2620
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
2621
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
2622
+ }
2623
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
2624
+ }
2625
+ return value;
2626
+ }
2627
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
2628
+ scheduleSecretReresolve(delayMs) {
2629
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
2630
+ if (this[timerOf] !== null) return;
2631
+ const timer = setTimeout(() => {
2632
+ this[timerOf] = null;
2633
+ if (this._ctx === null) return;
2634
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
2635
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
2636
+ });
2637
+ }, delayMs);
2638
+ timer.unref?.();
2639
+ this[timerOf] = timer;
2640
+ }
1820
2641
  /**
1821
2642
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
1822
2643
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -1950,6 +2771,31 @@ var PeerBytesTicketSchema = zod.z.object({
1950
2771
  */
1951
2772
  declaredBytes: zod.z.number().int().nonnegative().nullable()
1952
2773
  });
2774
+ /**
2775
+ * One store per PROCESS, even when two copies of this module are loaded (an
2776
+ * addon bundle next to the framework's): keyed on a registered symbol.
2777
+ */
2778
+ var STORE_KEY = Symbol.for("camstack.keychain.known-secrets");
2779
+ function store() {
2780
+ const existing = Reflect.get(globalThis, STORE_KEY);
2781
+ if (existing !== void 0 && existing !== null) return existing;
2782
+ const created = {
2783
+ values: /* @__PURE__ */ new Map(),
2784
+ compiled: null
2785
+ };
2786
+ Reflect.set(globalThis, STORE_KEY, created);
2787
+ return created;
2788
+ }
2789
+ /** Replace every registered value inside `text` with its label. */
2790
+ function scrubKnownSecrets(text) {
2791
+ const s = store();
2792
+ const re = s.compiled;
2793
+ if (re === null || text.length < 8) return text;
2794
+ re.lastIndex = 0;
2795
+ if (!re.test(text)) return text;
2796
+ re.lastIndex = 0;
2797
+ return text.replace(re, (match) => s.values.get(match) ?? "‹secret›");
2798
+ }
1953
2799
  /** Shared Zod schemas used across streaming capabilities. */
1954
2800
  var CamProfileSchema = zod.z.enum([
1955
2801
  "high",
@@ -5778,53 +6624,6 @@ var DERIVED_CAMERA_SILENCED_CAP_NAMES = [
5778
6624
  "scene-monitor"
5779
6625
  ];
5780
6626
  /**
5781
- * The value a redacted secret is replaced with on every read surface.
5782
- *
5783
- * It is also the WRITE-BACK token: an `upsertLocation` that sends this value
5784
- * back for a key means "keep what is stored", which is what lets an operator
5785
- * rename a location without retyping its password. A literal an operator could
5786
- * plausibly choose as a real password would turn that convenience into a way
5787
- * to lock yourself out, hence the sentinel shape.
5788
- */
5789
- var REDACTED_SECRET = "__camstack_redacted__";
5790
- /**
5791
- * Every config key in `schema` whose value is a secret, including keys nested
5792
- * inside `group` / `sub-tabs` containers.
5793
- */
5794
- function collectSecretConfigKeys(schema) {
5795
- const keys = /* @__PURE__ */ new Set();
5796
- for (const section of sectionsOf(schema)) for (const field of fieldsOf(section)) walkField(field, keys);
5797
- return keys;
5798
- }
5799
- function isRecord$3(value) {
5800
- return typeof value === "object" && value !== null && !Array.isArray(value);
5801
- }
5802
- function sectionsOf(schema) {
5803
- if (!isRecord$3(schema)) return [];
5804
- const sections = schema["sections"];
5805
- return Array.isArray(sections) ? sections : [];
5806
- }
5807
- function fieldsOf(node) {
5808
- if (!isRecord$3(node)) return [];
5809
- const fields = node["fields"];
5810
- return Array.isArray(fields) ? fields : [];
5811
- }
5812
- function walkField(field, out) {
5813
- if (!isRecord$3(field)) return;
5814
- const type = field["type"];
5815
- const key = field["key"];
5816
- if ((type === "password" || field["secret"] === true) && typeof key === "string" && key.length > 0) out.add(key);
5817
- if (type === "group") {
5818
- for (const child of fieldsOf(field)) walkField(child, out);
5819
- return;
5820
- }
5821
- if (type === "sub-tabs") {
5822
- const tabs = field["tabs"];
5823
- if (!Array.isArray(tabs)) return;
5824
- for (const tab of tabs) for (const child of fieldsOf(tab)) walkField(child, out);
5825
- }
5826
- }
5827
- /**
5828
6627
  * What the gate decided about a birth, from the CALLER's point of view.
5829
6628
  *
5830
6629
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -14025,6 +14824,270 @@ id: zod.z.union([zod.z.string(), zod.z.number()]) }), {
14025
14824
  })
14026
14825
  }
14027
14826
  };
14827
+ /**
14828
+ * `keychain` — the hub's encrypted store of secret values (D787).
14829
+ *
14830
+ * Settings blobs never hold a secret: they hold a marker
14831
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
14832
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
14833
+ * is the OWNER's door to its own values: every method is owner-checked
14834
+ * against the CALLER, never against anything the caller claims.
14835
+ *
14836
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
14837
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
14838
+ * connection, the agent from its child's connection carried in
14839
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
14840
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
14841
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
14842
+ * identity against BUGS and misrouting, not against a malicious addon (every
14843
+ * runner is the same OS user): see the threat model in
14844
+ * `docs/design/2026-10-08-secrets-keychain.md`.
14845
+ *
14846
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
14847
+ * parses the input, so a session can never supply it, and the internal mount
14848
+ * floors every method to admin anyway (D240).
14849
+ *
14850
+ * Internal: addons reach it through `ctx.secrets`, never directly.
14851
+ */
14852
+ /** Why a value cannot be served right now. Never folded into "missing". */
14853
+ var KeychainUnavailableReasonSchema = zod.z.enum([
14854
+ "key-missing",
14855
+ "wrong-key",
14856
+ "key-file-unreadable",
14857
+ "store-unavailable",
14858
+ "not-initialized",
14859
+ "decrypt-failed"
14860
+ ]);
14861
+ var KeychainStateSchema = zod.z.discriminatedUnion("state", [zod.z.object({ state: zod.z.literal("ready") }), zod.z.object({
14862
+ state: zod.z.literal("locked"),
14863
+ reason: KeychainUnavailableReasonSchema
14864
+ })]);
14865
+ var KeychainResolveEntrySchema = zod.z.discriminatedUnion("kind", [
14866
+ zod.z.object({
14867
+ kind: zod.z.literal("value"),
14868
+ value: zod.z.string(),
14869
+ version: zod.z.number().int()
14870
+ }),
14871
+ zod.z.object({ kind: zod.z.literal("missing") }),
14872
+ zod.z.object({
14873
+ kind: zod.z.literal("unavailable"),
14874
+ reason: KeychainUnavailableReasonSchema
14875
+ }),
14876
+ zod.z.object({ kind: zod.z.literal("forbidden") })
14877
+ ]);
14878
+ var KeychainResolveResultSchema = zod.z.record(zod.z.string(), KeychainResolveEntrySchema);
14879
+ /** Metadata of one stored value — never the value. */
14880
+ var KeychainSecretMetaSchema = zod.z.object({
14881
+ ref: zod.z.string(),
14882
+ owner: zod.z.string(),
14883
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
14884
+ scope: zod.z.string(),
14885
+ fieldPath: zod.z.string(),
14886
+ version: zod.z.number().int(),
14887
+ createdAt: zod.z.number(),
14888
+ updatedAt: zod.z.number(),
14889
+ /** `addon:<id>` | `user:<id>` | `system`. */
14890
+ updatedBy: zod.z.string(),
14891
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
14892
+ lastReadAt: zod.z.number().nullable()
14893
+ });
14894
+ var RefListSchema = zod.z.array(zod.z.string().min(1)).max(512);
14895
+ var keychainCapability = {
14896
+ name: "keychain",
14897
+ scope: "system",
14898
+ mode: "singleton",
14899
+ internal: true,
14900
+ methods: {
14901
+ /** Store (or replace) the caller's value at `ref`. Refused while locked. */
14902
+ put: method(zod.z.object({
14903
+ ref: zod.z.string().min(1),
14904
+ value: zod.z.string().min(1)
14905
+ }), zod.z.object({
14906
+ ref: zod.z.string(),
14907
+ version: zod.z.number().int()
14908
+ }), {
14909
+ kind: "mutation",
14910
+ auth: "admin"
14911
+ }),
14912
+ /**
14913
+ * Resolve the caller's refs in one round-trip. A locked keychain answers
14914
+ * `unavailable` per ref — never `missing`, never an empty value.
14915
+ */
14916
+ resolve: method(zod.z.object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }),
14917
+ /** Remove the caller's refs. Unknown refs are ignored. */
14918
+ delete: method(zod.z.object({ refs: RefListSchema }), zod.z.object({ deleted: zod.z.number().int() }), {
14919
+ kind: "mutation",
14920
+ auth: "admin"
14921
+ }),
14922
+ /** The caller's own refs, metadata only. */
14923
+ listMeta: method(zod.z.object({}), zod.z.array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }),
14924
+ /** Whether values can be served — the save path refuses a write while locked. */
14925
+ getState: method(zod.z.object({}), KeychainStateSchema, { auth: "admin" })
14926
+ }
14927
+ };
14928
+ /**
14929
+ * `keychain-admin` — the operator's view of the keychain (System → Secrets).
14930
+ *
14931
+ * Every method is `admin`. Two methods hand out material, each audited and
14932
+ * each named for exactly that: {@link keychainAdminCapability.methods.reveal}
14933
+ * (one value, shown briefly by the UI) and `downloadRecoveryKey` (the master
14934
+ * key itself, so the operator can keep a copy off the hub). Nothing else
14935
+ * returns a value.
14936
+ *
14937
+ * The master key's LOCATION is configuration, never an env var (D788):
14938
+ * `keychain.keyFile` in `config.yaml`, the OS keychain on a desktop hub, else
14939
+ * `<dataDir>/.keychain/master.key` — which sits beside the database in every
14940
+ * whole-volume backup, and the status says so.
14941
+ */
14942
+ /** Where the master key in use came from. */
14943
+ var KeychainKeySourceKindSchema = zod.z.enum([
14944
+ "config-file",
14945
+ "previous-config-file",
14946
+ "platform",
14947
+ "default-file"
14948
+ ]);
14949
+ var KeychainKeySourceSchema = zod.z.object({
14950
+ kind: KeychainKeySourceKindSchema,
14951
+ /** File sources only — a path is not a secret. */
14952
+ path: zod.z.string().optional(),
14953
+ /**
14954
+ * True when a whole-volume backup of the data directory carries this key
14955
+ * next to the database it protects (the default file). The page warns.
14956
+ */
14957
+ sharesBackupWithDatabase: zod.z.boolean()
14958
+ });
14959
+ var KeychainStatusSchema = zod.z.object({
14960
+ keychain: KeychainStateSchema,
14961
+ /** The source of the master key in use; `null` while locked. */
14962
+ keySource: KeychainKeySourceSchema.nullable(),
14963
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
14964
+ configuredSource: KeychainKeySourceSchema,
14965
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
14966
+ fingerprint: zod.z.string().nullable(),
14967
+ activeKeyId: zod.z.string().nullable(),
14968
+ /**
14969
+ * The keychain unlocked with a NON-primary source: the configured primary
14970
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
14971
+ */
14972
+ rotationPending: zod.z.boolean(),
14973
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
14974
+ retiredWraps: zod.z.number().int(),
14975
+ recoveryKeyDownloadedAt: zod.z.number().nullable(),
14976
+ secretCount: zod.z.number().int()
14977
+ });
14978
+ /**
14979
+ * Whether a stored value is still pointed at by its owner's settings.
14980
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
14981
+ * never reported as an orphan (and never deleted as one).
14982
+ */
14983
+ var KeychainSecretUsageSchema = zod.z.enum([
14984
+ "in-use",
14985
+ "orphan",
14986
+ "unknown"
14987
+ ]);
14988
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
14989
+ var KeychainAuditActionSchema = zod.z.enum([
14990
+ "put",
14991
+ "delete",
14992
+ "reveal",
14993
+ "rotate-master-key",
14994
+ "purge-retired-keys",
14995
+ "download-recovery-key",
14996
+ "delete-orphans",
14997
+ "reset",
14998
+ "initialize"
14999
+ ]);
15000
+ var KeychainAuditEntrySchema = zod.z.object({
15001
+ id: zod.z.string(),
15002
+ at: zod.z.number(),
15003
+ action: KeychainAuditActionSchema,
15004
+ /** `addon:<id>` | `user:<id>` | `system`. */
15005
+ actor: zod.z.string(),
15006
+ ref: zod.z.string().nullable(),
15007
+ detail: zod.z.string().nullable()
15008
+ });
15009
+ var keychainAdminCapability = {
15010
+ name: "keychain-admin",
15011
+ scope: "system",
15012
+ mode: "singleton",
15013
+ methods: {
15014
+ status: method(zod.z.object({}), KeychainStatusSchema, { auth: "admin" }),
15015
+ listSecrets: method(zod.z.object({}), zod.z.array(KeychainAdminSecretSchema).readonly(), { auth: "admin" }),
15016
+ listAudit: method(zod.z.object({ limit: zod.z.number().int().min(1).max(500).optional() }), zod.z.array(KeychainAuditEntrySchema).readonly(), { auth: "admin" }),
15017
+ /**
15018
+ * Show one value to the operator. Audited. The UI hides it again after a
15019
+ * few seconds; nothing caches it.
15020
+ */
15021
+ reveal: method(zod.z.object({ ref: zod.z.string().min(1) }), zod.z.object({
15022
+ value: zod.z.string(),
15023
+ version: zod.z.number().int()
15024
+ }), {
15025
+ kind: "mutation",
15026
+ auth: "admin",
15027
+ caller: "required"
15028
+ }),
15029
+ /** Delete refs no owner points at any more. Re-checked here; `unknown` is kept. */
15030
+ deleteOrphans: method(zod.z.object({ refs: zod.z.array(zod.z.string().min(1)).max(1e3) }), zod.z.object({
15031
+ deleted: zod.z.array(zod.z.string()).readonly(),
15032
+ kept: zod.z.array(zod.z.object({
15033
+ ref: zod.z.string(),
15034
+ usage: KeychainSecretUsageSchema
15035
+ })).readonly()
15036
+ }), {
15037
+ kind: "mutation",
15038
+ auth: "admin",
15039
+ caller: "required"
15040
+ }),
15041
+ /**
15042
+ * Wrap the data key under the configured primary master key.
15043
+ *
15044
+ * Pending rotation (the keychain unlocked with a previous source): re-wrap
15045
+ * under the primary. Otherwise, with the default file as primary: generate
15046
+ * a new master key, write it there, re-wrap. A file or OS-keychain primary
15047
+ * that is already in use cannot be replaced from here — put the new key at
15048
+ * the source, keep the old one as `keychain.previousKeyFile`, restart, and
15049
+ * rotate. No value is re-encrypted either way; the previous wrap is kept
15050
+ * (retired) until purged.
15051
+ */
15052
+ rotateMasterKey: method(zod.z.object({}), zod.z.object({
15053
+ fingerprint: zod.z.string(),
15054
+ keySource: KeychainKeySourceSchema
15055
+ }), {
15056
+ kind: "mutation",
15057
+ auth: "admin",
15058
+ caller: "required"
15059
+ }),
15060
+ purgeRetiredKeys: method(zod.z.object({}), zod.z.object({ purged: zod.z.number().int() }), {
15061
+ kind: "mutation",
15062
+ auth: "admin",
15063
+ caller: "required"
15064
+ }),
15065
+ /** The master key, base64. Audited; marks the recovery copy as taken. */
15066
+ downloadRecoveryKey: method(zod.z.object({}), zod.z.object({
15067
+ key: zod.z.string(),
15068
+ fingerprint: zod.z.string(),
15069
+ keySource: KeychainKeySourceSchema
15070
+ }), {
15071
+ kind: "mutation",
15072
+ auth: "admin",
15073
+ caller: "required"
15074
+ }),
15075
+ /**
15076
+ * Lost-key recovery: archive every stored value into a
15077
+ * `keychain:secrets-orphaned-<ts>` table and start over with a new data
15078
+ * key. Every secret field then reads "not set". Requires the typed
15079
+ * confirmation {@link KEYCHAIN_RESET_CONFIRMATION}.
15080
+ */
15081
+ resetKeychain: method(zod.z.object({ confirm: zod.z.literal("RESET KEYCHAIN") }), zod.z.object({
15082
+ archivedCollection: zod.z.string().nullable(),
15083
+ archived: zod.z.number().int()
15084
+ }), {
15085
+ kind: "mutation",
15086
+ auth: "admin",
15087
+ caller: "required"
15088
+ })
15089
+ }
15090
+ };
14028
15091
  var decoderCapability = {
14029
15092
  name: "decoder",
14030
15093
  scope: "system",
@@ -15444,7 +16507,11 @@ var DeviceRegisterPayloadSchema = zod.z.object({
15444
16507
  var DeviceRemovePayloadSchema = zod.z.object({ deviceId: zod.z.number() });
15445
16508
  var DevicePersistConfigPayloadSchema = zod.z.object({
15446
16509
  deviceId: zod.z.number(),
15447
- data: zod.z.record(zod.z.string(), zod.z.unknown())
16510
+ data: zod.z.record(zod.z.string(), zod.z.unknown()),
16511
+ /** The paths the device's schema declares secret (D783), when the caller
16512
+ * knows them — those values are kept in the keychain, not the blob (D787).
16513
+ * Absent: the paths the device last reported at `registerDevice` apply. */
16514
+ secretConfigPaths: zod.z.array(zod.z.string()).optional()
15448
16515
  });
15449
16516
  /** What a migration actually did, per switch. `unreachable` is a first-class
15450
16517
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -24162,8 +25229,23 @@ var RetrainMacroClassSchema = zod.z.enum([
24162
25229
  ]);
24163
25230
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
24164
25231
  var RetrainAnnotationKindSchema = zod.z.enum(["subject", "model_error"]);
24165
- /** Did a human draw this box, or did the assist propose it? */
24166
- var RetrainAnnotationSourceSchema = zod.z.enum(["operator", "assist"]);
25232
+ /**
25233
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
25234
+ * the operator confirms it; once saved it keeps its source as provenance.
25235
+ *
25236
+ * - `operator` — drawn by hand.
25237
+ * - `assist` — proposed by a detector run on the copy (the camera's own
25238
+ * model, or a larger teacher model).
25239
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
25240
+ * back from the track store (never a re-run).
25241
+ * - `llm` — proposed by a vision-capable LLM profile.
25242
+ */
25243
+ var RetrainAnnotationSourceSchema = zod.z.enum([
25244
+ "operator",
25245
+ "assist",
25246
+ "pipeline",
25247
+ "llm"
25248
+ ]);
24167
25249
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
24168
25250
  var RetrainBboxSchema = zod.z.object({
24169
25251
  x: zod.z.number(),
@@ -24181,7 +25263,8 @@ var RetrainBboxSchema = zod.z.object({
24181
25263
  */
24182
25264
  var RetrainAnnotationSchema = zod.z.object({
24183
25265
  id: zod.z.string(),
24184
- trackId: zod.z.string(),
25266
+ /** The frame's track. Absent on a recording still, which has none. */
25267
+ trackId: zod.z.string().optional(),
24185
25268
  deviceId: zod.z.number(),
24186
25269
  /** The COPY in retrain storage — never the source track's media key. */
24187
25270
  mediaKey: zod.z.string(),
@@ -24230,13 +25313,47 @@ var RetrainFrameCandidateSchema = zod.z.object({
24230
25313
  * fail, whatever became of the original. */
24231
25314
  copied: zod.z.boolean()
24232
25315
  });
25316
+ /**
25317
+ * One box the live pipeline drew on a copied frame — what a correction starts
25318
+ * from. Derived when the frame is listed, from the track store: the subject
25319
+ * box recorded on the source media row when there is one, else the track
25320
+ * position nearest the frame's capture time. Never stored as an annotation
25321
+ * until the operator confirms it.
25322
+ */
25323
+ var RetrainPipelineBoxSchema = zod.z.object({
25324
+ /** Normalised `[0,1]` against the full frame. */
25325
+ bbox: RetrainBboxSchema,
25326
+ macroClass: RetrainMacroClassSchema,
25327
+ label: zod.z.string().optional(),
25328
+ subLabel: zod.z.string().optional(),
25329
+ /** The detection score of the position used, when it was recorded. */
25330
+ score: zod.z.number().optional(),
25331
+ /** The root model that produced the track, when it was recorded. */
25332
+ modelId: zod.z.string().optional(),
25333
+ trackId: zod.z.string(),
25334
+ /** `subject-box`: recorded on this very frame. `position`: the track's
25335
+ * position nearest the capture time, `deltaMs` away. */
25336
+ basis: zod.z.enum(["subject-box", "position"]),
25337
+ deltaMs: zod.z.number()
25338
+ });
25339
+ /**
25340
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
25341
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
25342
+ * track at all.
25343
+ */
25344
+ var RetrainFrameOriginSchema = zod.z.enum(["track", "recording"]);
24233
25345
  /** A frame the dataset OWNS: bytes copied at selection time. */
24234
25346
  var RetrainFrameSchema = zod.z.object({
24235
25347
  frameId: zod.z.string(),
24236
25348
  deviceId: zod.z.number(),
24237
- trackId: zod.z.string(),
24238
- /** Provenance only. It may already point at nothing — that is expected. */
24239
- sourceMediaId: zod.z.number().int(),
25349
+ origin: RetrainFrameOriginSchema,
25350
+ /** The track it was copied from. Absent on a recording still. */
25351
+ trackId: zod.z.string().optional(),
25352
+ /** Provenance only. It may already point at nothing — that is expected.
25353
+ * Absent on a recording still. */
25354
+ sourceMediaId: zod.z.number().int().optional(),
25355
+ /** A recording still: the playhead instant it was taken at. */
25356
+ epochMs: zod.z.number().optional(),
24240
25357
  sourceKind: MediaFileKindEnum,
24241
25358
  sizeBytes: zod.z.number().int(),
24242
25359
  width: zod.z.number().int(),
@@ -24247,7 +25364,12 @@ var RetrainFrameSchema = zod.z.object({
24247
25364
  /** The operator's "every subject in this frame is boxed". Detector
24248
25365
  * evaluation keeps only complete frames: an unboxed subject would count as
24249
25366
  * a false positive. */
24250
- complete: zod.z.boolean()
25367
+ complete: zod.z.boolean(),
25368
+ /** The boxes the pipeline drew on this frame. Present on list answers;
25369
+ * empty when nothing the track store holds can be placed on it. */
25370
+ pipelineBoxes: zod.z.array(RetrainPipelineBoxSchema).readonly().optional(),
25371
+ /** The named collections this frame belongs to. Present on list answers. */
25372
+ collectionIds: zod.z.array(zod.z.string()).readonly().optional()
24251
25373
  });
24252
25374
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
24253
25375
  var RetrainCopyRefusalSchema = zod.z.enum([
@@ -24278,6 +25400,8 @@ var RetrainFrameListSchema = zod.z.object({
24278
25400
  var RetrainExportFilterSchema = zod.z.object({
24279
25401
  deviceIds: zod.z.array(zod.z.number()).optional(),
24280
25402
  frameIds: zod.z.array(zod.z.string()).max(2e4).optional(),
25403
+ /** Only frames in at least one of these named collections. */
25404
+ collectionIds: zod.z.array(zod.z.string()).max(200).optional(),
24281
25405
  batchId: zod.z.string().optional(),
24282
25406
  /** Only frames the operator marked complete (all subjects boxed). */
24283
25407
  completeOnly: zod.z.boolean().optional()
@@ -24342,6 +25466,109 @@ var RetrainAssistResultSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
24342
25466
  reason: zod.z.string(),
24343
25467
  detail: zod.z.string().optional()
24344
25468
  })]);
25469
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
25470
+ var RetrainCollectionSchema = zod.z.object({
25471
+ id: zod.z.string(),
25472
+ name: zod.z.string(),
25473
+ createdAt: zod.z.number(),
25474
+ frameCount: zod.z.number().int()
25475
+ });
25476
+ var RetrainCollectionCreateResultSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
25477
+ kind: zod.z.literal("created"),
25478
+ collection: RetrainCollectionSchema
25479
+ }), zod.z.object({
25480
+ kind: zod.z.literal("refused"),
25481
+ reason: zod.z.enum(["empty-name", "duplicate-name"])
25482
+ })]);
25483
+ var RetrainCollectionRenameResultSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
25484
+ kind: zod.z.literal("renamed"),
25485
+ collection: RetrainCollectionSchema
25486
+ }), zod.z.object({
25487
+ kind: zod.z.literal("refused"),
25488
+ reason: zod.z.enum([
25489
+ "empty-name",
25490
+ "duplicate-name",
25491
+ "unknown-collection"
25492
+ ])
25493
+ })]);
25494
+ /**
25495
+ * The outcome of adding the frame at a recording instant. Every refusal is
25496
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
25497
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
25498
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
25499
+ */
25500
+ var AddRetrainFrameFromRecordingResultSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
25501
+ kind: zod.z.literal("added"),
25502
+ collectionId: zod.z.string(),
25503
+ frame: RetrainFrameSchema,
25504
+ /** The moment was already in the dataset; nothing was decoded. */
25505
+ reused: zod.z.boolean()
25506
+ }), zod.z.object({
25507
+ kind: zod.z.literal("refused"),
25508
+ reason: zod.z.enum([
25509
+ "unknown-collection",
25510
+ "still-unavailable",
25511
+ "still-busy",
25512
+ "unreadable-image",
25513
+ "write-failed"
25514
+ ]),
25515
+ detail: zod.z.string().optional()
25516
+ })]);
25517
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
25518
+ var RetrainAssistProfileSchema = zod.z.object({
25519
+ id: zod.z.string(),
25520
+ name: zod.z.string(),
25521
+ model: zod.z.string(),
25522
+ kind: zod.z.string(),
25523
+ /** `true` when the frame would leave the house (a cloud vendor, or an
25524
+ * endpoint that is not on the local network). The page confirms each such
25525
+ * run, and the provider refuses one without `allowCloud`. */
25526
+ leavesHouse: zod.z.boolean()
25527
+ });
25528
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
25529
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: zod.z.string() });
25530
+ /** What the AI assist said about a box that was already on the canvas. */
25531
+ var RetrainLlmReviewSchema = zod.z.object({
25532
+ /** The `ref` the page sent the box under. */
25533
+ ref: zod.z.string(),
25534
+ verdict: zod.z.enum([
25535
+ "confirmed",
25536
+ "wrong-class",
25537
+ "not-an-object",
25538
+ "uncertain"
25539
+ ]),
25540
+ suggestedClass: RetrainMacroClassSchema.optional(),
25541
+ reason: zod.z.string()
25542
+ });
25543
+ /**
25544
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
25545
+ * model and its confidence) and reviews; items the model got wrong (a box off
25546
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
25547
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
25548
+ */
25549
+ var RetrainLlmAssistResultSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
25550
+ kind: zod.z.literal("proposed"),
25551
+ profileId: zod.z.string(),
25552
+ model: zod.z.string(),
25553
+ /** The frame was sent outside the house for this answer. */
25554
+ leftHouse: zod.z.boolean(),
25555
+ proposals: zod.z.array(RetrainLlmProposalSchema).readonly(),
25556
+ reviews: zod.z.array(RetrainLlmReviewSchema).readonly(),
25557
+ rejected: zod.z.number().int()
25558
+ }), zod.z.object({
25559
+ kind: zod.z.literal("refused"),
25560
+ reason: zod.z.enum([
25561
+ "unknown-frame",
25562
+ "unreadable-frame",
25563
+ "unknown-profile",
25564
+ "profile-disabled",
25565
+ "no-vision",
25566
+ "cloud-not-confirmed",
25567
+ "llm-error",
25568
+ "malformed-answer"
25569
+ ]),
25570
+ detail: zod.z.string().optional()
25571
+ })]);
24345
25572
  /** The outcome of a lifecycle move owned by the retrain page. */
24346
25573
  var RetrainTransitionResultSchema = zod.z.object({
24347
25574
  trackId: zod.z.string(),
@@ -25528,7 +26755,7 @@ var pipelineAnalyticsCapability = {
25528
26755
  * a frame leaves the dataset before export. */
25529
26756
  deselectRetrainFrame: method(zod.z.object({
25530
26757
  deviceId: zod.z.number(),
25531
- trackId: zod.z.string(),
26758
+ trackId: zod.z.string().optional(),
25532
26759
  frameId: zod.z.string()
25533
26760
  }), zod.z.object({
25534
26761
  removed: zod.z.boolean(),
@@ -25571,7 +26798,8 @@ var pipelineAnalyticsCapability = {
25571
26798
  */
25572
26799
  proposeRetrainAnnotations: method(zod.z.object({
25573
26800
  deviceId: zod.z.number(),
25574
- trackId: zod.z.string(),
26801
+ /** The frame's track, when it has one — checked against the frame. */
26802
+ trackId: zod.z.string().optional(),
25575
26803
  frameId: zod.z.string(),
25576
26804
  subject: RetrainAssistSubjectSchema,
25577
26805
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -25580,8 +26808,12 @@ var pipelineAnalyticsCapability = {
25580
26808
  kind: "mutation",
25581
26809
  auth: "admin"
25582
26810
  }),
25583
- /** Every annotation on a track, oldest first. */
25584
- listRetrainAnnotations: method(zod.z.object({ trackId: zod.z.string() }), zod.z.array(RetrainAnnotationSchema).readonly(), {
26811
+ /** Every annotation on a track, or on named frames (a recording still has
26812
+ * no track), oldest first. One of the two is required. */
26813
+ listRetrainAnnotations: method(zod.z.object({
26814
+ trackId: zod.z.string().optional(),
26815
+ frameIds: zod.z.array(zod.z.string()).max(2e3).optional()
26816
+ }), zod.z.array(RetrainAnnotationSchema).readonly(), {
25585
26817
  kind: "query",
25586
26818
  auth: "admin"
25587
26819
  }),
@@ -25600,7 +26832,8 @@ var pipelineAnalyticsCapability = {
25600
26832
  */
25601
26833
  saveRetrainAnnotations: method(zod.z.object({
25602
26834
  deviceId: zod.z.number(),
25603
- trackId: zod.z.string(),
26835
+ /** The frame's track, when it has one — checked against the frame. */
26836
+ trackId: zod.z.string().optional(),
25604
26837
  frameId: zod.z.string(),
25605
26838
  annotations: zod.z.array(RetrainAnnotationDraftSchema)
25606
26839
  }), zod.z.array(RetrainAnnotationSchema).readonly(), {
@@ -25663,7 +26896,7 @@ var pipelineAnalyticsCapability = {
25663
26896
  */
25664
26897
  setRetrainFrameComplete: method(zod.z.object({
25665
26898
  deviceId: zod.z.number(),
25666
- trackId: zod.z.string(),
26899
+ trackId: zod.z.string().optional(),
25667
26900
  frameId: zod.z.string(),
25668
26901
  complete: zod.z.boolean()
25669
26902
  }), RetrainFrameSchema, {
@@ -25686,6 +26919,115 @@ var pipelineAnalyticsCapability = {
25686
26919
  auth: "admin",
25687
26920
  timeoutMs: 60 * 6e4
25688
26921
  }),
26922
+ /** The enabled, vision-capable LLM profiles, each saying whether a frame
26923
+ * sent to it leaves the house. */
26924
+ listRetrainAssistProfiles: method(zod.z.object({}), zod.z.array(RetrainAssistProfileSchema).readonly(), {
26925
+ kind: "query",
26926
+ auth: "admin"
26927
+ }),
26928
+ /**
26929
+ * Ask a vision LLM (the `llm` capability) about ONE copied frame: list the
26930
+ * objects of `classes` with boxes, and review the boxes already on the
26931
+ * canvas (sent by `ref`). Answers drafts (`source: 'llm'`) and reviews —
26932
+ * nothing is stored, nothing is accepted. A profile that sends the frame
26933
+ * outside the house is refused unless `allowCloud` says the operator
26934
+ * confirmed this run.
26935
+ */
26936
+ proposeRetrainAnnotationsWithLlm: method(zod.z.object({
26937
+ deviceId: zod.z.number(),
26938
+ trackId: zod.z.string().optional(),
26939
+ frameId: zod.z.string(),
26940
+ profileId: zod.z.string(),
26941
+ classes: zod.z.array(RetrainMacroClassSchema).min(1),
26942
+ boxes: zod.z.array(zod.z.object({
26943
+ ref: zod.z.string(),
26944
+ bbox: RetrainBboxSchema,
26945
+ macroClass: RetrainMacroClassSchema,
26946
+ label: zod.z.string().optional()
26947
+ })).max(50),
26948
+ allowCloud: zod.z.boolean()
26949
+ }), RetrainLlmAssistResultSchema, {
26950
+ kind: "mutation",
26951
+ auth: "admin",
26952
+ timeoutMs: 18e4
26953
+ }),
26954
+ /**
26955
+ * Create a named collection — a set over the retrain corpus ("packages
26956
+ * porch night"). Names are unique case-insensitively and never empty;
26957
+ * both refusals are named.
26958
+ */
26959
+ createRetrainCollection: method(zod.z.object({ name: zod.z.string().max(120) }), RetrainCollectionCreateResultSchema, {
26960
+ kind: "mutation",
26961
+ auth: "admin"
26962
+ }),
26963
+ /** Every collection, newest first, with its frame count. */
26964
+ listRetrainCollections: method(zod.z.object({}), zod.z.array(RetrainCollectionSchema).readonly(), {
26965
+ kind: "query",
26966
+ auth: "admin"
26967
+ }),
26968
+ renameRetrainCollection: method(zod.z.object({
26969
+ id: zod.z.string(),
26970
+ name: zod.z.string().max(120)
26971
+ }), RetrainCollectionRenameResultSchema, {
26972
+ kind: "mutation",
26973
+ auth: "admin"
26974
+ }),
26975
+ /**
26976
+ * Delete a collection. Its recording stills that no other collection
26977
+ * holds are deleted with their annotations (nothing else reaches them);
26978
+ * frames copied from tracks always stay in the dataset.
26979
+ */
26980
+ deleteRetrainCollection: method(zod.z.object({ id: zod.z.string() }), zod.z.object({
26981
+ deleted: zod.z.boolean(),
26982
+ removedFrames: zod.z.number().int()
26983
+ }), {
26984
+ kind: "mutation",
26985
+ auth: "admin"
26986
+ }),
26987
+ /**
26988
+ * Add the frame at a recording instant to a collection — the frame the
26989
+ * model may have seen NOTHING in. The recorder re-decodes the native
26990
+ * frame at `epochMs`; the dataset copies it (trackless, durable). The same
26991
+ * moment twice is one copy. Every refusal is named.
26992
+ */
26993
+ addRetrainFrameFromRecording: method(zod.z.object({
26994
+ collectionId: zod.z.string(),
26995
+ deviceId: zod.z.number(),
26996
+ epochMs: zod.z.number()
26997
+ }), AddRetrainFrameFromRecordingResultSchema, {
26998
+ kind: "mutation",
26999
+ auth: "admin",
27000
+ timeoutMs: 6e4
27001
+ }),
27002
+ /** Add frames already in the dataset to a collection. */
27003
+ addRetrainFramesToCollection: method(zod.z.object({
27004
+ collectionId: zod.z.string(),
27005
+ frameIds: zod.z.array(zod.z.string()).min(1).max(500)
27006
+ }), zod.z.object({
27007
+ added: zod.z.number().int(),
27008
+ alreadyMember: zod.z.number().int(),
27009
+ unknownFrameIds: zod.z.array(zod.z.string()).readonly()
27010
+ }), {
27011
+ kind: "mutation",
27012
+ auth: "admin"
27013
+ }),
27014
+ /** Remove a frame from a collection. A recording still left in no
27015
+ * collection is deleted with its annotations (`deletedFrame`). */
27016
+ removeRetrainFrameFromCollection: method(zod.z.object({
27017
+ collectionId: zod.z.string(),
27018
+ frameId: zod.z.string()
27019
+ }), zod.z.object({
27020
+ removed: zod.z.boolean(),
27021
+ deletedFrame: zod.z.boolean()
27022
+ }), {
27023
+ kind: "mutation",
27024
+ auth: "admin"
27025
+ }),
27026
+ /** The frames of a collection, with their pipeline boxes. */
27027
+ listRetrainCollectionFrames: method(zod.z.object({ collectionId: zod.z.string() }), zod.z.array(RetrainFrameSchema).readonly(), {
27028
+ kind: "query",
27029
+ auth: "admin"
27030
+ }),
25689
27031
  /**
25690
27032
  * The media an EVENT owns.
25691
27033
  *
@@ -26626,13 +27968,31 @@ var RecommendationReasonSchema = zod.z.discriminatedUnion("kind", [
26626
27968
  zod.z.object({
26627
27969
  kind: zod.z.literal("no-family-build"),
26628
27970
  format: ModelFormatSchema$1
27971
+ }),
27972
+ zod.z.object({
27973
+ kind: zod.z.literal("kept-custom-pin"),
27974
+ modelId: zod.z.string(),
27975
+ deviceKey: zod.z.string()
26629
27976
  })
26630
27977
  ]);
27978
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
27979
+ var KeptReasonSchema = zod.z.enum(["custom-pin"]);
27980
+ /**
27981
+ * Where a choice's latency came from (D791): this node's own benchmark
27982
+ * result, or the hardware-class table. Measured on the node beats the table.
27983
+ */
27984
+ var LatencySourceSchema = zod.z.discriminatedUnion("kind", [zod.z.object({ kind: zod.z.literal("table") }), zod.z.object({
27985
+ kind: zod.z.literal("node-benchmark"),
27986
+ resultId: zod.z.string(),
27987
+ measuredAtMs: zod.z.number()
27988
+ })]);
26631
27989
  var DeviceModelChoiceSchema = zod.z.object({
26632
27990
  modelId: zod.z.string(),
26633
27991
  p50Ms: zod.z.number(),
26634
27992
  fps: zod.z.number(),
26635
27993
  measured: zod.z.boolean(),
27994
+ /** Absent on a plan from before D791 — read as the table. */
27995
+ source: LatencySourceSchema.optional(),
26636
27996
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
26637
27997
  capacitySessions: zod.z.number(),
26638
27998
  personRecall: zod.z.number()
@@ -26643,6 +28003,8 @@ var DeviceRecommendationSchema = zod.z.object({
26643
28003
  enabled: zod.z.boolean(),
26644
28004
  available: zod.z.boolean(),
26645
28005
  chosen: DeviceModelChoiceSchema.nullable(),
28006
+ /** Present when the device is kept as is: Apply writes nothing on it. */
28007
+ kept: KeptReasonSchema.optional(),
26646
28008
  reasons: zod.z.array(RecommendationReasonSchema).readonly()
26647
28009
  });
26648
28010
  var NodeRecommendationSchema = zod.z.object({
@@ -26696,6 +28058,17 @@ var AutoTuneWarningSchema = zod.z.discriminatedUnion("kind", [
26696
28058
  kind: zod.z.literal("coral-enabled"),
26697
28059
  nodeId: zod.z.string(),
26698
28060
  deviceKey: zod.z.string()
28061
+ }),
28062
+ zod.z.object({
28063
+ kind: zod.z.literal("custom-pin-kept"),
28064
+ nodeId: zod.z.string(),
28065
+ deviceKey: zod.z.string().nullable(),
28066
+ deviceId: zod.z.number().nullable(),
28067
+ modelId: zod.z.string()
28068
+ }),
28069
+ zod.z.object({
28070
+ kind: zod.z.literal("custom-registry-unreadable"),
28071
+ error: zod.z.string()
26699
28072
  })
26700
28073
  ]);
26701
28074
  var AutoTuneOptionsSchema = zod.z.object({
@@ -26874,13 +28247,14 @@ var SuggestSharesResultSchema = zod.z.object({
26874
28247
  nodes: zod.z.array(SuggestedNodeShareSchema).readonly()
26875
28248
  });
26876
28249
  /**
26877
- * Where the node and device shares come from (D750, D755).
26878
- * - `hardware` (default) — computed by the system from each node's static
26879
- * capacity (its accelerators at their Auto tune models, from the measured
26880
- * latency table), recomputed whenever a node or device joins, leaves, is
26881
- * switched on or off, or changes model. No load input.
26882
- * - `benchmark` — the same, from each node's measured capacity (node
26883
- * benchmark results); a node without results falls back to `hardware`.
28250
+ * Where the node and device shares come from (D750, D755, D791).
28251
+ * - `benchmark` (default since D791) — each node's capacity as its own node
28252
+ * benchmark measured it; a node without fresh results is sized from
28253
+ * `hardware` and says so. Measured on the node beats the table.
28254
+ * - `hardware` — computed from each node's static capacity only (its
28255
+ * accelerators at their Auto tune models, from the latency table).
28256
+ * Both are recomputed whenever a node or device joins, leaves, is switched
28257
+ * on or off, changes model, or a benchmark result is written. No load input.
26884
28258
  * - `manual` — the operator's stored sliders.
26885
28259
  * Either way a node or device that cannot take sessions gives its share to
26886
28260
  * the others in proportion; the stored values are never rewritten for that.
@@ -26929,6 +28303,368 @@ var EffectiveSharesSchema = zod.z.object({
26929
28303
  nodeWeights: zod.z.record(zod.z.string(), zod.z.number()),
26930
28304
  deviceWeights: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.number()))
26931
28305
  });
28306
+ /**
28307
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
28308
+ * preflight the confirmation shows, the run the orchestrator owns, what the
28309
+ * measuring runner reports, and the result rows Auto tune and the automatic
28310
+ * shares read.
28311
+ *
28312
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
28313
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
28314
+ * detection candidate, camera pins naming it are ignored so its sessions move
28315
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
28316
+ * restart too (a persisted manifest, reconciled against the registry).
28317
+ *
28318
+ * Two measurements, both on the node, driven by its own runner (frames never
28319
+ * cross a process at frame rate, D9):
28320
+ * - `device` — one accelerator × one candidate detector, root only, open
28321
+ * loop: how many streams at the camera rate it carries inside the frame
28322
+ * interval;
28323
+ * - `pipeline` — the chosen detector plus the operator's detail steps
28324
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
28325
+ * clip: how many parallel sessions the node carries before latency, drops,
28326
+ * CPU, RAM or the event loop give out.
28327
+ */
28328
+ /** Defaults and bounds, one place. */
28329
+ var NODE_BENCHMARK_DEFAULTS = {
28330
+ fpsPerStream: 10,
28331
+ budgetMinutes: 45,
28332
+ minBudgetMinutes: 10,
28333
+ maxBudgetMinutes: 120,
28334
+ /** A result older than this no longer beats the table. */
28335
+ staleAfterDays: 30,
28336
+ /** Warm-in per ramp step (not accounted). */
28337
+ settleSec: 5,
28338
+ /** Accounted window per ramp step. */
28339
+ measureSec: 20,
28340
+ /** Longest the drain may take before the run is refused. */
28341
+ drainTimeoutSec: 120,
28342
+ /** Candidate models per device in one run. */
28343
+ maxModelsPerDevice: 6
28344
+ };
28345
+ /** The two measurements a run can make. */
28346
+ var NodeBenchmarkPhaseSchema = zod.z.enum(["device", "pipeline"]);
28347
+ var NodeBenchmarkDevicePlanSchema = zod.z.object({
28348
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
28349
+ deviceKey: zod.z.string().min(1),
28350
+ /**
28351
+ * Root detector candidates for the `device` measurement, in the order
28352
+ * measured. The FIRST is the one the `pipeline` measurement runs.
28353
+ */
28354
+ modelIds: zod.z.array(zod.z.string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
28355
+ });
28356
+ /** What the operator confirmed. */
28357
+ var NodeBenchmarkPlanSchema = zod.z.object({
28358
+ nodeId: zod.z.string().min(1),
28359
+ devices: zod.z.array(NodeBenchmarkDevicePlanSchema).min(1),
28360
+ /** Which measurements run. At least one. */
28361
+ phases: zod.z.array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
28362
+ /**
28363
+ * Detail steps (catalog step ids under the root: faces, plates,
28364
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
28365
+ * detector always runs.
28366
+ */
28367
+ steps: zod.z.array(zod.z.string().min(1)).default([]),
28368
+ /** Offered rate of one stream / session. */
28369
+ fpsPerStream: zod.z.number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
28370
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
28371
+ budgetMinutes: zod.z.number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
28372
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
28373
+ keepDownloadedModels: zod.z.boolean().default(false),
28374
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
28375
+ acceptInsufficientHeadroom: zod.z.boolean().default(false)
28376
+ });
28377
+ /** Why a run cannot start. `overridable` ones are lifted by a plan flag. */
28378
+ var NodeBenchmarkRefusalKindSchema = zod.z.enum([
28379
+ "benchmark-active",
28380
+ "node-offline",
28381
+ "unknown-device",
28382
+ "no-phase",
28383
+ "insufficient-headroom"
28384
+ ]);
28385
+ var NodeBenchmarkRefusalSchema = zod.z.object({
28386
+ kind: NodeBenchmarkRefusalKindSchema,
28387
+ detail: zod.z.string(),
28388
+ overridable: zod.z.boolean()
28389
+ });
28390
+ /** A camera whose detection leaves the node for the run. */
28391
+ var NodeBenchmarkMovingCameraSchema = zod.z.object({
28392
+ deviceId: zod.z.number(),
28393
+ /** Placed on the node now (a standing attach or a running session). */
28394
+ placedOnNode: zod.z.boolean(),
28395
+ /** A node pin naming this node, ignored for the run. */
28396
+ pinnedToNode: zod.z.boolean()
28397
+ });
28398
+ /** A camera that cannot leave: no other node can obtain its frames. */
28399
+ var NodeBenchmarkStayingCameraSchema = zod.z.object({
28400
+ deviceId: zod.z.number(),
28401
+ reason: zod.z.literal("only-frame-source")
28402
+ });
28403
+ var NodeBenchmarkPreflightSchema = zod.z.object({
28404
+ nodeId: zod.z.string(),
28405
+ online: zod.z.boolean(),
28406
+ moving: zod.z.array(NodeBenchmarkMovingCameraSchema).readonly(),
28407
+ /** Keep running on the node during the run; the result is flagged contaminated. */
28408
+ staying: zod.z.array(NodeBenchmarkStayingCameraSchema).readonly(),
28409
+ estimatedDurationMs: zod.z.number(),
28410
+ /** The run ends and the cluster is restored at the latest after this long. */
28411
+ budgetMs: zod.z.number(),
28412
+ phases: zod.z.array(NodeBenchmarkPhaseSchema).readonly(),
28413
+ steps: zod.z.array(zod.z.string()).readonly(),
28414
+ devices: zod.z.array(NodeBenchmarkDevicePlanSchema).readonly(),
28415
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
28416
+ headroom: zod.z.object({
28417
+ sessionsNow: zod.z.number(),
28418
+ otherNodesCapacitySessions: zod.z.number().nullable()
28419
+ }),
28420
+ refusals: zod.z.array(NodeBenchmarkRefusalSchema).readonly(),
28421
+ canStart: zod.z.boolean()
28422
+ });
28423
+ /** Where the measuring runner is. */
28424
+ var NodeBenchProgressSchema = zod.z.object({
28425
+ phase: zod.z.enum([
28426
+ "preparing",
28427
+ "device",
28428
+ "pipeline",
28429
+ "cleanup"
28430
+ ]),
28431
+ deviceKey: zod.z.string().nullable(),
28432
+ modelId: zod.z.string().nullable(),
28433
+ /** Streams (device) or sessions (pipeline) of the step running now. */
28434
+ load: zod.z.number().nullable(),
28435
+ cellsDone: zod.z.number(),
28436
+ cellsTotal: zod.z.number(),
28437
+ message: zod.z.string()
28438
+ });
28439
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
28440
+ var NodeBenchLimitSchema = zod.z.enum([
28441
+ "p95",
28442
+ "drops",
28443
+ "errors",
28444
+ "stall",
28445
+ "cpu",
28446
+ "ram",
28447
+ "none"
28448
+ ]);
28449
+ var NodeBenchRampStepSchema = zod.z.object({
28450
+ load: zod.z.number(),
28451
+ pass: zod.z.boolean(),
28452
+ p95Ms: zod.z.number(),
28453
+ dropRatio: zod.z.number(),
28454
+ /** Completed frames per second over the accounted window. */
28455
+ fps: zod.z.number(),
28456
+ cpuPct: zod.z.number().nullable(),
28457
+ ramFreePct: zod.z.number().nullable(),
28458
+ failReasons: zod.z.array(zod.z.string()).readonly()
28459
+ });
28460
+ /** One measured device × detector (the `device` measurement). */
28461
+ var NodeBenchDeviceCellSchema = zod.z.object({
28462
+ phase: zod.z.literal("device"),
28463
+ deviceKey: zod.z.string(),
28464
+ modelId: zod.z.string(),
28465
+ /** Single-stream latency (the K = 1 step). */
28466
+ p50Ms: zod.z.number(),
28467
+ p95Ms: zod.z.number(),
28468
+ p99Ms: zod.z.number(),
28469
+ /** Frames per second sustained at the last passing step. */
28470
+ fps: zod.z.number(),
28471
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
28472
+ kMax: zod.z.number(),
28473
+ limitedBy: NodeBenchLimitSchema,
28474
+ /** First call (model load + warm-up). */
28475
+ warmupMs: zod.z.number(),
28476
+ ramp: zod.z.array(NodeBenchRampStepSchema).readonly()
28477
+ });
28478
+ /** One measured pipeline (the `pipeline` measurement) on a device. */
28479
+ var NodeBenchPipelineCellSchema = zod.z.object({
28480
+ phase: zod.z.literal("pipeline"),
28481
+ deviceKey: zod.z.string(),
28482
+ modelId: zod.z.string(),
28483
+ steps: zod.z.array(zod.z.string()).readonly(),
28484
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
28485
+ maxSessions: zod.z.number(),
28486
+ limitedBy: NodeBenchLimitSchema,
28487
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
28488
+ stepsFired: zod.z.array(zod.z.string()).readonly(),
28489
+ warmupMs: zod.z.number(),
28490
+ ramp: zod.z.array(NodeBenchRampStepSchema).readonly()
28491
+ });
28492
+ var NodeBenchCellSchema = zod.z.discriminatedUnion("phase", [NodeBenchDeviceCellSchema, NodeBenchPipelineCellSchema]);
28493
+ /**
28494
+ * What a result was measured ON. A result whose fingerprint no longer matches
28495
+ * the node no longer beats the table.
28496
+ */
28497
+ var NodeBenchFingerprintSchema = zod.z.object({
28498
+ pipelineVersion: zod.z.string().nullable(),
28499
+ cpuModel: zod.z.string().nullable(),
28500
+ ramGb: zod.z.number().nullable(),
28501
+ os: zod.z.string().nullable(),
28502
+ /** Per device: the pool the cells ran on (runtime + tuning). */
28503
+ pools: zod.z.record(zod.z.string(), zod.z.object({
28504
+ runtime: zod.z.string(),
28505
+ numWorkers: zod.z.number(),
28506
+ concurrency: zod.z.number(),
28507
+ batchMode: zod.z.string()
28508
+ })).default({})
28509
+ });
28510
+ /** The frames the run used. */
28511
+ var NodeBenchClipSchema = zod.z.object({
28512
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
28513
+ id: zod.z.string(),
28514
+ revision: zod.z.string().nullable(),
28515
+ frames: zod.z.number(),
28516
+ width: zod.z.number(),
28517
+ height: zod.z.number()
28518
+ });
28519
+ var NodeBenchRunnerInputSchema = zod.z.object({
28520
+ runId: zod.z.string().min(1),
28521
+ devices: zod.z.array(NodeBenchmarkDevicePlanSchema).min(1),
28522
+ phases: zod.z.array(NodeBenchmarkPhaseSchema).min(1),
28523
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
28524
+ steps: zod.z.array(zod.z.string()).default([]),
28525
+ fpsPerStream: zod.z.number().int().min(1).max(30),
28526
+ /** The runner stops on its own past this instant, whatever the hub does. */
28527
+ deadlineAtMs: zod.z.number(),
28528
+ settleSec: zod.z.number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
28529
+ measureSec: zod.z.number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
28530
+ keepDownloadedModels: zod.z.boolean().default(false)
28531
+ });
28532
+ var NodeBenchRunnerStateSchema = zod.z.enum([
28533
+ "running",
28534
+ "done",
28535
+ "failed",
28536
+ "aborted"
28537
+ ]);
28538
+ var NodeBenchRunnerStatusSchema = zod.z.object({
28539
+ runId: zod.z.string(),
28540
+ nodeId: zod.z.string(),
28541
+ state: NodeBenchRunnerStateSchema,
28542
+ progress: NodeBenchProgressSchema.nullable(),
28543
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
28544
+ cells: zod.z.array(NodeBenchCellSchema).readonly(),
28545
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
28546
+ clip: NodeBenchClipSchema.nullable(),
28547
+ /** Cameras seen running on the node during the run (they share its pools). */
28548
+ activeCameraIds: zod.z.array(zod.z.number()).readonly(),
28549
+ /** Models the run downloaded and then deleted (not installed before). */
28550
+ deletedModels: zod.z.array(zod.z.string()).readonly(),
28551
+ error: zod.z.string().nullable(),
28552
+ startedAtMs: zod.z.number(),
28553
+ finishedAtMs: zod.z.number().nullable()
28554
+ });
28555
+ var NodeBenchmarkStateSchema = zod.z.enum([
28556
+ "draining",
28557
+ "measuring",
28558
+ "restoring",
28559
+ "done",
28560
+ "failed",
28561
+ "aborted"
28562
+ ]);
28563
+ /** Why a run ended. */
28564
+ var NodeBenchmarkEndReasonSchema = zod.z.enum([
28565
+ "completed",
28566
+ "operator-abort",
28567
+ "deadline",
28568
+ "node-lost",
28569
+ "runner-lost",
28570
+ "hub-restart",
28571
+ "drain-timeout",
28572
+ "failed"
28573
+ ]);
28574
+ var NodeBenchmarkRunSchema = zod.z.object({
28575
+ runId: zod.z.string(),
28576
+ nodeId: zod.z.string(),
28577
+ state: NodeBenchmarkStateSchema,
28578
+ plan: NodeBenchmarkPlanSchema,
28579
+ startedAtMs: zod.z.number(),
28580
+ deadlineAtMs: zod.z.number(),
28581
+ finishedAtMs: zod.z.number().nullable(),
28582
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
28583
+ error: zod.z.string().nullable(),
28584
+ /** Cameras moved off the node for the run. */
28585
+ moved: zod.z.array(zod.z.number()).readonly(),
28586
+ /** Cameras that stayed (their only frame source is the node). */
28587
+ staying: zod.z.array(zod.z.number()).readonly(),
28588
+ /** Something else ran on the node's pools during the run. */
28589
+ contaminated: zod.z.boolean(),
28590
+ progress: NodeBenchProgressSchema.nullable(),
28591
+ resultIds: zod.z.array(zod.z.string()).readonly()
28592
+ });
28593
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
28594
+ var NodeBenchmarkStatusSchema = zod.z.object({
28595
+ /** The node the cluster is in benchmark mode for; null = none. */
28596
+ modeNodeId: zod.z.string().nullable(),
28597
+ run: NodeBenchmarkRunSchema.nullable()
28598
+ });
28599
+ /**
28600
+ * One stored measurement — the only authority Auto tune and the automatic
28601
+ * shares read measured capacity from. Written by the orchestrator when a run
28602
+ * ends, never by anyone else.
28603
+ */
28604
+ var NodeBenchmarkResultSchema = zod.z.object({
28605
+ id: zod.z.string(),
28606
+ runId: zod.z.string(),
28607
+ nodeId: zod.z.string(),
28608
+ cell: NodeBenchCellSchema,
28609
+ fpsPerStream: zod.z.number(),
28610
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
28611
+ clip: NodeBenchClipSchema.nullable(),
28612
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
28613
+ contaminated: zod.z.boolean(),
28614
+ stayingCameras: zod.z.array(zod.z.number()).readonly(),
28615
+ /** The run ended early; the cell itself completed. */
28616
+ partialRun: zod.z.boolean(),
28617
+ measuredAtMs: zod.z.number()
28618
+ });
28619
+ var ListNodeBenchmarkResultsInputSchema = zod.z.object({
28620
+ nodeId: zod.z.string().optional(),
28621
+ deviceKey: zod.z.string().optional()
28622
+ });
28623
+ /** A result with its standing today: does it still beat the table? */
28624
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
28625
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
28626
+ standing: zod.z.enum([
28627
+ "fresh",
28628
+ "stale",
28629
+ "superseded"
28630
+ ]),
28631
+ staleWhy: zod.z.enum([
28632
+ "age",
28633
+ "runtime",
28634
+ "pool-tuning"
28635
+ ]).nullable()
28636
+ });
28637
+ zod.z.object({
28638
+ runId: zod.z.string(),
28639
+ nodeId: zod.z.string(),
28640
+ startedAtMs: zod.z.number(),
28641
+ deadlineAtMs: zod.z.number(),
28642
+ plan: NodeBenchmarkPlanSchema,
28643
+ moved: zod.z.array(zod.z.number()).readonly(),
28644
+ staying: zod.z.array(zod.z.number()).readonly()
28645
+ });
28646
+ /** Candidate detectors per device, for the plan editor. */
28647
+ var NodeBenchmarkCandidatesSchema = zod.z.object({
28648
+ nodeId: zod.z.string(),
28649
+ reachable: zod.z.boolean(),
28650
+ devices: zod.z.array(zod.z.object({
28651
+ deviceKey: zod.z.string(),
28652
+ enabled: zod.z.boolean(),
28653
+ available: zod.z.boolean(),
28654
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
28655
+ suggested: zod.z.array(zod.z.string()).readonly(),
28656
+ /** Every root detector the device has a build for. */
28657
+ all: zod.z.array(zod.z.string()).readonly(),
28658
+ /** The model the device runs now, when pinned. */
28659
+ currentModelId: zod.z.string().nullable()
28660
+ })).readonly(),
28661
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
28662
+ steps: zod.z.array(zod.z.object({
28663
+ id: zod.z.string(),
28664
+ name: zod.z.string(),
28665
+ slot: zod.z.string()
28666
+ })).readonly()
28667
+ });
26932
28668
  zod.z.object({
26933
28669
  activeCameras: zod.z.number(),
26934
28670
  throttledCameras: zod.z.number(),
@@ -28247,7 +29983,30 @@ var pipelineRunnerCapability = {
28247
29983
  releaseParkedTrackFrames: method(zod.z.object({
28248
29984
  deviceId: zod.z.number(),
28249
29985
  trackId: zod.z.string()
28250
- }), zod.z.object({ released: zod.z.number().int().nonnegative() }), { kind: "mutation" })
29986
+ }), zod.z.object({ released: zod.z.number().int().nonnegative() }), { kind: "mutation" }),
29987
+ /**
29988
+ * Start measuring THIS node for the orchestrator's node benchmark: the
29989
+ * bench clip decoded once into RAM, each device × candidate detector on an
29990
+ * open-loop ramp (`device`), then the chosen pipeline with the requested
29991
+ * detail steps (`pipeline`). Everything runs in-process with the executor
29992
+ * — no frame crosses a node (D9) — and writes nothing: no track, event,
29993
+ * media or notification. Reached by `nodePin(nodeId)`. Answers at once;
29994
+ * one run per node; the run stops itself at `deadlineAtMs`.
29995
+ */
29996
+ startNodeBench: method(NodeBenchRunnerInputSchema, zod.z.object({
29997
+ accepted: zod.z.literal(true),
29998
+ runId: zod.z.string()
29999
+ }), {
30000
+ kind: "mutation",
30001
+ auth: "admin"
30002
+ }),
30003
+ /** The run's progress and every finished cell; null when this runner does not know `runId`. */
30004
+ getNodeBenchStatus: method(zod.z.object({ runId: zod.z.string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }),
30005
+ /** Stop the run; what it finished is kept. */
30006
+ abortNodeBench: method(zod.z.object({ runId: zod.z.string() }), zod.z.object({ aborted: zod.z.boolean() }), {
30007
+ kind: "mutation",
30008
+ auth: "admin"
30009
+ })
28251
30010
  }
28252
30011
  };
28253
30012
  var CameraPipelineConfigSchema = zod.z.object({
@@ -29205,6 +30964,51 @@ var pipelineOrchestratorCapability = {
29205
30964
  kind: "mutation",
29206
30965
  auth: "admin"
29207
30966
  }),
30967
+ /**
30968
+ * Node benchmark — what a run of this plan would do, without doing it:
30969
+ * the cameras that leave the node, those that cannot (the node is their
30970
+ * only frame source; they stay and flag the run), the estimated duration
30971
+ * and every reason it may not start. The confirmation shows this.
30972
+ */
30973
+ getNodeBenchmarkPreflight: method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }),
30974
+ /**
30975
+ * Node benchmark — start ONE run (cluster-wide lock). The orchestrator
30976
+ * persists a restore manifest, enters benchmark mode for the node (out of
30977
+ * placement, its camera pins ignored, nothing rewritten), drains it, drives
30978
+ * the node's own runner, then restores — always, including after an
30979
+ * abort, a lost node or a hub restart. Answers at once; poll
30980
+ * `getNodeBenchmarkStatus`. Refused runs carry the preflight.
30981
+ */
30982
+ startNodeBenchmark: method(NodeBenchmarkPlanSchema, zod.z.discriminatedUnion("kind", [zod.z.object({
30983
+ kind: zod.z.literal("started"),
30984
+ runId: zod.z.string()
30985
+ }), zod.z.object({
30986
+ kind: zod.z.literal("refused"),
30987
+ preflight: NodeBenchmarkPreflightSchema
30988
+ })]), {
30989
+ kind: "mutation",
30990
+ auth: "admin"
30991
+ }),
30992
+ /** Node benchmark — the active run (or the last one) and the node in benchmark mode. */
30993
+ getNodeBenchmarkStatus: method(zod.z.void(), NodeBenchmarkStatusSchema, { auth: "admin" }),
30994
+ /** Node benchmark — stop the active run; the cluster is restored as it was. */
30995
+ abortNodeBenchmark: method(zod.z.object({ runId: zod.z.string() }), zod.z.object({ aborted: zod.z.boolean() }), {
30996
+ kind: "mutation",
30997
+ auth: "admin"
30998
+ }),
30999
+ /**
31000
+ * Node benchmark — root detector candidates per device (what Auto tune
31001
+ * would pick first, then the family) and the detail steps the node's
31002
+ * catalog offers, for the plan editor.
31003
+ */
31004
+ getNodeBenchmarkCandidates: method(zod.z.object({ nodeId: zod.z.string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }),
31005
+ /** Node benchmark — stored results, newest first, each with its standing today. */
31006
+ listNodeBenchmarkResults: method(ListNodeBenchmarkResultsInputSchema, zod.z.array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }),
31007
+ /** Node benchmark — delete one result; Auto tune and the shares stop reading it. */
31008
+ deleteNodeBenchmarkResult: method(zod.z.object({ id: zod.z.string() }), zod.z.object({ deleted: zod.z.boolean() }), {
31009
+ kind: "mutation",
31010
+ auth: "admin"
31011
+ }),
29208
31012
  /** Read one camera's settings. Null when never touched (inherits agent defaults fully). */
29209
31013
  getCameraSettings: method(zod.z.object({ deviceId: zod.z.number() }), CameraPipelineSettingsSchema.nullable()),
29210
31014
  /** Set or clear the 3-state toggle for one (camera, addonId). Pass `enabled: null` to clear and revert to agent default. */
@@ -36764,6 +38568,9 @@ var CreateIntegrationInputSchema = zod.z.object({
36764
38568
  enabled: zod.z.boolean().optional(),
36765
38569
  info: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
36766
38570
  settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
38571
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
38572
+ * the keychain, not the table (D787). */
38573
+ secretKeys: zod.z.array(zod.z.string()).optional(),
36767
38574
  skipRestart: zod.z.boolean().optional()
36768
38575
  });
36769
38576
  var UpdateIntegrationInputSchema = zod.z.object({
@@ -36799,7 +38606,9 @@ var integrationsCapability = {
36799
38606
  getSettings: method(zod.z.object({ id: zod.z.string() }), zod.z.record(zod.z.string(), zod.z.unknown()), { auth: "admin" }),
36800
38607
  setSettings: method(zod.z.object({
36801
38608
  id: zod.z.string(),
36802
- settings: zod.z.record(zod.z.string(), zod.z.unknown())
38609
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()),
38610
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
38611
+ secretKeys: zod.z.array(zod.z.string()).optional()
36803
38612
  }), zod.z.object({ success: zod.z.boolean() }), {
36804
38613
  kind: "mutation",
36805
38614
  auth: "admin"
@@ -46952,7 +48761,8 @@ var BaseDevice = class {
46952
48761
  this.role = options.role;
46953
48762
  this.parentDeviceId = ctx.parentDeviceId;
46954
48763
  const seedData = ctx.persistedConfig ?? {};
46955
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
48764
+ const declaredSecretPaths = collectZodSecretPaths(schema);
48765
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
46956
48766
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
46957
48767
  tags: {
46958
48768
  deviceId: ctx.id,
@@ -50424,6 +52234,90 @@ var METHOD_ACCESS_MAP = Object.freeze({
50424
52234
  addonId: null,
50425
52235
  access: "create"
50426
52236
  },
52237
+ "keychain.delete": {
52238
+ capName: "keychain",
52239
+ capScope: "system",
52240
+ addonId: null,
52241
+ access: "delete"
52242
+ },
52243
+ "keychain.getState": {
52244
+ capName: "keychain",
52245
+ capScope: "system",
52246
+ addonId: null,
52247
+ access: "view"
52248
+ },
52249
+ "keychain.listMeta": {
52250
+ capName: "keychain",
52251
+ capScope: "system",
52252
+ addonId: null,
52253
+ access: "view"
52254
+ },
52255
+ "keychain.put": {
52256
+ capName: "keychain",
52257
+ capScope: "system",
52258
+ addonId: null,
52259
+ access: "create"
52260
+ },
52261
+ "keychain.resolve": {
52262
+ capName: "keychain",
52263
+ capScope: "system",
52264
+ addonId: null,
52265
+ access: "view"
52266
+ },
52267
+ "keychainAdmin.deleteOrphans": {
52268
+ capName: "keychain-admin",
52269
+ capScope: "system",
52270
+ addonId: null,
52271
+ access: "delete"
52272
+ },
52273
+ "keychainAdmin.downloadRecoveryKey": {
52274
+ capName: "keychain-admin",
52275
+ capScope: "system",
52276
+ addonId: null,
52277
+ access: "create"
52278
+ },
52279
+ "keychainAdmin.listAudit": {
52280
+ capName: "keychain-admin",
52281
+ capScope: "system",
52282
+ addonId: null,
52283
+ access: "view"
52284
+ },
52285
+ "keychainAdmin.listSecrets": {
52286
+ capName: "keychain-admin",
52287
+ capScope: "system",
52288
+ addonId: null,
52289
+ access: "view"
52290
+ },
52291
+ "keychainAdmin.purgeRetiredKeys": {
52292
+ capName: "keychain-admin",
52293
+ capScope: "system",
52294
+ addonId: null,
52295
+ access: "delete"
52296
+ },
52297
+ "keychainAdmin.resetKeychain": {
52298
+ capName: "keychain-admin",
52299
+ capScope: "system",
52300
+ addonId: null,
52301
+ access: "delete"
52302
+ },
52303
+ "keychainAdmin.reveal": {
52304
+ capName: "keychain-admin",
52305
+ capScope: "system",
52306
+ addonId: null,
52307
+ access: "create"
52308
+ },
52309
+ "keychainAdmin.rotateMasterKey": {
52310
+ capName: "keychain-admin",
52311
+ capScope: "system",
52312
+ addonId: null,
52313
+ access: "create"
52314
+ },
52315
+ "keychainAdmin.status": {
52316
+ capName: "keychain-admin",
52317
+ capScope: "system",
52318
+ addonId: null,
52319
+ access: "view"
52320
+ },
50427
52321
  "lawnMowerControl.dock": {
50428
52322
  capName: "lawn-mower-control",
50429
52323
  capScope: "device",
@@ -51798,6 +53692,18 @@ var METHOD_ACCESS_MAP = Object.freeze({
51798
53692
  addonId: null,
51799
53693
  access: "create"
51800
53694
  },
53695
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
53696
+ capName: "pipeline-analytics",
53697
+ capScope: "device",
53698
+ addonId: null,
53699
+ access: "create"
53700
+ },
53701
+ "pipelineAnalytics.addRetrainFramesToCollection": {
53702
+ capName: "pipeline-analytics",
53703
+ capScope: "device",
53704
+ addonId: null,
53705
+ access: "create"
53706
+ },
51801
53707
  "pipelineAnalytics.applyDeviceSettingsPatch": {
51802
53708
  capName: "pipeline-analytics",
51803
53709
  capScope: "device",
@@ -51846,12 +53752,24 @@ var METHOD_ACCESS_MAP = Object.freeze({
51846
53752
  addonId: null,
51847
53753
  access: "view"
51848
53754
  },
53755
+ "pipelineAnalytics.createRetrainCollection": {
53756
+ capName: "pipeline-analytics",
53757
+ capScope: "device",
53758
+ addonId: null,
53759
+ access: "create"
53760
+ },
51849
53761
  "pipelineAnalytics.deleteDeviceEvents": {
51850
53762
  capName: "pipeline-analytics",
51851
53763
  capScope: "device",
51852
53764
  addonId: null,
51853
53765
  access: "delete"
51854
53766
  },
53767
+ "pipelineAnalytics.deleteRetrainCollection": {
53768
+ capName: "pipeline-analytics",
53769
+ capScope: "device",
53770
+ addonId: null,
53771
+ access: "delete"
53772
+ },
51855
53773
  "pipelineAnalytics.deleteTracks": {
51856
53774
  capName: "pipeline-analytics",
51857
53775
  capScope: "device",
@@ -52056,6 +53974,24 @@ var METHOD_ACCESS_MAP = Object.freeze({
52056
53974
  addonId: null,
52057
53975
  access: "view"
52058
53976
  },
53977
+ "pipelineAnalytics.listRetrainAssistProfiles": {
53978
+ capName: "pipeline-analytics",
53979
+ capScope: "device",
53980
+ addonId: null,
53981
+ access: "view"
53982
+ },
53983
+ "pipelineAnalytics.listRetrainCollectionFrames": {
53984
+ capName: "pipeline-analytics",
53985
+ capScope: "device",
53986
+ addonId: null,
53987
+ access: "view"
53988
+ },
53989
+ "pipelineAnalytics.listRetrainCollections": {
53990
+ capName: "pipeline-analytics",
53991
+ capScope: "device",
53992
+ addonId: null,
53993
+ access: "view"
53994
+ },
52059
53995
  "pipelineAnalytics.listRetrainFrames": {
52060
53996
  capName: "pipeline-analytics",
52061
53997
  capScope: "device",
@@ -52104,6 +54040,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
52104
54040
  addonId: null,
52105
54041
  access: "create"
52106
54042
  },
54043
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
54044
+ capName: "pipeline-analytics",
54045
+ capScope: "device",
54046
+ addonId: null,
54047
+ access: "create"
54048
+ },
52107
54049
  "pipelineAnalytics.pruneEvents": {
52108
54050
  capName: "pipeline-analytics",
52109
54051
  capScope: "device",
@@ -52158,6 +54100,18 @@ var METHOD_ACCESS_MAP = Object.freeze({
52158
54100
  addonId: null,
52159
54101
  access: "create"
52160
54102
  },
54103
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
54104
+ capName: "pipeline-analytics",
54105
+ capScope: "device",
54106
+ addonId: null,
54107
+ access: "delete"
54108
+ },
54109
+ "pipelineAnalytics.renameRetrainCollection": {
54110
+ capName: "pipeline-analytics",
54111
+ capScope: "device",
54112
+ addonId: null,
54113
+ access: "create"
54114
+ },
52161
54115
  "pipelineAnalytics.restageRetrainTrack": {
52162
54116
  capName: "pipeline-analytics",
52163
54117
  capScope: "device",
@@ -52446,6 +54400,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
52446
54400
  addonId: null,
52447
54401
  access: "view"
52448
54402
  },
54403
+ "pipelineOrchestrator.abortNodeBenchmark": {
54404
+ capName: "pipeline-orchestrator",
54405
+ capScope: "system",
54406
+ addonId: null,
54407
+ access: "create"
54408
+ },
52449
54409
  "pipelineOrchestrator.applyAutoTune": {
52450
54410
  capName: "pipeline-orchestrator",
52451
54411
  capScope: "system",
@@ -52470,6 +54430,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
52470
54430
  addonId: null,
52471
54431
  access: "create"
52472
54432
  },
54433
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
54434
+ capName: "pipeline-orchestrator",
54435
+ capScope: "system",
54436
+ addonId: null,
54437
+ access: "delete"
54438
+ },
52473
54439
  "pipelineOrchestrator.getAgentLoad": {
52474
54440
  capName: "pipeline-orchestrator",
52475
54441
  capScope: "system",
@@ -52578,6 +54544,24 @@ var METHOD_ACCESS_MAP = Object.freeze({
52578
54544
  addonId: null,
52579
54545
  access: "view"
52580
54546
  },
54547
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
54548
+ capName: "pipeline-orchestrator",
54549
+ capScope: "system",
54550
+ addonId: null,
54551
+ access: "view"
54552
+ },
54553
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
54554
+ capName: "pipeline-orchestrator",
54555
+ capScope: "system",
54556
+ addonId: null,
54557
+ access: "view"
54558
+ },
54559
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
54560
+ capName: "pipeline-orchestrator",
54561
+ capScope: "system",
54562
+ addonId: null,
54563
+ access: "view"
54564
+ },
52581
54565
  "pipelineOrchestrator.getNodeInferenceDevices": {
52582
54566
  capName: "pipeline-orchestrator",
52583
54567
  capScope: "system",
@@ -52620,6 +54604,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
52620
54604
  addonId: null,
52621
54605
  access: "view"
52622
54606
  },
54607
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
54608
+ capName: "pipeline-orchestrator",
54609
+ capScope: "system",
54610
+ addonId: null,
54611
+ access: "view"
54612
+ },
52623
54613
  "pipelineOrchestrator.pauseForStorageMigration": {
52624
54614
  capName: "pipeline-orchestrator",
52625
54615
  capScope: "system",
@@ -52764,6 +54754,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
52764
54754
  addonId: null,
52765
54755
  access: "create"
52766
54756
  },
54757
+ "pipelineOrchestrator.startNodeBenchmark": {
54758
+ capName: "pipeline-orchestrator",
54759
+ capScope: "system",
54760
+ addonId: null,
54761
+ access: "create"
54762
+ },
52767
54763
  "pipelineOrchestrator.suggestShares": {
52768
54764
  capName: "pipeline-orchestrator",
52769
54765
  capScope: "system",
@@ -52782,6 +54778,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
52782
54778
  addonId: null,
52783
54779
  access: "create"
52784
54780
  },
54781
+ "pipelineRunner.abortNodeBench": {
54782
+ capName: "pipeline-runner",
54783
+ capScope: "system",
54784
+ addonId: null,
54785
+ access: "create"
54786
+ },
52785
54787
  "pipelineRunner.attachCamera": {
52786
54788
  capName: "pipeline-runner",
52787
54789
  capScope: "system",
@@ -52830,6 +54832,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
52830
54832
  addonId: null,
52831
54833
  access: "view"
52832
54834
  },
54835
+ "pipelineRunner.getNodeBenchStatus": {
54836
+ capName: "pipeline-runner",
54837
+ capScope: "system",
54838
+ addonId: null,
54839
+ access: "view"
54840
+ },
52833
54841
  "pipelineRunner.getParkedTrackFrame": {
52834
54842
  capName: "pipeline-runner",
52835
54843
  capScope: "system",
@@ -52872,6 +54880,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
52872
54880
  addonId: null,
52873
54881
  access: "create"
52874
54882
  },
54883
+ "pipelineRunner.startNodeBench": {
54884
+ capName: "pipeline-runner",
54885
+ capScope: "system",
54886
+ addonId: null,
54887
+ access: "create"
54888
+ },
52875
54889
  "plateGallery.assignPlate": {
52876
54890
  capName: "plate-gallery",
52877
54891
  capScope: "system",
@@ -56630,6 +58644,8 @@ var ALL_CAPABILITY_DEFINITIONS = [
56630
58644
  imageSettingsCapability,
56631
58645
  integrationsCapability,
56632
58646
  intercomCapability,
58647
+ keychainCapability,
58648
+ keychainAdminCapability,
56633
58649
  lawnMowerControlCapability,
56634
58650
  llmCapability,
56635
58651
  llmRuntimeCapability,
@@ -58056,6 +60072,11 @@ Object.freeze({
58056
60072
  form: "single",
58057
60073
  optional: false
58058
60074
  }],
60075
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
60076
+ name: "deviceId",
60077
+ form: "single",
60078
+ optional: false
60079
+ }],
58059
60080
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
58060
60081
  name: "deviceId",
58061
60082
  form: "single",
@@ -58246,6 +60267,11 @@ Object.freeze({
58246
60267
  form: "single",
58247
60268
  optional: false
58248
60269
  }],
60270
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
60271
+ name: "deviceId",
60272
+ form: "single",
60273
+ optional: false
60274
+ }],
58249
60275
  "pipelineAnalytics.pruneEventsBefore": [{
58250
60276
  name: "deviceId",
58251
60277
  form: "single",
@@ -60684,6 +62710,70 @@ function bareAddonId(id) {
60684
62710
  function hfModelUrl(repo, path) {
60685
62711
  return `https://huggingface.co/${repo}/resolve/main/${path}`;
60686
62712
  }
62713
+ /**
62714
+ * Names that, when used as URL query parameters, almost certainly carry
62715
+ * a secret. Matching is case-insensitive and anchored to the full param
62716
+ * name to avoid false positives like `user_id` (an entity reference, not
62717
+ * a credential) or `topic=password-reset` (a value happens to contain
62718
+ * the substring "password" but the param name is unrelated).
62719
+ *
62720
+ * Add new patterns here as we encounter cameras/APIs that leak through
62721
+ * the existing list.
62722
+ */
62723
+ var CREDENTIAL_PARAM_PATTERNS = [
62724
+ /^user$/i,
62725
+ /^usr$/i,
62726
+ /^username$/i,
62727
+ /^password$/i,
62728
+ /^pwd$/i,
62729
+ /^pass$/i,
62730
+ /^passwd$/i,
62731
+ /^secret$/i,
62732
+ /^token$/i,
62733
+ /^auth$/i,
62734
+ /^auth[_-]?token$/i,
62735
+ /^bearer$/i,
62736
+ /^api[_-]?key$/i,
62737
+ /^access[_-]?token$/i,
62738
+ /^refresh[_-]?token$/i
62739
+ ];
62740
+ function isCredentialParam(name) {
62741
+ return CREDENTIAL_PARAM_PATTERNS.some((re) => re.test(name));
62742
+ }
62743
+ /**
62744
+ * Redact secrets we may surface in logs or telemetry:
62745
+ * 1. `userinfo` (`user:password@host`) — the classic RTSP shape.
62746
+ * 2. Query-string credential params (`?user=...&password=...`) — the
62747
+ * Reolink RTMP shape and several HTTP-pushed-stream APIs.
62748
+ *
62749
+ * Returns the original string verbatim when the input is not a parseable
62750
+ * URL — a log helper must never throw. Param values are replaced with
62751
+ * `***` so an operator reading logs still sees WHICH credential was
62752
+ * present (useful for debugging "wrong password" issues) without
62753
+ * exposing the value.
62754
+ *
62755
+ * The credential-name match is case-insensitive but anchored to the
62756
+ * whole param name; values like `user_id=42` or `topic=password-reset`
62757
+ * are NOT masked (those are entity references, not credentials).
62758
+ */
62759
+ function maskUrlCredentials(rawUrl) {
62760
+ try {
62761
+ const u = new URL(rawUrl);
62762
+ let touched = false;
62763
+ if (u.username || u.password) {
62764
+ u.username = "";
62765
+ u.password = "";
62766
+ touched = true;
62767
+ }
62768
+ for (const key of Array.from(u.searchParams.keys())) if (isCredentialParam(key)) {
62769
+ u.searchParams.set(key, "***");
62770
+ touched = true;
62771
+ }
62772
+ return touched ? u.toString() : rawUrl;
62773
+ } catch {
62774
+ return rawUrl;
62775
+ }
62776
+ }
60687
62777
  var MB = 1024 * 1024;
60688
62778
  1024 * MB, 3072 * MB;
60689
62779
  /**
@@ -61538,6 +63628,12 @@ Object.defineProperty(exports, "formatMinutes", {
61538
63628
  return formatMinutes;
61539
63629
  }
61540
63630
  });
63631
+ Object.defineProperty(exports, "formatSecretScope", {
63632
+ enumerable: true,
63633
+ get: function() {
63634
+ return formatSecretScope;
63635
+ }
63636
+ });
61541
63637
  Object.defineProperty(exports, "gbToBytes", {
61542
63638
  enumerable: true,
61543
63639
  get: function() {
@@ -61604,6 +63700,12 @@ Object.defineProperty(exports, "isObjectInput", {
61604
63700
  return isObjectInput;
61605
63701
  }
61606
63702
  });
63703
+ Object.defineProperty(exports, "isSecretMarker", {
63704
+ enumerable: true,
63705
+ get: function() {
63706
+ return isSecretMarker;
63707
+ }
63708
+ });
61607
63709
  Object.defineProperty(exports, "isVoidInput", {
61608
63710
  enumerable: true,
61609
63711
  get: function() {
@@ -61616,6 +63718,18 @@ Object.defineProperty(exports, "kebabToCamel", {
61616
63718
  return kebabToCamel;
61617
63719
  }
61618
63720
  });
63721
+ Object.defineProperty(exports, "keychainAdminCapability", {
63722
+ enumerable: true,
63723
+ get: function() {
63724
+ return keychainAdminCapability;
63725
+ }
63726
+ });
63727
+ Object.defineProperty(exports, "keychainCapability", {
63728
+ enumerable: true,
63729
+ get: function() {
63730
+ return keychainCapability;
63731
+ }
63732
+ });
61619
63733
  Object.defineProperty(exports, "legacyAutoLinkIds", {
61620
63734
  enumerable: true,
61621
63735
  get: function() {
@@ -61664,6 +63778,12 @@ Object.defineProperty(exports, "looseSchema", {
61664
63778
  return looseSchema;
61665
63779
  }
61666
63780
  });
63781
+ Object.defineProperty(exports, "maskUrlCredentials", {
63782
+ enumerable: true,
63783
+ get: function() {
63784
+ return maskUrlCredentials;
63785
+ }
63786
+ });
61667
63787
  Object.defineProperty(exports, "mayReadLocation", {
61668
63788
  enumerable: true,
61669
63789
  get: function() {
@@ -61712,6 +63832,12 @@ Object.defineProperty(exports, "normalizeCoreBlockWrite", {
61712
63832
  return normalizeCoreBlockWrite;
61713
63833
  }
61714
63834
  });
63835
+ Object.defineProperty(exports, "normalizeSecretOwner", {
63836
+ enumerable: true,
63837
+ get: function() {
63838
+ return normalizeSecretOwner;
63839
+ }
63840
+ });
61715
63841
  Object.defineProperty(exports, "normalizeUnit", {
61716
63842
  enumerable: true,
61717
63843
  get: function() {
@@ -61742,6 +63868,12 @@ Object.defineProperty(exports, "parseJsonUnknown", {
61742
63868
  return parseJsonUnknown;
61743
63869
  }
61744
63870
  });
63871
+ Object.defineProperty(exports, "parseSecretRef", {
63872
+ enumerable: true,
63873
+ get: function() {
63874
+ return parseSecretRef;
63875
+ }
63876
+ });
61745
63877
  Object.defineProperty(exports, "parseStreamParamsFormPatch", {
61746
63878
  enumerable: true,
61747
63879
  get: function() {
@@ -61850,6 +63982,12 @@ Object.defineProperty(exports, "resolveNotificationTapAddress", {
61850
63982
  return resolveNotificationTapAddress;
61851
63983
  }
61852
63984
  });
63985
+ Object.defineProperty(exports, "resolveSecretMarkers", {
63986
+ enumerable: true,
63987
+ get: function() {
63988
+ return resolveSecretMarkers;
63989
+ }
63990
+ });
61853
63991
  Object.defineProperty(exports, "runtimeStatePolicyFor", {
61854
63992
  enumerable: true,
61855
63993
  get: function() {
@@ -61880,6 +64018,18 @@ Object.defineProperty(exports, "scoreRuntimes", {
61880
64018
  return scoreRuntimes;
61881
64019
  }
61882
64020
  });
64021
+ Object.defineProperty(exports, "scrubKnownSecrets", {
64022
+ enumerable: true,
64023
+ get: function() {
64024
+ return scrubKnownSecrets;
64025
+ }
64026
+ });
64027
+ Object.defineProperty(exports, "secretTreeFromPaths", {
64028
+ enumerable: true,
64029
+ get: function() {
64030
+ return secretTreeFromPaths;
64031
+ }
64032
+ });
61883
64033
  Object.defineProperty(exports, "settingsStoreCapability", {
61884
64034
  enumerable: true,
61885
64035
  get: function() {
@@ -61952,6 +64102,12 @@ Object.defineProperty(exports, "toNodeId", {
61952
64102
  return toNodeId;
61953
64103
  }
61954
64104
  });
64105
+ Object.defineProperty(exports, "transformSecretWrite", {
64106
+ enumerable: true,
64107
+ get: function() {
64108
+ return transformSecretWrite;
64109
+ }
64110
+ });
61955
64111
  Object.defineProperty(exports, "userManagementCapability", {
61956
64112
  enumerable: true,
61957
64113
  get: function() {