@camstack/server 1.2.718 → 1.2.720

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 (970) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/addon-root-inventory.js +1 -1
  3. package/dist/agent/addon-scan.js +11 -7
  4. package/dist/agent/agent-addon-updates.js +1 -1
  5. package/dist/agent/agent-cap-dispatch-service.js +1 -1
  6. package/dist/agent/agent-heap-watch.js +1 -1
  7. package/dist/agent/agent-http.js +1 -1
  8. package/dist/agent/agent-hub-addon-update.js +1 -1
  9. package/dist/agent/agent-hub-registration.js +1 -1
  10. package/dist/agent/agent-infra-capabilities.js +2 -2
  11. package/dist/agent/agent-mesh-gate.js +1 -1
  12. package/dist/agent/agent-node-certificates.js +1 -1
  13. package/dist/agent/agent-pairing-routes.js +1 -1
  14. package/dist/agent/agent-pairing-store.js +1 -1
  15. package/dist/agent/agent-service.js +6 -2
  16. package/dist/agent/agent-update-service.js +3 -1
  17. package/dist/agent/hub-membership-client.js +1 -1
  18. package/dist/agent/infra-boot-guard.js +2 -2
  19. package/dist/agent/main.js +9 -9
  20. package/dist/api/addon-upload.js +1 -1
  21. package/dist/api/core/addon-settings.router.js +1 -1
  22. package/dist/api/core/agent-pairing.router.js +1 -1
  23. package/dist/api/core/auth-device-cert.procedures.js +1 -1
  24. package/dist/api/core/cap-providers.js +6 -6
  25. package/dist/api/core/certificates.router.js +1 -1
  26. package/dist/api/core/lifecycle-job-runner.js +1 -1
  27. package/dist/api/core/logging-settings.js +1 -1
  28. package/dist/api/core/logs.router.js +2 -2
  29. package/dist/api/core/notifications.router.js +1 -1
  30. package/dist/api/core/preferences.router.js +1 -1
  31. package/dist/api/core/repl.router.js +1 -1
  32. package/dist/api/cors/cors-policy.js +1 -1
  33. package/dist/api/mesh-membership-routes.js +1 -1
  34. package/dist/api/model-distributor.js +1 -1
  35. package/dist/api/trpc/cap-route-error-formatter.js +1 -1
  36. package/dist/api/trpc/cap-router-runtime.js +2 -2
  37. package/dist/api/trpc/core-cap-bridge.js +1 -1
  38. package/dist/api/trpc/device-collection-dispatch.js +1 -1
  39. package/dist/api/trpc/generated-cap-routers.js +1 -1
  40. package/dist/api/trpc/principal-authorization.js +1 -1
  41. package/dist/api/trpc/principal-visibility.js +1 -1
  42. package/dist/api/trpc/scope-access.js +1 -1
  43. package/dist/api/trpc/trpc.context.js +1 -1
  44. package/dist/api/trpc/trpc.middleware.js +1 -1
  45. package/dist/api/trpc/trpc.router.js +3 -3
  46. package/dist/auth/auth-network-policy.js +1 -1
  47. package/dist/auth/client-address.js +1 -1
  48. package/dist/auth/hub-sessions.js +1 -1
  49. package/dist/auth/session-lifetimes.js +1 -1
  50. package/dist/auth/sso-finish-deps.js +1 -1
  51. package/dist/boot/boot-config.js +53 -133
  52. package/dist/boot/platform-keychain-key.js +1 -1
  53. package/dist/boot/post-boot.service.js +1 -1
  54. package/dist/bootstrap-packages.js +3 -3
  55. package/dist/core/addon/addon-call-gateway.js +1 -1
  56. package/dist/core/addon/addon-package.service.js +140 -21
  57. package/dist/core/addon/addon-registry.service.js +36 -32
  58. package/dist/core/addon/addon-requirements.js +81 -0
  59. package/dist/core/addon/hub-addon-api.js +1 -1
  60. package/dist/core/addon/installed-addon-versions.js +82 -0
  61. package/dist/core/addon/package-dir-utils.js +11 -1
  62. package/dist/core/addon/settings-door-wiring.js +1 -1
  63. package/dist/core/addon-bridge/addon-bridge.service.js +3 -3
  64. package/dist/core/addon-pages/addon-pages.service.js +1 -1
  65. package/dist/core/agent/agent-desired-set.js +1 -1
  66. package/dist/core/agent/agent-pairing-http.js +1 -1
  67. package/dist/core/agent/agent-registry.service.js +41 -7
  68. package/dist/core/agent/cluster-node-history-store.js +1 -1
  69. package/dist/core/agent/delivery-requirements.js +36 -0
  70. package/dist/core/agent/forgotten-node-revoker.js +1 -1
  71. package/dist/core/agent/node-removal-hooks.js +6 -2
  72. package/dist/core/auth/auth.service.js +1 -1
  73. package/dist/core/config/config.schema.js +2 -2
  74. package/dist/core/config/config.service.js +1 -1
  75. package/dist/core/events/event-bus.service.js +1 -1
  76. package/dist/core/feature/feature.service.js +1 -1
  77. package/dist/core/lifecycle/lifecycle-state-machine.js +2 -2
  78. package/dist/core/logging/log-history.js +1 -1
  79. package/dist/core/logging/log-ring-buffer.js +2 -2
  80. package/dist/core/logging/logging.service.js +2 -2
  81. package/dist/core/logging/scoped-logger.js +2 -2
  82. package/dist/core/moleculer/cap-route-authority.js +2 -2
  83. package/dist/core/moleculer/hub-mesh-guard.js +1 -1
  84. package/dist/core/moleculer/moleculer.service.js +1 -1
  85. package/dist/core/network/network-quality.service.js +1 -1
  86. package/dist/core/notification/notification-wrapper.service.js +1 -1
  87. package/dist/core/notification/toast-wrapper.service.js +1 -1
  88. package/dist/core/repl/repl-engine.service.js +1 -1
  89. package/dist/core/server-update/server-update.service.js +3 -0
  90. package/dist/core/server-update/system-ensure-prebuilds.js +3 -3
  91. package/dist/core/server-update/system-exec-npm.js +2 -2
  92. package/dist/core/storage/fs-storage-backend.js +2 -2
  93. package/dist/core/storage/storage-location-manager.js +2 -2
  94. package/dist/core/storage/storage.service.js +1 -1
  95. package/dist/framework-nodepath.js +14 -1
  96. package/dist/launcher.js +23 -23
  97. package/dist/legacy-package-names.js +15 -0
  98. package/dist/main.js +2 -2
  99. package/dist/manual-boot.js +4 -3
  100. package/dist/package-inventory.js +6 -3
  101. package/dist/server-root/index.js +182 -30
  102. package/dist/single-copy-cleanup-runner.js +3 -3
  103. package/dist/single-copy-cleanup.js +19 -14
  104. package/package.json +53 -19
  105. package/scripts/closure-postinstall.mjs +1 -1
  106. package/system/assets/addon-pages-aggregator/icon.svg +5 -0
  107. package/system/assets/addon-widgets-aggregator/icon.svg +6 -0
  108. package/system/assets/alert-center/icon.svg +5 -0
  109. package/system/assets/autotrack/icon.svg +5 -0
  110. package/system/assets/backup-orchestrator/icon.svg +5 -0
  111. package/system/assets/calendars/icon.svg +5 -0
  112. package/system/assets/camera-grid/icon.svg +10 -0
  113. package/system/assets/composer/icon.svg +7 -0
  114. package/system/assets/console-logging/icon.svg +4 -0
  115. package/system/assets/core-blocks/icon.svg +6 -0
  116. package/system/assets/device-history/icon.svg +4 -0
  117. package/system/assets/device-manager/icon.svg +6 -0
  118. package/system/assets/filesystem-storage/icon.svg +6 -0
  119. package/system/assets/hub-forwarder/icon.svg +7 -0
  120. package/system/assets/keychain/icon.svg +6 -0
  121. package/system/assets/liveness-monitor/icon.svg +4 -0
  122. package/system/assets/local-auth/icon.svg +5 -0
  123. package/system/assets/local-network/icon.svg +7 -0
  124. package/system/assets/loki-logging/icon.svg +7 -0
  125. package/system/assets/metrics-native/icon.svg +3 -0
  126. package/system/assets/platform-probe/icon.svg +5 -0
  127. package/system/assets/record-entries/icon.svg +8 -0
  128. package/system/assets/remote-access-orchestrator/icon.svg +5 -0
  129. package/system/assets/snapshot/icon.svg +4 -0
  130. package/system/assets/sqlite-settings/icon.svg +5 -0
  131. package/system/assets/storage-orchestrator/icon.svg +8 -0
  132. package/system/assets/system-config/icon.svg +4 -0
  133. package/system/assets/winston-logging/icon.svg +6 -0
  134. package/system/dist/addon/addon-api-factory.d.ts +35 -0
  135. package/system/dist/addon-routes/addon-route-registry.d.ts +37 -0
  136. package/system/dist/addon-runner.js +11894 -0
  137. package/system/dist/addon-runner.mjs +11840 -0
  138. package/system/dist/addon-utils.d.ts +23 -0
  139. package/system/dist/addon-utils.js +27 -0
  140. package/system/dist/addon-utils.mjs +3 -0
  141. package/system/dist/agent-https-BMbnmX5u.mjs +1042 -0
  142. package/system/dist/agent-https-DslXCDRW.js +1289 -0
  143. package/system/dist/amd-accelerators-CEuPFBBK.js +36 -0
  144. package/system/dist/amd-accelerators-U_RsoEDd.mjs +35 -0
  145. package/system/dist/auth/auth-audit-log.d.ts +45 -0
  146. package/system/dist/auth/auth-manager.d.ts +155 -0
  147. package/system/dist/auth/cidr.d.ts +22 -0
  148. package/system/dist/auth/device-ca-store.d.ts +57 -0
  149. package/system/dist/auth/device-ca.d.ts +65 -0
  150. package/system/dist/auth/device-credential-manager.d.ts +158 -0
  151. package/system/dist/auth/external-identity-manager.d.ts +42 -0
  152. package/system/dist/auth/jwt-signing-key.d.ts +42 -0
  153. package/system/dist/auth/legacy-token-tables.d.ts +16 -0
  154. package/system/dist/auth/login-session-manager.d.ts +140 -0
  155. package/system/dist/auth/origin.d.ts +34 -0
  156. package/system/dist/auth/parse-record.d.ts +18 -0
  157. package/system/dist/auth/scope-matcher.d.ts +8 -0
  158. package/system/dist/auth/session-revocation-bus.d.ts +32 -0
  159. package/system/dist/auth/token-expiry.d.ts +62 -0
  160. package/system/dist/auth/totp-manager.d.ts +107 -0
  161. package/system/dist/auth/user-management-internal.d.ts +90 -0
  162. package/system/dist/auth/user-manager.d.ts +69 -0
  163. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.d.ts +57 -0
  164. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +271 -0
  165. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +263 -0
  166. package/system/dist/builtins/addon-pages-aggregator/dedupe-pages.d.ts +24 -0
  167. package/system/dist/builtins/addon-pages-aggregator/index.d.ts +1 -0
  168. package/system/dist/builtins/addon-pages-aggregator/index.js +8 -0
  169. package/system/dist/builtins/addon-pages-aggregator/index.mjs +2 -0
  170. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.d.ts +57 -0
  171. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +257 -0
  172. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +249 -0
  173. package/system/dist/builtins/addon-widgets-aggregator/index.d.ts +1 -0
  174. package/system/dist/builtins/addon-widgets-aggregator/index.js +8 -0
  175. package/system/dist/builtins/addon-widgets-aggregator/index.mjs +2 -0
  176. package/system/dist/builtins/alerts/alert-episode-policy.d.ts +39 -0
  177. package/system/dist/builtins/alerts/alert-store.d.ts +32 -0
  178. package/system/dist/builtins/alerts/alerts.addon.d.ts +148 -0
  179. package/system/dist/builtins/alerts/alerts.addon.js +1566 -0
  180. package/system/dist/builtins/alerts/alerts.addon.mjs +1559 -0
  181. package/system/dist/builtins/alerts/device-label.d.ts +8 -0
  182. package/system/dist/builtins/alerts/emit-alert-policy.d.ts +15 -0
  183. package/system/dist/builtins/alerts/index.d.ts +1 -0
  184. package/system/dist/builtins/alerts/index.js +4 -0
  185. package/system/dist/builtins/alerts/index.mjs +2 -0
  186. package/system/dist/builtins/alerts/migration-alerts.d.ts +13 -0
  187. package/system/dist/builtins/alerts/prune-policy.d.ts +44 -0
  188. package/system/dist/builtins/alerts/record-kinds.d.ts +15 -0
  189. package/system/dist/builtins/alerts/runner-alert.d.ts +58 -0
  190. package/system/dist/builtins/autotrack/autotrack-cameras.d.ts +125 -0
  191. package/system/dist/builtins/autotrack/autotrack-config.d.ts +89 -0
  192. package/system/dist/builtins/autotrack/autotrack-decision.d.ts +86 -0
  193. package/system/dist/builtins/autotrack/autotrack-loop.d.ts +95 -0
  194. package/system/dist/builtins/autotrack/autotrack.addon.d.ts +108 -0
  195. package/system/dist/builtins/autotrack/frame-error.d.ts +50 -0
  196. package/system/dist/builtins/autotrack/frame-measurements.d.ts +97 -0
  197. package/system/dist/builtins/autotrack/index.d.ts +2 -0
  198. package/system/dist/builtins/autotrack/index.js +1018 -0
  199. package/system/dist/builtins/autotrack/index.mjs +1012 -0
  200. package/system/dist/builtins/autotrack/ptz-mirror.d.ts +54 -0
  201. package/system/dist/builtins/autotrack/target-selection.d.ts +46 -0
  202. package/system/dist/builtins/backup-orchestrator/backup-databases.d.ts +51 -0
  203. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +291 -0
  204. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +3213 -0
  205. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +3204 -0
  206. package/system/dist/builtins/backup-orchestrator/cron-helpers.d.ts +23 -0
  207. package/system/dist/builtins/backup-orchestrator/destination-policy.d.ts +91 -0
  208. package/system/dist/builtins/backup-orchestrator/download-helpers.d.ts +12 -0
  209. package/system/dist/builtins/backup-orchestrator/encryption-key-store.d.ts +49 -0
  210. package/system/dist/builtins/backup-orchestrator/index.d.ts +2 -0
  211. package/system/dist/builtins/backup-orchestrator/index.js +8 -0
  212. package/system/dist/builtins/backup-orchestrator/index.mjs +2 -0
  213. package/system/dist/builtins/backup-orchestrator/manifest-store.d.ts +134 -0
  214. package/system/dist/builtins/backup-orchestrator/record-kinds.d.ts +56 -0
  215. package/system/dist/builtins/backup-orchestrator/restore-archive.d.ts +24 -0
  216. package/system/dist/builtins/backup-orchestrator/run-queue.d.ts +106 -0
  217. package/system/dist/builtins/backup-orchestrator/schedule-store.d.ts +59 -0
  218. package/system/dist/builtins/backup-orchestrator/seed-marker-store.d.ts +26 -0
  219. package/system/dist/builtins/backup-orchestrator/staging-paths.d.ts +36 -0
  220. package/system/dist/builtins/backup-orchestrator/write-targets.d.ts +63 -0
  221. package/system/dist/builtins/calendars/calendar-color.d.ts +9 -0
  222. package/system/dist/builtins/calendars/calendar-prefs-store.d.ts +34 -0
  223. package/system/dist/builtins/calendars/calendars.addon.d.ts +19 -0
  224. package/system/dist/builtins/calendars/calendars.addon.js +227 -0
  225. package/system/dist/builtins/calendars/calendars.addon.mjs +220 -0
  226. package/system/dist/builtins/calendars/index.d.ts +1 -0
  227. package/system/dist/builtins/calendars/index.js +8 -0
  228. package/system/dist/builtins/calendars/index.mjs +2 -0
  229. package/system/dist/builtins/calendars/record-kinds.d.ts +18 -0
  230. package/system/dist/builtins/camera-grid/acquire-retry.d.ts +30 -0
  231. package/system/dist/builtins/camera-grid/addon.d.ts +205 -0
  232. package/system/dist/builtins/camera-grid/flv-join.d.ts +40 -0
  233. package/system/dist/builtins/camera-grid/grid-activity-mirror.d.ts +42 -0
  234. package/system/dist/builtins/camera-grid/grid-activity.d.ts +91 -0
  235. package/system/dist/builtins/camera-grid/grid-camera-declarations.d.ts +59 -0
  236. package/system/dist/builtins/camera-grid/grid-camera-device.d.ts +68 -0
  237. package/system/dist/builtins/camera-grid/grid-canvas-derivation.d.ts +54 -0
  238. package/system/dist/builtins/camera-grid/grid-canvas-seed.d.ts +112 -0
  239. package/system/dist/builtins/camera-grid/grid-canvas.d.ts +85 -0
  240. package/system/dist/builtins/camera-grid/grid-child.d.ts +32 -0
  241. package/system/dist/builtins/camera-grid/grid-compositor-child.d.ts +3 -0
  242. package/system/dist/builtins/camera-grid/grid-compositor-invocation.d.ts +47 -0
  243. package/system/dist/builtins/camera-grid/grid-compositor.d.ts +54 -0
  244. package/system/dist/builtins/camera-grid/grid-detection-mapping.d.ts +61 -0
  245. package/system/dist/builtins/camera-grid/grid-device-settings.d.ts +35 -0
  246. package/system/dist/builtins/camera-grid/grid-filter-graph.d.ts +53 -0
  247. package/system/dist/builtins/camera-grid/grid-frame-sample.d.ts +53 -0
  248. package/system/dist/builtins/camera-grid/grid-instances.d.ts +22 -0
  249. package/system/dist/builtins/camera-grid/grid-last-frame-store.d.ts +58 -0
  250. package/system/dist/builtins/camera-grid/grid-layout-native-provider.d.ts +34 -0
  251. package/system/dist/builtins/camera-grid/grid-plan.d.ts +34 -0
  252. package/system/dist/builtins/camera-grid/grid-profiles.d.ts +104 -0
  253. package/system/dist/builtins/camera-grid/grid-row-normalization.d.ts +10 -0
  254. package/system/dist/builtins/camera-grid/grid-sentry-sources.d.ts +64 -0
  255. package/system/dist/builtins/camera-grid/grid-snapshot.d.ts +62 -0
  256. package/system/dist/builtins/camera-grid/grid-stream-descriptor.d.ts +53 -0
  257. package/system/dist/builtins/camera-grid/grid-stream-invocation.d.ts +44 -0
  258. package/system/dist/builtins/camera-grid/grid-stream-relay.d.ts +35 -0
  259. package/system/dist/builtins/camera-grid/grid-stream-session.d.ts +143 -0
  260. package/system/dist/builtins/camera-grid/grid-tile-feed.d.ts +50 -0
  261. package/system/dist/builtins/camera-grid/grid-tile-plan.d.ts +66 -0
  262. package/system/dist/builtins/camera-grid/grid-wire-format.d.ts +30 -0
  263. package/system/dist/builtins/camera-grid/index.d.ts +45 -0
  264. package/system/dist/builtins/camera-grid/index.js +3994 -0
  265. package/system/dist/builtins/camera-grid/index.mjs +3961 -0
  266. package/system/dist/builtins/camera-grid/silence-analysis.d.ts +37 -0
  267. package/system/dist/builtins/cluster-agent/record-kinds.d.ts +49 -0
  268. package/system/dist/builtins/composer/actuator-dispatch.d.ts +13 -0
  269. package/system/dist/builtins/composer/actuator-groups.d.ts +68 -0
  270. package/system/dist/builtins/composer/actuator-invoke.d.ts +32 -0
  271. package/system/dist/builtins/composer/claim-gate.d.ts +59 -0
  272. package/system/dist/builtins/composer/composed-device-set.d.ts +52 -0
  273. package/system/dist/builtins/composer/composed-device.d.ts +57 -0
  274. package/system/dist/builtins/composer/composer-apply-waits.d.ts +28 -0
  275. package/system/dist/builtins/composer/composer-grafts.d.ts +73 -0
  276. package/system/dist/builtins/composer/composer-live-set.d.ts +30 -0
  277. package/system/dist/builtins/composer/composer-plan.d.ts +112 -0
  278. package/system/dist/builtins/composer/composer-runtime-factory.d.ts +30 -0
  279. package/system/dist/builtins/composer/composer-seeds.d.ts +28 -0
  280. package/system/dist/builtins/composer/composer-verdict.d.ts +33 -0
  281. package/system/dist/builtins/composer/composer.addon.d.ts +26 -0
  282. package/system/dist/builtins/composer/composer.addon.js +6229 -0
  283. package/system/dist/builtins/composer/composer.addon.mjs +6223 -0
  284. package/system/dist/builtins/composer/composer.d.ts +208 -0
  285. package/system/dist/builtins/composer/composition-declarations.d.ts +64 -0
  286. package/system/dist/builtins/composer/composition-evaluation.d.ts +53 -0
  287. package/system/dist/builtins/composer/composition-runtime.d.ts +203 -0
  288. package/system/dist/builtins/composer/composition-target.d.ts +60 -0
  289. package/system/dist/builtins/composer/confirmed-seed.d.ts +44 -0
  290. package/system/dist/builtins/composer/deadline-timer.d.ts +18 -0
  291. package/system/dist/builtins/composer/existing-target.d.ts +131 -0
  292. package/system/dist/builtins/composer/field-record.d.ts +64 -0
  293. package/system/dist/builtins/composer/forward-commands.d.ts +61 -0
  294. package/system/dist/builtins/composer/graft-host.d.ts +71 -0
  295. package/system/dist/builtins/composer/held-claims.d.ts +29 -0
  296. package/system/dist/builtins/composer/history-helpers.d.ts +67 -0
  297. package/system/dist/builtins/composer/index.d.ts +1 -0
  298. package/system/dist/builtins/composer/index.js +8 -0
  299. package/system/dist/builtins/composer/index.mjs +2 -0
  300. package/system/dist/builtins/composer/math-quantity.d.ts +20 -0
  301. package/system/dist/builtins/composer/own-field-reads.d.ts +30 -0
  302. package/system/dist/builtins/composer/owned-fields-target.d.ts +95 -0
  303. package/system/dist/builtins/composer/pulse-seed-resolve.d.ts +59 -0
  304. package/system/dist/builtins/composer/pulse-seed.d.ts +75 -0
  305. package/system/dist/builtins/composer/slice-assembler.d.ts +26 -0
  306. package/system/dist/builtins/composer/source-readings.d.ts +128 -0
  307. package/system/dist/builtins/composer/source-tracker.d.ts +135 -0
  308. package/system/dist/builtins/console-logging/console-destination.d.ts +19 -0
  309. package/system/dist/builtins/console-logging/console-logging.addon.d.ts +26 -0
  310. package/system/dist/builtins/console-logging/index.d.ts +3 -0
  311. package/system/dist/builtins/console-logging/index.js +108 -0
  312. package/system/dist/builtins/console-logging/index.mjs +99 -0
  313. package/system/dist/builtins/core-blocks/actions-service.d.ts +113 -0
  314. package/system/dist/builtins/core-blocks/actions-store.d.ts +32 -0
  315. package/system/dist/builtins/core-blocks/actions-wiring.d.ts +32 -0
  316. package/system/dist/builtins/core-blocks/block-package.d.ts +54 -0
  317. package/system/dist/builtins/core-blocks/block-settings-store.d.ts +93 -0
  318. package/system/dist/builtins/core-blocks/block-supervisor.d.ts +176 -0
  319. package/system/dist/builtins/core-blocks/block-type-defs.d.ts +29 -0
  320. package/system/dist/builtins/core-blocks/blocks-integration.d.ts +89 -0
  321. package/system/dist/builtins/core-blocks/compile-block.d.ts +52 -0
  322. package/system/dist/builtins/core-blocks/composition-api.d.ts +50 -0
  323. package/system/dist/builtins/core-blocks/composition-peers.d.ts +31 -0
  324. package/system/dist/builtins/core-blocks/composition-sources.d.ts +40 -0
  325. package/system/dist/builtins/core-blocks/core-block-store.d.ts +120 -0
  326. package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +108 -0
  327. package/system/dist/builtins/core-blocks/core-blocks.addon.js +6374 -0
  328. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +6355 -0
  329. package/system/dist/builtins/core-blocks/extract-settings-schema.d.ts +6 -0
  330. package/system/dist/builtins/core-blocks/index.d.ts +8 -0
  331. package/system/dist/builtins/core-blocks/index.js +21 -0
  332. package/system/dist/builtins/core-blocks/index.mjs +2 -0
  333. package/system/dist/builtins/core-blocks/lock-door-gate.d.ts +31 -0
  334. package/system/dist/builtins/core-blocks/lock-door-sensor.d.ts +35 -0
  335. package/system/dist/builtins/core-blocks/power-source-service.d.ts +70 -0
  336. package/system/dist/builtins/core-blocks/record-kinds.d.ts +83 -0
  337. package/system/dist/builtins/core-blocks/remote-call-redirect.d.ts +23 -0
  338. package/system/dist/builtins/core-blocks/remote-components-service.d.ts +10 -0
  339. package/system/dist/builtins/core-blocks/remote-service.d.ts +85 -0
  340. package/system/dist/builtins/core-blocks/remote-wiring.d.ts +49 -0
  341. package/system/dist/builtins/core-blocks/runs-api.d.ts +30 -0
  342. package/system/dist/builtins/core-blocks/runs-ledger.d.ts +64 -0
  343. package/system/dist/builtins/core-blocks/scheduler/scheduler-engine.d.ts +91 -0
  344. package/system/dist/builtins/core-blocks/scheduler/scheduler-holds.d.ts +54 -0
  345. package/system/dist/builtins/core-blocks/scheduler/scheduler-service.d.ts +76 -0
  346. package/system/dist/builtins/core-blocks/scheduler/scheduler-store.d.ts +23 -0
  347. package/system/dist/builtins/core-blocks/scheduler/scheduler-timeline.d.ts +53 -0
  348. package/system/dist/builtins/core-blocks/scheduler/scheduler-trace.d.ts +17 -0
  349. package/system/dist/builtins/core-blocks/scheduler/scheduler-types.d.ts +20 -0
  350. package/system/dist/builtins/core-blocks/scheduler/scheduler-wiring.d.ts +41 -0
  351. package/system/dist/builtins/core-blocks/templates-service.d.ts +24 -0
  352. package/system/dist/builtins/device-history/capture/capture-engine.d.ts +113 -0
  353. package/system/dist/builtins/device-history/capture/capture-filter.d.ts +37 -0
  354. package/system/dist/builtins/device-history/capture/device-directory.d.ts +47 -0
  355. package/system/dist/builtins/device-history/capture/field-path.d.ts +10 -0
  356. package/system/dist/builtins/device-history/capture/point-writer.d.ts +63 -0
  357. package/system/dist/builtins/device-history/device-history.addon.d.ts +53 -0
  358. package/system/dist/builtins/device-history/device-history.addon.js +2885 -0
  359. package/system/dist/builtins/device-history/device-history.addon.mjs +2878 -0
  360. package/system/dist/builtins/device-history/index.d.ts +3 -0
  361. package/system/dist/builtins/device-history/ingest/producer-ingest.d.ts +99 -0
  362. package/system/dist/builtins/device-history/query/history-query.d.ts +116 -0
  363. package/system/dist/builtins/device-history/query/point-shape.d.ts +31 -0
  364. package/system/dist/builtins/device-history/retention/departure-tracker.d.ts +33 -0
  365. package/system/dist/builtins/device-history/retention/orphans.d.ts +50 -0
  366. package/system/dist/builtins/device-history/retention/retention.d.ts +74 -0
  367. package/system/dist/builtins/device-history/rollup/rollup-engine.d.ts +74 -0
  368. package/system/dist/builtins/device-history/rollup/rollup-math.d.ts +50 -0
  369. package/system/dist/builtins/device-history/runtime/history-runtime.d.ts +118 -0
  370. package/system/dist/builtins/device-history/status/counters.d.ts +55 -0
  371. package/system/dist/builtins/device-history/store/history-door.d.ts +7 -0
  372. package/system/dist/builtins/device-history/store/history-schema.d.ts +28 -0
  373. package/system/dist/builtins/device-history/store/history-store.d.ts +109 -0
  374. package/system/dist/builtins/device-history/store/row-readers.d.ts +11 -0
  375. package/system/dist/builtins/device-history/store/series-registry.d.ts +64 -0
  376. package/system/dist/builtins/device-history/store/series-scale.d.ts +37 -0
  377. package/system/dist/builtins/device-history/time/bucket-time.d.ts +25 -0
  378. package/system/dist/builtins/device-manager/adoption-job-engine.d.ts +153 -0
  379. package/system/dist/builtins/device-manager/claimed-status-overlay.d.ts +45 -0
  380. package/system/dist/builtins/device-manager/contribution-cache.d.ts +85 -0
  381. package/system/dist/builtins/device-manager/day-night-config-schema.d.ts +30 -0
  382. package/system/dist/builtins/device-manager/device-aggregation-merge.d.ts +22 -0
  383. package/system/dist/builtins/device-manager/device-aggregation.d.ts +335 -0
  384. package/system/dist/builtins/device-manager/device-bindings-store.d.ts +278 -0
  385. package/system/dist/builtins/device-manager/device-config-contribution.d.ts +45 -0
  386. package/system/dist/builtins/device-manager/device-config-secrets.d.ts +40 -0
  387. package/system/dist/builtins/device-manager/device-event-propagator.d.ts +26 -0
  388. package/system/dist/builtins/device-manager/device-extension-linked-slot.d.ts +27 -0
  389. package/system/dist/builtins/device-manager/device-form-secrets.d.ts +25 -0
  390. package/system/dist/builtins/device-manager/device-linked-devices.d.ts +201 -0
  391. package/system/dist/builtins/device-manager/device-manager.addon.d.ts +234 -0
  392. package/system/dist/builtins/device-manager/device-manager.addon.js +11369 -0
  393. package/system/dist/builtins/device-manager/device-manager.addon.mjs +11358 -0
  394. package/system/dist/builtins/device-manager/device-meta-actions.d.ts +338 -0
  395. package/system/dist/builtins/device-manager/device-meta-store.d.ts +103 -0
  396. package/system/dist/builtins/device-manager/device-meta-types.d.ts +277 -0
  397. package/system/dist/builtins/device-manager/device-online-fallback.d.ts +35 -0
  398. package/system/dist/builtins/device-manager/device-projection.d.ts +71 -0
  399. package/system/dist/builtins/device-manager/device-provider-context.d.ts +126 -0
  400. package/system/dist/builtins/device-manager/device-queries.d.ts +67 -0
  401. package/system/dist/builtins/device-manager/device-removal-hooks.d.ts +92 -0
  402. package/system/dist/builtins/device-manager/device-row-store.d.ts +449 -0
  403. package/system/dist/builtins/device-manager/device-source-activation.d.ts +103 -0
  404. package/system/dist/builtins/device-manager/device-state-claim-views.d.ts +92 -0
  405. package/system/dist/builtins/device-manager/device-state-claims.d.ts +66 -0
  406. package/system/dist/builtins/device-manager/device-state-mirror.d.ts +267 -0
  407. package/system/dist/builtins/device-manager/device-sync-resolvers.d.ts +30 -0
  408. package/system/dist/builtins/device-manager/device-tombstone-store.d.ts +29 -0
  409. package/system/dist/builtins/device-manager/discovery-orchestrator.d.ts +45 -0
  410. package/system/dist/builtins/device-manager/field-claims-index.d.ts +96 -0
  411. package/system/dist/builtins/device-manager/field-ownership.d.ts +71 -0
  412. package/system/dist/builtins/device-manager/fleet-read-census.d.ts +104 -0
  413. package/system/dist/builtins/device-manager/image-settings-config-schema.d.ts +22 -0
  414. package/system/dist/builtins/device-manager/index.d.ts +2 -0
  415. package/system/dist/builtins/device-manager/index.js +8 -0
  416. package/system/dist/builtins/device-manager/index.mjs +2 -0
  417. package/system/dist/builtins/device-manager/linked-devices-manual-backfill.d.ts +27 -0
  418. package/system/dist/builtins/device-manager/location-alignment.d.ts +61 -0
  419. package/system/dist/builtins/device-manager/migrate-device.d.ts +192 -0
  420. package/system/dist/builtins/device-manager/migrate-guard.d.ts +78 -0
  421. package/system/dist/builtins/device-manager/migrate-hardware-state.d.ts +79 -0
  422. package/system/dist/builtins/device-manager/migrate-reload.d.ts +46 -0
  423. package/system/dist/builtins/device-manager/migration-refused.d.ts +23 -0
  424. package/system/dist/builtins/device-manager/mirror-row-writer.d.ts +222 -0
  425. package/system/dist/builtins/device-manager/record-kinds.d.ts +14 -0
  426. package/system/dist/builtins/device-manager/recording-onboard-config-schema.d.ts +65 -0
  427. package/system/dist/builtins/device-manager/removal-cleanup.d.ts +50 -0
  428. package/system/dist/builtins/device-manager/removal-fence.d.ts +58 -0
  429. package/system/dist/builtins/device-manager/running-flip.d.ts +11 -0
  430. package/system/dist/builtins/device-manager/runtime-state-persist-gate.d.ts +64 -0
  431. package/system/dist/builtins/device-manager/secret-config-paths.d.ts +24 -0
  432. package/system/dist/builtins/device-manager/stale-wrapper-activations.d.ts +59 -0
  433. package/system/dist/builtins/device-manager/write-lock.d.ts +17 -0
  434. package/system/dist/builtins/hub-forwarder/hub-forwarder-destination.d.ts +43 -0
  435. package/system/dist/builtins/hub-forwarder/hub-forwarder.addon.d.ts +16 -0
  436. package/system/dist/builtins/hub-forwarder/index.d.ts +3 -0
  437. package/system/dist/builtins/hub-forwarder/index.js +151 -0
  438. package/system/dist/builtins/hub-forwarder/index.mjs +142 -0
  439. package/system/dist/builtins/keychain/index.d.ts +1 -0
  440. package/system/dist/builtins/keychain/index.js +2059 -0
  441. package/system/dist/builtins/keychain/index.mjs +2052 -0
  442. package/system/dist/builtins/keychain/key-sources.d.ts +37 -0
  443. package/system/dist/builtins/keychain/keychain-crypto.d.ts +28 -0
  444. package/system/dist/builtins/keychain/keychain-reset-trigger.d.ts +25 -0
  445. package/system/dist/builtins/keychain/keychain-service.d.ts +180 -0
  446. package/system/dist/builtins/keychain/keychain-store.d.ts +125 -0
  447. package/system/dist/builtins/keychain/keychain-usage.d.ts +17 -0
  448. package/system/dist/builtins/keychain/keychain.addon.d.ts +36 -0
  449. package/system/dist/builtins/keychain/platform-key-source.d.ts +24 -0
  450. package/system/dist/builtins/keychain/record-kinds.d.ts +16 -0
  451. package/system/dist/builtins/keychain/system-held-secrets.d.ts +25 -0
  452. package/system/dist/builtins/liveness-monitor/index.d.ts +2 -0
  453. package/system/dist/builtins/liveness-monitor/index.js +6 -0
  454. package/system/dist/builtins/liveness-monitor/index.mjs +2 -0
  455. package/system/dist/builtins/liveness-monitor/liveness-checks.d.ts +85 -0
  456. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.d.ts +46 -0
  457. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +443 -0
  458. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +437 -0
  459. package/system/dist/builtins/liveness-monitor/liveness-reporter.d.ts +28 -0
  460. package/system/dist/builtins/liveness-monitor/storage-root-access.d.ts +53 -0
  461. package/system/dist/builtins/local-auth/admin-account-boot.d.ts +27 -0
  462. package/system/dist/builtins/local-auth/auth-config-reader.d.ts +39 -0
  463. package/system/dist/builtins/local-auth/auth-schema.d.ts +93 -0
  464. package/system/dist/builtins/local-auth/index.d.ts +1 -0
  465. package/system/dist/builtins/local-auth/index.js +4 -0
  466. package/system/dist/builtins/local-auth/index.mjs +2 -0
  467. package/system/dist/builtins/local-auth/jwt-signing-key-keeper.d.ts +30 -0
  468. package/system/dist/builtins/local-auth/local-auth.addon.d.ts +48 -0
  469. package/system/dist/builtins/local-auth/local-auth.addon.js +12418 -0
  470. package/system/dist/builtins/local-auth/local-auth.addon.mjs +12388 -0
  471. package/system/dist/builtins/local-auth/oauth-grants.d.ts +71 -0
  472. package/system/dist/builtins/local-auth/oauth-session-manager.d.ts +44 -0
  473. package/system/dist/builtins/local-auth/person-scopes.d.ts +7 -0
  474. package/system/dist/builtins/local-auth/preferences-record-kinds.d.ts +27 -0
  475. package/system/dist/builtins/local-auth/record-kinds.d.ts +137 -0
  476. package/system/dist/builtins/local-auth/user-preferences-store.d.ts +56 -0
  477. package/system/dist/builtins/local-network/address-book.d.ts +128 -0
  478. package/system/dist/builtins/local-network/agent-mdns.d.ts +56 -0
  479. package/system/dist/builtins/local-network/hub-mdns-ciao.d.ts +7 -0
  480. package/system/dist/builtins/local-network/hub-mdns.d.ts +58 -0
  481. package/system/dist/builtins/local-network/index.d.ts +1 -0
  482. package/system/dist/builtins/local-network/index.js +10 -0
  483. package/system/dist/builtins/local-network/index.mjs +2 -0
  484. package/system/dist/builtins/local-network/ipv6-lan.d.ts +21 -0
  485. package/system/dist/builtins/local-network/local-hostname.d.ts +15 -0
  486. package/system/dist/builtins/local-network/local-network.addon.d.ts +334 -0
  487. package/system/dist/builtins/local-network/local-network.addon.js +2487 -0
  488. package/system/dist/builtins/local-network/local-network.addon.mjs +2466 -0
  489. package/system/dist/builtins/local-network/scan/dns-wire.d.ts +17 -0
  490. package/system/dist/builtins/local-network/scan/scan-engine.d.ts +31 -0
  491. package/system/dist/builtins/local-network/scan/scan-io-node.d.ts +2 -0
  492. package/system/dist/builtins/local-network/scan/scan-io.d.ts +56 -0
  493. package/system/dist/builtins/local-network/scan/subnets.d.ts +57 -0
  494. package/system/dist/builtins/loki-logging/index.d.ts +4 -0
  495. package/system/dist/builtins/loki-logging/index.js +915 -0
  496. package/system/dist/builtins/loki-logging/index.mjs +901 -0
  497. package/system/dist/builtins/loki-logging/loki-destination.d.ts +142 -0
  498. package/system/dist/builtins/loki-logging/loki-logging.addon.d.ts +66 -0
  499. package/system/dist/builtins/loki-logging/loki-payload.d.ts +100 -0
  500. package/system/dist/builtins/loki-logging/loki-read.d.ts +51 -0
  501. package/system/dist/builtins/loki-logging/retire-enabled-flag.d.ts +48 -0
  502. package/system/dist/builtins/native-metrics/cgroup-memory.d.ts +240 -0
  503. package/system/dist/builtins/native-metrics/cgroup-pids.d.ts +159 -0
  504. package/system/dist/builtins/native-metrics/container-memory-ring.d.ts +18 -0
  505. package/system/dist/builtins/native-metrics/darwin-memory.d.ts +26 -0
  506. package/system/dist/builtins/native-metrics/gpu-probe.d.ts +18 -0
  507. package/system/dist/builtins/native-metrics/index.d.ts +2 -0
  508. package/system/dist/builtins/native-metrics/load-series-config.d.ts +83 -0
  509. package/system/dist/builtins/native-metrics/load-series-reader.d.ts +63 -0
  510. package/system/dist/builtins/native-metrics/load-series-types.d.ts +14 -0
  511. package/system/dist/builtins/native-metrics/native-metrics-provider.d.ts +49 -0
  512. package/system/dist/builtins/native-metrics/native-metrics.addon.d.ts +233 -0
  513. package/system/dist/builtins/native-metrics/native-metrics.addon.js +3116 -0
  514. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +3106 -0
  515. package/system/dist/builtins/native-metrics/node-load-ring.d.ts +212 -0
  516. package/system/dist/builtins/native-metrics/node-metrics-history-recorder.d.ts +155 -0
  517. package/system/dist/builtins/native-metrics/proc-process-table.d.ts +25 -0
  518. package/system/dist/builtins/native-metrics/process-classification.d.ts +110 -0
  519. package/system/dist/builtins/native-metrics/thread-cpu-sampler.d.ts +116 -0
  520. package/system/dist/builtins/platform-probe/accelerator-facts-probe.d.ts +24 -0
  521. package/system/dist/builtins/platform-probe/accelerator-reprobe.d.ts +23 -0
  522. package/system/dist/builtins/platform-probe/amd-accelerators.d.ts +15 -0
  523. package/system/dist/builtins/platform-probe/amd-npu.d.ts +35 -0
  524. package/system/dist/builtins/platform-probe/coral-accelerators.d.ts +87 -0
  525. package/system/dist/builtins/platform-probe/index.d.ts +57 -0
  526. package/system/dist/builtins/platform-probe/index.js +1151 -0
  527. package/system/dist/builtins/platform-probe/index.mjs +1140 -0
  528. package/system/dist/builtins/platform-probe/inference-config-resolver.d.ts +29 -0
  529. package/system/dist/builtins/platform-probe/intel-accelerators.d.ts +14 -0
  530. package/system/dist/builtins/platform-probe/intel-npu.d.ts +38 -0
  531. package/system/dist/builtins/platform-probe/platform-scorer.d.ts +66 -0
  532. package/system/dist/builtins/platform-probe/runtime-packages.d.ts +6 -0
  533. package/system/dist/builtins/platform-probe/windows-hardware.d.ts +77 -0
  534. package/system/dist/builtins/record-entries/entries-service.d.ts +42 -0
  535. package/system/dist/builtins/record-entries/index.d.ts +1 -0
  536. package/system/dist/builtins/record-entries/index.js +162 -0
  537. package/system/dist/builtins/record-entries/index.mjs +156 -0
  538. package/system/dist/builtins/record-entries/record-entries.addon.d.ts +13 -0
  539. package/system/dist/builtins/records-isolated.d.ts +10 -0
  540. package/system/dist/builtins/remote-access-orchestrator/enabled-providers-reconcile.d.ts +96 -0
  541. package/system/dist/builtins/remote-access-orchestrator/index.d.ts +1 -0
  542. package/system/dist/builtins/remote-access-orchestrator/index.js +8 -0
  543. package/system/dist/builtins/remote-access-orchestrator/index.mjs +2 -0
  544. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.d.ts +71 -0
  545. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +214 -0
  546. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +208 -0
  547. package/system/dist/builtins/shared/device-state-changed.d.ts +16 -0
  548. package/system/dist/builtins/shared/settle-sources.d.ts +22 -0
  549. package/system/dist/builtins/snapshot/index.d.ts +2 -0
  550. package/system/dist/builtins/snapshot/index.js +2720 -0
  551. package/system/dist/builtins/snapshot/index.mjs +2713 -0
  552. package/system/dist/builtins/snapshot/snapshot-cache.d.ts +108 -0
  553. package/system/dist/builtins/snapshot/snapshot-coalescing.d.ts +135 -0
  554. package/system/dist/builtins/snapshot/snapshot-courtesy.d.ts +68 -0
  555. package/system/dist/builtins/snapshot/snapshot-durable-store.d.ts +36 -0
  556. package/system/dist/builtins/snapshot/snapshot-fatigue.d.ts +41 -0
  557. package/system/dist/builtins/snapshot/snapshot-grab-pick.d.ts +20 -0
  558. package/system/dist/builtins/snapshot/snapshot-link-url.d.ts +66 -0
  559. package/system/dist/builtins/snapshot/snapshot-media-handler.d.ts +121 -0
  560. package/system/dist/builtins/snapshot/snapshot-resize.d.ts +75 -0
  561. package/system/dist/builtins/snapshot/snapshot.addon.d.ts +581 -0
  562. package/system/dist/builtins/sqlite-storage/analyze-stats.d.ts +83 -0
  563. package/system/dist/builtins/sqlite-storage/config-store.d.ts +8 -0
  564. package/system/dist/builtins/sqlite-storage/database-snapshot-provider.d.ts +18 -0
  565. package/system/dist/builtins/sqlite-storage/device-store.d.ts +23 -0
  566. package/system/dist/builtins/sqlite-storage/file-host-client.d.ts +75 -0
  567. package/system/dist/builtins/sqlite-storage/file-host-handlers.d.ts +27 -0
  568. package/system/dist/builtins/sqlite-storage/file-host-protocol.d.ts +167 -0
  569. package/system/dist/builtins/sqlite-storage/file-host-worker.d.ts +1 -0
  570. package/system/dist/builtins/sqlite-storage/filesystem-browse-provider.d.ts +25 -0
  571. package/system/dist/builtins/sqlite-storage/filesystem-storage-provider.d.ts +83 -0
  572. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.d.ts +33 -0
  573. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +419 -0
  574. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +411 -0
  575. package/system/dist/builtins/sqlite-storage/filter-compiler.d.ts +126 -0
  576. package/system/dist/builtins/sqlite-storage/index.d.ts +12 -0
  577. package/system/dist/builtins/sqlite-storage/index.js +82 -0
  578. package/system/dist/builtins/sqlite-storage/index.mjs +50 -0
  579. package/system/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +31 -0
  580. package/system/dist/builtins/sqlite-storage/integration-registry.d.ts +34 -0
  581. package/system/dist/builtins/sqlite-storage/migrations/migration-actions.d.ts +12 -0
  582. package/system/dist/builtins/sqlite-storage/migrations/migration-edits.d.ts +35 -0
  583. package/system/dist/builtins/sqlite-storage/migrations/migration-engine.d.ts +125 -0
  584. package/system/dist/builtins/sqlite-storage/migrations/migration-hold.d.ts +23 -0
  585. package/system/dist/builtins/sqlite-storage/migrations/migration-pass.d.ts +48 -0
  586. package/system/dist/builtins/sqlite-storage/migrations/migration-restore-marker.d.ts +3 -0
  587. package/system/dist/builtins/sqlite-storage/migrations/migration-types.d.ts +151 -0
  588. package/system/dist/builtins/sqlite-storage/migrations/migrations-provider.d.ts +61 -0
  589. package/system/dist/builtins/sqlite-storage/owned-sqlite-file.d.ts +173 -0
  590. package/system/dist/builtins/sqlite-storage/path-guard.d.ts +11 -0
  591. package/system/dist/builtins/sqlite-storage/placement-errors.d.ts +60 -0
  592. package/system/dist/builtins/sqlite-storage/placement-router.d.ts +85 -0
  593. package/system/dist/builtins/sqlite-storage/prefix-range.d.ts +50 -0
  594. package/system/dist/builtins/sqlite-storage/query-bounds.d.ts +110 -0
  595. package/system/dist/builtins/sqlite-storage/query-profiler.d.ts +242 -0
  596. package/system/dist/builtins/sqlite-storage/records/records-catalog.d.ts +27 -0
  597. package/system/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +48 -0
  598. package/system/dist/builtins/sqlite-storage/records/records-engine.d.ts +115 -0
  599. package/system/dist/builtins/sqlite-storage/records/records-explain.d.ts +18 -0
  600. package/system/dist/builtins/sqlite-storage/records/records-plan.d.ts +95 -0
  601. package/system/dist/builtins/sqlite-storage/records/records-probe.d.ts +33 -0
  602. package/system/dist/builtins/sqlite-storage/records/records-provider.d.ts +72 -0
  603. package/system/dist/builtins/sqlite-storage/records/records-rows.d.ts +46 -0
  604. package/system/dist/builtins/sqlite-storage/records/records-sql.d.ts +39 -0
  605. package/system/dist/builtins/sqlite-storage/retired-settings-keys.d.ts +276 -0
  606. package/system/dist/builtins/sqlite-storage/shm-lock-canary.d.ts +60 -0
  607. package/system/dist/builtins/sqlite-storage/sqlite-pragmas.d.ts +191 -0
  608. package/system/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +583 -0
  609. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +52 -0
  610. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2960 -0
  611. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2952 -0
  612. package/system/dist/builtins/sqlite-storage/sqlite-snapshot-protocol.d.ts +54 -0
  613. package/system/dist/builtins/sqlite-storage/sqlite-snapshot-worker.d.ts +33 -0
  614. package/system/dist/builtins/sqlite-storage/sqlite-snapshotter.d.ts +118 -0
  615. package/system/dist/builtins/sqlite-storage/stale-data/stale-data-audit.d.ts +81 -0
  616. package/system/dist/builtins/sqlite-storage/stale-data/stale-data-ports.d.ts +17 -0
  617. package/system/dist/builtins/sqlite-storage/statement-shape.d.ts +64 -0
  618. package/system/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +33 -0
  619. package/system/dist/builtins/sqlite-storage/table-sizes.d.ts +95 -0
  620. package/system/dist/builtins/sqlite-storage/vector-index-shared.d.ts +81 -0
  621. package/system/dist/builtins/sqlite-storage/vector-index-vec.d.ts +143 -0
  622. package/system/dist/builtins/sqlite-storage/vector-provider.d.ts +30 -0
  623. package/system/dist/builtins/sqlite-storage/wal-checkpoint-policy.d.ts +196 -0
  624. package/system/dist/builtins/sqlite-storage/wal-checkpoint-worker.d.ts +1 -0
  625. package/system/dist/builtins/sqlite-storage/wal-checkpointer.d.ts +76 -0
  626. package/system/dist/builtins/sqlite-storage/wal-maintenance.d.ts +130 -0
  627. package/system/dist/builtins/storage-orchestrator/access-guards.d.ts +43 -0
  628. package/system/dist/builtins/storage-orchestrator/data-store-dispatch.d.ts +39 -0
  629. package/system/dist/builtins/storage-orchestrator/drain-ratchet.d.ts +104 -0
  630. package/system/dist/builtins/storage-orchestrator/drain-state-store.d.ts +26 -0
  631. package/system/dist/builtins/storage-orchestrator/hub-settings-forward.d.ts +128 -0
  632. package/system/dist/builtins/storage-orchestrator/index.d.ts +7 -0
  633. package/system/dist/builtins/storage-orchestrator/index.js +11 -0
  634. package/system/dist/builtins/storage-orchestrator/index.mjs +2 -0
  635. package/system/dist/builtins/storage-orchestrator/location-class-paths.d.ts +13 -0
  636. package/system/dist/builtins/storage-orchestrator/location-history-recorder.d.ts +76 -0
  637. package/system/dist/builtins/storage-orchestrator/location-occupancy-slice.d.ts +71 -0
  638. package/system/dist/builtins/storage-orchestrator/location-occupancy.d.ts +19 -0
  639. package/system/dist/builtins/storage-orchestrator/location-protection.d.ts +20 -0
  640. package/system/dist/builtins/storage-orchestrator/location-repoint-move.d.ts +57 -0
  641. package/system/dist/builtins/storage-orchestrator/location-repointer.d.ts +97 -0
  642. package/system/dist/builtins/storage-orchestrator/location-root-collision.d.ts +80 -0
  643. package/system/dist/builtins/storage-orchestrator/location-secrets.d.ts +114 -0
  644. package/system/dist/builtins/storage-orchestrator/location-store.d.ts +82 -0
  645. package/system/dist/builtins/storage-orchestrator/location-volume-capacity.d.ts +58 -0
  646. package/system/dist/builtins/storage-orchestrator/provider-discovery.d.ts +24 -0
  647. package/system/dist/builtins/storage-orchestrator/record-kinds.d.ts +43 -0
  648. package/system/dist/builtins/storage-orchestrator/storage-cleanup-coordinator.d.ts +68 -0
  649. package/system/dist/builtins/storage-orchestrator/storage-location-band-monitor.d.ts +77 -0
  650. package/system/dist/builtins/storage-orchestrator/storage-migration-coordinator.d.ts +241 -0
  651. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +318 -0
  652. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +5280 -0
  653. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +5264 -0
  654. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +475 -0
  655. package/system/dist/builtins/storage-orchestrator/storage-pressure-manager.d.ts +115 -0
  656. package/system/dist/builtins/system-backup/backup-encryption.d.ts +94 -0
  657. package/system/dist/builtins/system-backup/system-backup.service.d.ts +308 -0
  658. package/system/dist/builtins/system-config/index.d.ts +2 -0
  659. package/system/dist/builtins/system-config/index.js +10 -0
  660. package/system/dist/builtins/system-config/index.mjs +2 -0
  661. package/system/dist/builtins/system-config/mesh-actions.d.ts +3 -0
  662. package/system/dist/builtins/system-config/record-kinds.d.ts +32 -0
  663. package/system/dist/builtins/system-config/system-config.addon.d.ts +56 -0
  664. package/system/dist/builtins/system-config/system-config.addon.js +89334 -0
  665. package/system/dist/builtins/system-config/system-config.addon.mjs +89233 -0
  666. package/system/dist/builtins/winston-logging/index.d.ts +3 -0
  667. package/system/dist/builtins/winston-logging/index.js +324 -0
  668. package/system/dist/builtins/winston-logging/index.mjs +313 -0
  669. package/system/dist/builtins/winston-logging/log-file-cursor.d.ts +12 -0
  670. package/system/dist/builtins/winston-logging/log-file-index-store.d.ts +11 -0
  671. package/system/dist/builtins/winston-logging/log-file-index.d.ts +77 -0
  672. package/system/dist/builtins/winston-logging/log-file-read-client.d.ts +44 -0
  673. package/system/dist/builtins/winston-logging/log-file-read-protocol.d.ts +41 -0
  674. package/system/dist/builtins/winston-logging/log-file-read-worker.d.ts +1 -0
  675. package/system/dist/builtins/winston-logging/log-file-reader.d.ts +51 -0
  676. package/system/dist/builtins/winston-logging/winston-destination.d.ts +39 -0
  677. package/system/dist/builtins/winston-logging/winston-logging.addon.d.ts +20 -0
  678. package/system/dist/chunk-CNf5ZN-e.mjs +37 -0
  679. package/system/dist/chunk-Cek0wNdY.js +64 -0
  680. package/system/dist/composition-sources-C14epb_m.js +155 -0
  681. package/system/dist/composition-sources-EXNuxmGQ.mjs +132 -0
  682. package/system/dist/constants-DIGWBiNC.mjs +20 -0
  683. package/system/dist/constants-M7NtSiRo.js +66 -0
  684. package/system/dist/coral-accelerators-BSVsBVzt.js +250 -0
  685. package/system/dist/coral-accelerators-DBlgWB8k.mjs +231 -0
  686. package/system/dist/custom-action-registry-JuMHGKEc.js +1638 -0
  687. package/system/dist/custom-action-registry-oHl1xltx.mjs +1482 -0
  688. package/system/dist/device-ca-3vmBP1i0.js +474 -0
  689. package/system/dist/device-ca-DZlvNBWU.mjs +367 -0
  690. package/system/dist/dist-DcMqHB_N.mjs +108095 -0
  691. package/system/dist/dist-M9yHiIY7.js +110554 -0
  692. package/system/dist/download/hosted-model-revisions.d.ts +10 -0
  693. package/system/dist/download/model-download-service.d.ts +35 -0
  694. package/system/dist/download/model-downloader.d.ts +156 -0
  695. package/system/dist/events/event-bus.d.ts +10 -0
  696. package/system/dist/events/system-event-bus.d.ts +14 -0
  697. package/system/dist/feature/feature-manager.d.ts +11 -0
  698. package/system/dist/file-host-worker.js +160 -0
  699. package/system/dist/file-host-worker.mjs +160 -0
  700. package/system/dist/formatter-DkYZ4LXp.mjs +162 -0
  701. package/system/dist/formatter-xbxeV4GD.js +167 -0
  702. package/system/dist/framework-resolver-hook.mjs +49 -0
  703. package/system/dist/http/asset-compression.d.ts +55 -0
  704. package/system/dist/http/authenticated-file-server.d.ts +53 -0
  705. package/system/dist/http/data-plane-registry.d.ts +58 -0
  706. package/system/dist/http/file-data-plane.d.ts +18 -0
  707. package/system/dist/http/lan-http-bind.d.ts +41 -0
  708. package/system/dist/http/reverse-proxy.d.ts +42 -0
  709. package/system/dist/hub-mdns-ciao-CpCKuQnK.js +1163 -0
  710. package/system/dist/hub-mdns-ciao-Czz2ssit.mjs +942 -0
  711. package/system/dist/i18n/catalog-registry.d.ts +35 -0
  712. package/system/dist/i18n/index.d.ts +2 -0
  713. package/system/dist/index.d.ts +156 -0
  714. package/system/dist/index.js +28736 -0
  715. package/system/dist/index.mjs +28065 -0
  716. package/system/dist/intel-accelerators-BvBjZn4j.js +16 -0
  717. package/system/dist/intel-accelerators-idEumqk1.mjs +15 -0
  718. package/system/dist/intel-npu-C8HKvRQF.mjs +27 -0
  719. package/system/dist/intel-npu-DYF5hO5K.js +28 -0
  720. package/system/dist/kernel/addon-class-resolver.d.ts +4 -0
  721. package/system/dist/kernel/addon-engine-manager.d.ts +22 -0
  722. package/system/dist/kernel/addon-health-monitor.d.ts +163 -0
  723. package/system/dist/kernel/addon-installer.d.ts +651 -0
  724. package/system/dist/kernel/addon-loader.d.ts +144 -0
  725. package/system/dist/kernel/addon-manifest.d.ts +128 -0
  726. package/system/dist/kernel/addon-refused-error.d.ts +30 -0
  727. package/system/dist/kernel/addon-residue.d.ts +45 -0
  728. package/system/dist/kernel/addon-settings-store.d.ts +43 -0
  729. package/system/dist/kernel/addon-version-policy.d.ts +34 -0
  730. package/system/dist/kernel/anon-rss.d.ts +12 -0
  731. package/system/dist/kernel/array-buffer-census.d.ts +118 -0
  732. package/system/dist/kernel/bootstrap-config.d.ts +7 -0
  733. package/system/dist/kernel/cap-router-builder.d.ts +180 -0
  734. package/system/dist/kernel/capability-handle.d.ts +46 -0
  735. package/system/dist/kernel/capability-registry.d.ts +621 -0
  736. package/system/dist/kernel/config-manager.d.ts +174 -0
  737. package/system/dist/kernel/config-schema.d.ts +37 -0
  738. package/system/dist/kernel/custom-action-registry.d.ts +32 -0
  739. package/system/dist/kernel/deps/addon-deps-manager.d.ts +28 -0
  740. package/system/dist/kernel/deps/closure-dedupe.d.ts +105 -0
  741. package/system/dist/kernel/deps/ensure-addon-natives.d.ts +41 -0
  742. package/system/dist/kernel/deps/ensure-native-prebuilds.d.ts +40 -0
  743. package/system/dist/kernel/deps/manifest-native-deps.d.ts +42 -0
  744. package/system/dist/kernel/deps/manifest-python-deps.d.ts +20 -0
  745. package/system/dist/kernel/deps/manifest-system-deps.d.ts +18 -0
  746. package/system/dist/kernel/deps/npm-command.d.ts +60 -0
  747. package/system/dist/kernel/deps/system-package-allowlist.d.ts +12 -0
  748. package/system/dist/kernel/deps/system-package-broker.d.ts +31 -0
  749. package/system/dist/kernel/deps/system-package-client.d.ts +9 -0
  750. package/system/dist/kernel/device-call-redirect.d.ts +18 -0
  751. package/system/dist/kernel/device-registry.d.ts +29 -0
  752. package/system/dist/kernel/device-settings-store.d.ts +74 -0
  753. package/system/dist/kernel/event-loop-stall-monitor.d.ts +41 -0
  754. package/system/dist/kernel/event-plane-report.d.ts +225 -0
  755. package/system/dist/kernel/fs-utils.d.ts +88 -0
  756. package/system/dist/kernel/gc-census.d.ts +161 -0
  757. package/system/dist/kernel/heap-spaces.d.ts +112 -0
  758. package/system/dist/kernel/heap-watch.d.ts +816 -0
  759. package/system/dist/kernel/host-externals.d.ts +12 -0
  760. package/system/dist/kernel/hwaccel/hwaccel-resolver.d.ts +56 -0
  761. package/system/dist/kernel/hwaccel/vaapi-init-probe.d.ts +29 -0
  762. package/system/dist/kernel/index.d.ts +116 -0
  763. package/system/dist/kernel/inference/inference-resolver.d.ts +22 -0
  764. package/system/dist/kernel/inference/local-python-runtimes.d.ts +2 -0
  765. package/system/dist/kernel/infra-capabilities.d.ts +13 -0
  766. package/system/dist/kernel/isolated-builtin-phase.d.ts +57 -0
  767. package/system/dist/kernel/lifecycle/job-journal.d.ts +19 -0
  768. package/system/dist/kernel/lifecycle/lifecycle-job-engine.d.ts +106 -0
  769. package/system/dist/kernel/lifecycle/staging-area.d.ts +31 -0
  770. package/system/dist/kernel/moleculer/accessory-prune-gate.d.ts +55 -0
  771. package/system/dist/kernel/moleculer/addon-context-factory.d.ts +104 -0
  772. package/system/dist/kernel/moleculer/addon-data-plane-facility.d.ts +19 -0
  773. package/system/dist/kernel/moleculer/addon-deploy-source.d.ts +16 -0
  774. package/system/dist/kernel/moleculer/addon-peer-bytes-facility.d.ts +25 -0
  775. package/system/dist/kernel/moleculer/addon-runner.d.ts +1 -0
  776. package/system/dist/kernel/moleculer/addon-service-factory.d.ts +50 -0
  777. package/system/dist/kernel/moleculer/agent-event-scope.d.ts +49 -0
  778. package/system/dist/kernel/moleculer/agent-ui-unlock.d.ts +67 -0
  779. package/system/dist/kernel/moleculer/broker-factory.d.ts +95 -0
  780. package/system/dist/kernel/moleculer/broker-transport-swap.d.ts +60 -0
  781. package/system/dist/kernel/moleculer/cap-usage-registry.d.ts +126 -0
  782. package/system/dist/kernel/moleculer/capabilities-access.d.ts +21 -0
  783. package/system/dist/kernel/moleculer/child-addon-call-dispatch.d.ts +53 -0
  784. package/system/dist/kernel/moleculer/child-cap-descriptors.d.ts +34 -0
  785. package/system/dist/kernel/moleculer/child-cap-dispatch.d.ts +59 -0
  786. package/system/dist/kernel/moleculer/children-batch-loader.d.ts +98 -0
  787. package/system/dist/kernel/moleculer/core-cap-service.d.ts +65 -0
  788. package/system/dist/kernel/moleculer/crash-supervisor.d.ts +50 -0
  789. package/system/dist/kernel/moleculer/device-cap-proxy.d.ts +70 -0
  790. package/system/dist/kernel/moleculer/device-event-ring.d.ts +155 -0
  791. package/system/dist/kernel/moleculer/event-bus-core.d.ts +198 -0
  792. package/system/dist/kernel/moleculer/event-bus.d.ts +106 -0
  793. package/system/dist/kernel/moleculer/hub-log-forwarder.d.ts +36 -0
  794. package/system/dist/kernel/moleculer/hub-service.d.ts +39 -0
  795. package/system/dist/kernel/moleculer/init-watchdog.d.ts +60 -0
  796. package/system/dist/kernel/moleculer/mesh-access-middleware.d.ts +42 -0
  797. package/system/dist/kernel/moleculer/mesh-identity.d.ts +57 -0
  798. package/system/dist/kernel/moleculer/mesh-mtls/constants.d.ts +17 -0
  799. package/system/dist/kernel/moleculer/mesh-mtls/index.d.ts +12 -0
  800. package/system/dist/kernel/moleculer/mesh-mtls/mesh-ca-keeper.d.ts +60 -0
  801. package/system/dist/kernel/moleculer/mesh-mtls/mesh-ca.d.ts +49 -0
  802. package/system/dist/kernel/moleculer/mesh-mtls/mesh-certificate-registry.d.ts +105 -0
  803. package/system/dist/kernel/moleculer/mesh-mtls/mesh-crl.d.ts +16 -0
  804. package/system/dist/kernel/moleculer/mesh-mtls/mesh-membership.d.ts +64 -0
  805. package/system/dist/kernel/moleculer/mesh-mtls/mesh-peer-transport.d.ts +47 -0
  806. package/system/dist/kernel/moleculer/mesh-mtls/mesh-renewal.d.ts +135 -0
  807. package/system/dist/kernel/moleculer/mesh-mtls/mesh-tls-enabler.d.ts +9 -0
  808. package/system/dist/kernel/moleculer/mesh-mtls/mesh-tls-gate.d.ts +40 -0
  809. package/system/dist/kernel/moleculer/mesh-mtls/pairing/agent-pairing.d.ts +214 -0
  810. package/system/dist/kernel/moleculer/mesh-mtls/pairing/hub-pairing.d.ts +115 -0
  811. package/system/dist/kernel/moleculer/mesh-mtls/pairing/index.d.ts +3 -0
  812. package/system/dist/kernel/moleculer/mesh-mtls/pairing/pairing-protocol.d.ts +107 -0
  813. package/system/dist/kernel/moleculer/mesh-mtls/tls-tcp-transporter.d.ts +242 -0
  814. package/system/dist/kernel/moleculer/mesh-queue-report.d.ts +51 -0
  815. package/system/dist/kernel/moleculer/node-registry.d.ts +146 -0
  816. package/system/dist/kernel/moleculer/process-context.d.ts +4 -0
  817. package/system/dist/kernel/moleculer/process-service.d.ts +92 -0
  818. package/system/dist/kernel/moleculer/provider-registry.d.ts +28 -0
  819. package/system/dist/kernel/moleculer/readiness-context.d.ts +67 -0
  820. package/system/dist/kernel/moleculer/readiness-service.d.ts +37 -0
  821. package/system/dist/kernel/moleculer/records-api-transport.d.ts +9 -0
  822. package/system/dist/kernel/moleculer/register-framework-resolver.d.ts +8 -0
  823. package/system/dist/kernel/moleculer/register-node-client.d.ts +49 -0
  824. package/system/dist/kernel/moleculer/remote-logger.d.ts +43 -0
  825. package/system/dist/kernel/moleculer/resilient-cap-call.d.ts +28 -0
  826. package/system/dist/kernel/moleculer/runner-addon-settings.d.ts +29 -0
  827. package/system/dist/kernel/moleculer/runner-device-settings.d.ts +39 -0
  828. package/system/dist/kernel/moleculer/runner-heap-flags.d.ts +228 -0
  829. package/system/dist/kernel/moleculer/runner-native-allocator.d.ts +107 -0
  830. package/system/dist/kernel/moleculer/runner-process-group.d.ts +96 -0
  831. package/system/dist/kernel/moleculer/runner-refusal.d.ts +27 -0
  832. package/system/dist/kernel/moleculer/runtime-state-load.d.ts +29 -0
  833. package/system/dist/kernel/moleculer/settings-read-guard.d.ts +49 -0
  834. package/system/dist/kernel/moleculer/stream-probe-service.d.ts +28 -0
  835. package/system/dist/kernel/moleculer/trpc-links.d.ts +244 -0
  836. package/system/dist/kernel/moleculer/typed-array-serde.d.ts +14 -0
  837. package/system/dist/kernel/moleculer/worker-device-restore.d.ts +10 -0
  838. package/system/dist/kernel/outbound-queue-watch.d.ts +94 -0
  839. package/system/dist/kernel/prefix-walk.d.ts +39 -0
  840. package/system/dist/kernel/process-cpu-census.d.ts +74 -0
  841. package/system/dist/kernel/provider-kind-drift.d.ts +21 -0
  842. package/system/dist/kernel/restart-coordinator.d.ts +90 -0
  843. package/system/dist/kernel/sections-store.d.ts +20 -0
  844. package/system/dist/kernel/settings-door-view.d.ts +41 -0
  845. package/system/dist/kernel/settings-read-error.d.ts +35 -0
  846. package/system/dist/kernel/settings-view-types.d.ts +80 -0
  847. package/system/dist/kernel/socket-plane-report.d.ts +268 -0
  848. package/system/dist/kernel/status-overlay.d.ts +38 -0
  849. package/system/dist/kernel/storage-location-registry.d.ts +55 -0
  850. package/system/dist/kernel/store-settings-view.d.ts +14 -0
  851. package/system/dist/kernel/system-settings-mirror.d.ts +46 -0
  852. package/system/dist/kernel/system-settings-policy.d.ts +28 -0
  853. package/system/dist/kernel/transport/cap-action-census.d.ts +218 -0
  854. package/system/dist/kernel/transport/cap-action-name.d.ts +100 -0
  855. package/system/dist/kernel/transport/cap-child-index.d.ts +49 -0
  856. package/system/dist/kernel/transport/cap-route-resolver.d.ts +231 -0
  857. package/system/dist/kernel/transport/cap-route.d.ts +168 -0
  858. package/system/dist/kernel/transport/cap-routing-hints.d.ts +42 -0
  859. package/system/dist/kernel/transport/child-cap-protocol.d.ts +307 -0
  860. package/system/dist/kernel/transport/claimed-get-status.d.ts +39 -0
  861. package/system/dist/kernel/transport/create-local-transport.d.ts +7 -0
  862. package/system/dist/kernel/transport/device-call-redirect.d.ts +39 -0
  863. package/system/dist/kernel/transport/frame-codec.d.ts +122 -0
  864. package/system/dist/kernel/transport/hub-cap-forward.d.ts +96 -0
  865. package/system/dist/kernel/transport/index.d.ts +38 -0
  866. package/system/dist/kernel/transport/local-child-client.d.ts +199 -0
  867. package/system/dist/kernel/transport/local-child-registry.d.ts +654 -0
  868. package/system/dist/kernel/transport/local-endpoint-path.d.ts +6 -0
  869. package/system/dist/kernel/transport/local-transport.d.ts +122 -0
  870. package/system/dist/kernel/transport/parent-unowned-call.d.ts +283 -0
  871. package/system/dist/kernel/transport/peer-answered-error.d.ts +21 -0
  872. package/system/dist/kernel/transport/socket-channel.d.ts +116 -0
  873. package/system/dist/kernel/transport/socket-traffic.d.ts +118 -0
  874. package/system/dist/kernel/transport/uds-event-bridge.d.ts +85 -0
  875. package/system/dist/kernel/transport/uds-event-bus.d.ts +93 -0
  876. package/system/dist/kernel/transport/uds-local-transport.d.ts +18 -0
  877. package/system/dist/kernel/transport/uds-log-ingest.d.ts +43 -0
  878. package/system/dist/kernel/transport/uds-logger.d.ts +44 -0
  879. package/system/dist/kernel/utils/ring-buffer.d.ts +15 -0
  880. package/system/dist/kernel/workspace-detect.d.ts +9 -0
  881. package/system/dist/lib-5THG9eKz.mjs +15545 -0
  882. package/system/dist/lib-C3U1yluo.js +7110 -0
  883. package/system/dist/lib-CZ3g2WTS.js +15549 -0
  884. package/system/dist/lib-DFZblCIu.mjs +7106 -0
  885. package/system/dist/lifecycle/lifecycle-state-machine.d.ts +28 -0
  886. package/system/dist/log-file-read-protocol-B7M3X3bT.mjs +785 -0
  887. package/system/dist/log-file-read-protocol-D0WcLbIV.js +817 -0
  888. package/system/dist/log-file-read-worker.js +64 -0
  889. package/system/dist/log-file-read-worker.mjs +64 -0
  890. package/system/dist/log-read-filter-Bi066jwU.js +134 -0
  891. package/system/dist/log-read-filter-D7Ev3zm-.mjs +93 -0
  892. package/system/dist/logging/formatter.d.ts +57 -0
  893. package/system/dist/logging/log-manager.d.ts +145 -0
  894. package/system/dist/logging/log-read-filter.d.ts +43 -0
  895. package/system/dist/logging/log-redactor.d.ts +30 -0
  896. package/system/dist/logging/log-ring-buffer.d.ts +62 -0
  897. package/system/dist/logging/logging-gate.d.ts +76 -0
  898. package/system/dist/logging/logging-gate.singleton.d.ts +16 -0
  899. package/system/dist/logging/partitioned-log-buffer.d.ts +169 -0
  900. package/system/dist/logging/scoped-logger.d.ts +17 -0
  901. package/system/dist/migrations/hub/index.d.ts +11 -0
  902. package/system/dist/ms-CgH2OFlD.mjs +120 -0
  903. package/system/dist/ms-LB3giGoU.js +124 -0
  904. package/system/dist/network/network-quality.d.ts +11 -0
  905. package/system/dist/notification/notification-service.d.ts +43 -0
  906. package/system/dist/notification/toast-service.d.ts +22 -0
  907. package/system/dist/pipeline/engine-manager-resolver.d.ts +15 -0
  908. package/system/dist/pipeline/pipeline-runner.d.ts +8 -0
  909. package/system/dist/pipeline/pipeline-validator.d.ts +13 -0
  910. package/system/dist/platform-key-source-BWlq0jjn.mjs +23 -0
  911. package/system/dist/platform-key-source-Di7HrlGR.js +40 -0
  912. package/system/dist/prefix-range-D_KueXbQ.js +27 -0
  913. package/system/dist/prefix-range-Dl0znowN.mjs +22 -0
  914. package/system/dist/prefix-walk-DAOBSyH1.mjs +88 -0
  915. package/system/dist/prefix-walk-Dv6MLZlM.js +99 -0
  916. package/system/dist/process/proc-stat.d.ts +75 -0
  917. package/system/dist/process/resource-monitor.d.ts +28 -0
  918. package/system/dist/python/python-env-manager.d.ts +12 -0
  919. package/system/dist/read-all-rows-CVoO1ONM.js +29 -0
  920. package/system/dist/read-all-rows-TaPqdWNF.mjs +25 -0
  921. package/system/dist/records/read-all-rows.d.ts +6 -0
  922. package/system/dist/repl/interfaces.d.ts +31 -0
  923. package/system/dist/repl/repl-engine.d.ts +8 -0
  924. package/system/dist/resource-monitor-Di9daRwI.mjs +96 -0
  925. package/system/dist/resource-monitor-mio9dSCT.js +113 -0
  926. package/system/dist/restore-archive-Cy7jGqiD.js +4325 -0
  927. package/system/dist/restore-archive-DS4nvQ43.mjs +4213 -0
  928. package/system/dist/retention-Dqm_EiVq.mjs +893 -0
  929. package/system/dist/retention-Ufa2fci-.js +1024 -0
  930. package/system/dist/retired-settings-keys-C8nOOr5H.js +381 -0
  931. package/system/dist/retired-settings-keys-u6xQA6r7.mjs +364 -0
  932. package/system/dist/safe-buffer-B1OjL1I9.mjs +42 -0
  933. package/system/dist/safe-buffer-D3aoa-7X.js +46 -0
  934. package/system/dist/settle-sources-Bhsy57y-.js +38 -0
  935. package/system/dist/settle-sources-CDtNC8ub.mjs +33 -0
  936. package/system/dist/snapshot-courtesy-CyFs1M3I.mjs +167 -0
  937. package/system/dist/snapshot-courtesy-D_C5-nC0.js +192 -0
  938. package/system/dist/sqlite-snapshot-protocol-2QaTouWV.mjs +34 -0
  939. package/system/dist/sqlite-snapshot-protocol-B9OndqZv.js +51 -0
  940. package/system/dist/sqlite-snapshot-worker.js +185 -0
  941. package/system/dist/sqlite-snapshot-worker.mjs +179 -0
  942. package/system/dist/src-CnAqG6EF.js +714 -0
  943. package/system/dist/src-hG4grMU4.mjs +709 -0
  944. package/system/dist/storage/fs-storage-backend.d.ts +40 -0
  945. package/system/dist/storage/storage-location-manager.d.ts +23 -0
  946. package/system/dist/storage/storage-manager.d.ts +83 -0
  947. package/system/dist/tls/agent-https-names.d.ts +25 -0
  948. package/system/dist/tls/agent-https.d.ts +111 -0
  949. package/system/dist/tls/boot-tls.d.ts +35 -0
  950. package/system/dist/tls/cert-backdate.d.ts +10 -0
  951. package/system/dist/tls/cert-evaluation.d.ts +41 -0
  952. package/system/dist/tls/cert-identity.d.ts +60 -0
  953. package/system/dist/tls/cert-issue.d.ts +57 -0
  954. package/system/dist/tls/cert-manager.d.ts +124 -0
  955. package/system/dist/tls/cert-name-constraints.d.ts +53 -0
  956. package/system/dist/tls/cert-utc-time.d.ts +1 -0
  957. package/system/dist/tls/https-listener.d.ts +30 -0
  958. package/system/dist/tls/index.d.ts +12 -0
  959. package/system/dist/tls/tls-actions.d.ts +49 -0
  960. package/system/dist/tls/tls-status.d.ts +57 -0
  961. package/system/dist/tls/uploaded-cert.d.ts +46 -0
  962. package/system/dist/wal-checkpoint-policy-BahrTtyD.mjs +186 -0
  963. package/system/dist/wal-checkpoint-policy-d2z2qPqx.js +233 -0
  964. package/system/dist/wal-checkpoint-worker.js +144 -0
  965. package/system/dist/wal-checkpoint-worker.mjs +143 -0
  966. package/system/dist/wal-maintenance-BmugbgS7.js +0 -0
  967. package/system/dist/wal-maintenance-Bnb2QzYG.mjs +0 -0
  968. package/system/dist/x509.es-BRiJgOvu.mjs +11939 -0
  969. package/system/dist/x509.es-WtnRNyYS.js +12076 -0
  970. package/system/package.json +516 -0
@@ -0,0 +1,2052 @@
1
+ import { Ar as keychainAdminCapability, Go as defineRecordKinds, Ms as EventCategory, Qa as BaseAddon, Yo as formatSecretScope, ds as normalizeSecretOwner, dt as KeychainResetRecordSchema, jr as keychainCapability, lt as KEYCHAIN_RESET_TRIGGER_ACTOR, ms as parseSecretRef, ut as KeychainAuditEntrySchema } from "../../dist-DcMqHB_N.mjs";
2
+ import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-DZlvNBWU.mjs";
3
+ import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
4
+ import { a as MESH_CA_KEY_REF } from "../../constants-DIGWBiNC.mjs";
5
+ import { n as getPlatformKeychainKey } from "../../platform-key-source-BWlq0jjn.mjs";
6
+ import { createCipheriv, createDecipheriv, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
7
+ import { restrictDirToOwnerSync, restrictFileToOwnerSync, writeOwnerOnlyFileSync } from "@camstack/types/node";
8
+ import * as path$1 from "node:path";
9
+ import { promises } from "node:fs";
10
+ var IV_BYTES = 12;
11
+ var TAG_BYTES = 16;
12
+ var VALUE_PREFIX = "ck1";
13
+ var WRAP_PREFIX = "kw1";
14
+ var FINGERPRINT_LABEL = "camstack-keychain-v1";
15
+ /** 32 fresh random bytes — a master or a data key. */
16
+ function generateKey() {
17
+ return randomBytes(32);
18
+ }
19
+ /** A short random id for a data key (no dots — it is a segment of `ck1`). */
20
+ function generateKeyId() {
21
+ return randomBytes(8).toString("hex");
22
+ }
23
+ /** The full fingerprint of a master key. */
24
+ function kekFingerprint(kek) {
25
+ return createHmac("sha256", kek).update(FINGERPRINT_LABEL).digest("hex");
26
+ }
27
+ /** What the operator sees: the first 16 hex chars. */
28
+ function shortFingerprint(fingerprint) {
29
+ return fingerprint.slice(0, 16);
30
+ }
31
+ /** Constant-time string equality (lengths may differ). */
32
+ function constantTimeEquals(a, b) {
33
+ const ab = Buffer.from(a, "utf8");
34
+ const bb = Buffer.from(b, "utf8");
35
+ if (ab.length !== bb.length) return false;
36
+ return timingSafeEqual(ab, bb);
37
+ }
38
+ /**
39
+ * Key material from a key file: base64 (the format we write) or hex of
40
+ * exactly 32 bytes, surrounding whitespace ignored. Anything else is `null` —
41
+ * a file holding a password or a PEM is refused, never stretched into a key.
42
+ */
43
+ function decodeKeyMaterial(text) {
44
+ const trimmed = text.trim();
45
+ if (/^[0-9a-fA-F]{64}$/.test(trimmed)) return Buffer.from(trimmed, "hex");
46
+ if (!/^[A-Za-z0-9+/=_-]+$/.test(trimmed)) return null;
47
+ const buf = Buffer.from(trimmed, "base64");
48
+ return buf.length === 32 ? buf : null;
49
+ }
50
+ function encodeKeyMaterial(key) {
51
+ return key.toString("base64");
52
+ }
53
+ function seal(key, plaintext, aad) {
54
+ const iv = randomBytes(IV_BYTES);
55
+ const cipher = createCipheriv("aes-256-gcm", key, iv);
56
+ cipher.setAAD(Buffer.from(aad, "utf8"));
57
+ const ct = Buffer.concat([cipher.update(plaintext), cipher.final()]);
58
+ const tag = cipher.getAuthTag();
59
+ return [
60
+ iv.toString("base64"),
61
+ tag.toString("base64"),
62
+ ct.toString("base64")
63
+ ];
64
+ }
65
+ function open(key, ivB64, tagB64, ctB64, aad) {
66
+ try {
67
+ const iv = Buffer.from(ivB64, "base64");
68
+ const tag = Buffer.from(tagB64, "base64");
69
+ if (iv.length !== IV_BYTES || tag.length !== TAG_BYTES) return null;
70
+ const decipher = createDecipheriv("aes-256-gcm", key, iv);
71
+ decipher.setAAD(Buffer.from(aad, "utf8"));
72
+ decipher.setAuthTag(tag);
73
+ return Buffer.concat([decipher.update(Buffer.from(ctB64, "base64")), decipher.final()]);
74
+ } catch {
75
+ return null;
76
+ }
77
+ }
78
+ function dekAad(keyId) {
79
+ return `camstack-keychain-dek:${keyId}`;
80
+ }
81
+ /** Wrap a data key under a master key. */
82
+ function wrapDek(kek, dek, keyId) {
83
+ const [iv, tag, ct] = seal(kek, dek, dekAad(keyId));
84
+ return `${WRAP_PREFIX}.${iv}.${tag}.${ct}`;
85
+ }
86
+ /** Unwrap; `null` when the master key is not the one that wrapped it. */
87
+ function unwrapDek(kek, wrapped, keyId) {
88
+ const parts = wrapped.split(".");
89
+ if (parts.length !== 4 || parts[0] !== WRAP_PREFIX) return null;
90
+ const [, iv, tag, ct] = parts;
91
+ if (iv === void 0 || tag === void 0 || ct === void 0) return null;
92
+ const dek = open(kek, iv, tag, ct, dekAad(keyId));
93
+ return dek !== null && dek.length === 32 ? dek : null;
94
+ }
95
+ /** Encrypt one value for one ref. */
96
+ function encryptValue(dek, keyId, ref, value) {
97
+ const [iv, tag, ct] = seal(dek, Buffer.from(value, "utf8"), ref);
98
+ return `${VALUE_PREFIX}.${keyId}.${iv}.${tag}.${ct}`;
99
+ }
100
+ /** Decrypt; `null` on any failure — wrong key, wrong ref, tampered bytes. */
101
+ function decryptValue(dek, ref, envelope) {
102
+ const parts = envelope.split(".");
103
+ if (parts.length !== 5 || parts[0] !== VALUE_PREFIX) return null;
104
+ const [, , iv, tag, ct] = parts;
105
+ if (iv === void 0 || tag === void 0 || ct === void 0) return null;
106
+ const plain = open(dek, iv, tag, ct, ref);
107
+ return plain === null ? null : plain.toString("utf8");
108
+ }
109
+ //#endregion
110
+ //#region src/builtins/keychain/key-sources.ts
111
+ /**
112
+ * Where the master key comes from (D788). Configuration only — NO env var
113
+ * carries a key or a key path:
114
+ *
115
+ * 1. `keychain.keyFile` in `config.yaml` — a file outside the data volume
116
+ * (a read-only bind mount, a Docker secret). Recommended: a whole-volume
117
+ * backup then holds the ciphertext but not the key.
118
+ * 2. The desktop app's OS keychain (`safeStorage`), handed to the hub over an
119
+ * inherited pipe. Primary on a desktop hub with no key file configured.
120
+ * 3. `<dataDir>/.keychain/master.key` (0600, directory 0700), generated on
121
+ * first boot. The fallback: it protects CamStack's own backups and stray
122
+ * database copies (it is NOT in `DEFAULT_BACKUP_LOCATIONS`), but a tar of
123
+ * the whole data directory carries key and database together, and the
124
+ * Secrets page says so.
125
+ *
126
+ * `keychain.previousKeyFile` is consulted only to UNLOCK — so a move from one
127
+ * key to another is a restart plus `rotateMasterKey`, with no window where
128
+ * neither key works.
129
+ */
130
+ /** The default key file's location under the data root. */
131
+ function defaultKeyFilePath(dataDir) {
132
+ return path$1.join(dataDir, ".keychain", "master.key");
133
+ }
134
+ async function loadKeyFile(file) {
135
+ let text;
136
+ try {
137
+ text = await promises.readFile(file, "utf8");
138
+ } catch (err) {
139
+ if ((err !== null && typeof err === "object" ? Reflect.get(err, "code") : void 0) === "ENOENT") return { kind: "absent" };
140
+ return {
141
+ kind: "unreadable",
142
+ error: err instanceof Error ? err.message : String(err)
143
+ };
144
+ }
145
+ const key = decodeKeyMaterial(text);
146
+ return key === null ? {
147
+ kind: "unreadable",
148
+ error: "not 32 bytes of base64 or hex key material"
149
+ } : {
150
+ kind: "loaded",
151
+ key
152
+ };
153
+ }
154
+ function fileSource(kind, file, sharesBackupWithDatabase) {
155
+ return {
156
+ kind,
157
+ path: file,
158
+ sharesBackupWithDatabase
159
+ };
160
+ }
161
+ /** Every candidate, primary first. */
162
+ function buildKeySourceCandidates(opts) {
163
+ const out = [];
164
+ const defaultFile = defaultKeyFilePath(opts.dataDir);
165
+ const platform = getPlatformKeychainKey();
166
+ const keyFile = opts.config.keyFile?.trim();
167
+ const previousKeyFile = opts.config.previousKeyFile?.trim();
168
+ const primaryKind = keyFile !== void 0 && keyFile.length > 0 ? "config-file" : platform !== null ? "platform" : "default-file";
169
+ if (keyFile !== void 0 && keyFile.length > 0) out.push({
170
+ source: fileSource("config-file", keyFile, false),
171
+ primary: true,
172
+ load: () => loadKeyFile(keyFile)
173
+ });
174
+ if (previousKeyFile !== void 0 && previousKeyFile.length > 0) out.push({
175
+ source: fileSource("previous-config-file", previousKeyFile, false),
176
+ primary: false,
177
+ load: () => loadKeyFile(previousKeyFile)
178
+ });
179
+ if (platform !== null) out.push({
180
+ source: {
181
+ kind: "platform",
182
+ sharesBackupWithDatabase: false
183
+ },
184
+ primary: primaryKind === "platform",
185
+ load: async () => ({
186
+ kind: "loaded",
187
+ key: platform.key
188
+ })
189
+ });
190
+ out.push({
191
+ source: fileSource("default-file", defaultFile, true),
192
+ primary: primaryKind === "default-file",
193
+ load: () => loadKeyFile(defaultFile)
194
+ });
195
+ return out;
196
+ }
197
+ /**
198
+ * Write a master key to the default location: directory 0700, file 0600,
199
+ * atomically (temp + rename), never over an existing file unless `replace`.
200
+ * Returns the previous file's new name when one was moved aside.
201
+ */
202
+ async function writeDefaultKeyFile(dataDir, key, opts) {
203
+ const file = defaultKeyFilePath(dataDir);
204
+ try {
205
+ return await writeKeyFileAt(file, key, opts);
206
+ } catch (err) {
207
+ throw new Error(`could not write the master key at ${file}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
208
+ }
209
+ }
210
+ async function writeKeyFileAt(file, key, opts) {
211
+ const dir = path$1.dirname(file);
212
+ await promises.mkdir(dir, {
213
+ recursive: true,
214
+ mode: 448
215
+ });
216
+ restrictDirToOwnerSync(dir);
217
+ let movedAside = null;
218
+ try {
219
+ await promises.access(file);
220
+ if (!opts.replace) throw new Error(`refusing to overwrite the existing master key at ${file}`);
221
+ movedAside = `${file}.prev-${opts.nowMs}`;
222
+ await promises.copyFile(file, movedAside);
223
+ restrictFileToOwnerSync(movedAside);
224
+ } catch (err) {
225
+ if ((err !== null && typeof err === "object" ? Reflect.get(err, "code") : void 0) !== "ENOENT") throw err;
226
+ }
227
+ writeOwnerOnlyFileSync(file, `${encodeKeyMaterial(key)}\n`);
228
+ const back = await loadKeyFile(file);
229
+ if (back.kind !== "loaded" || !back.key.equals(key)) throw new Error("the written key file does not read back as the generated key");
230
+ return movedAside;
231
+ }
232
+ //#endregion
233
+ //#region src/builtins/keychain/keychain-reset-trigger.ts
234
+ /**
235
+ * The one-shot `RESET_KEYCHAIN` trigger file — the way back into a hub whose
236
+ * master key is lost (operator decision 2026-10-09; plan §2).
237
+ *
238
+ * ## Why a file
239
+ *
240
+ * A locked keychain cannot be reset from Data → Secrets: the session signing
241
+ * key lives IN the keychain (D797), so no login and no bearer token verifies,
242
+ * and every admin credential is a signing-key JWT. Whoever can write the data
243
+ * directory can already read the default master key, so a file there is the
244
+ * same trust boundary as the key itself — and it needs nothing but host access
245
+ * (works in a stopped container's volume, no extra binary). The pattern is
246
+ * `RESET_ADMIN_PASSWORD`'s (`local-auth/admin-account-boot.ts`).
247
+ *
248
+ * ## Behaviour
249
+ *
250
+ * Checked once at keychain boot, right after the unlock:
251
+ *
252
+ * - absent → nothing;
253
+ * - the keychain is UNLOCKED → ignored and deleted, with a warning. A working
254
+ * store is never destroyed by a file someone forgot;
255
+ * - locked for a key reason (`wrong-key`, `key-missing`, `key-file-unreadable`)
256
+ * → `KeychainService.resetAs('trigger-file')`: values and wrapped keys
257
+ * archived, a new master key and data key, the system-held markers cleared,
258
+ * the file deleted, and an error-level banner naming what to re-enter;
259
+ * - a reset that cannot end unlocked (a configured key file that is missing)
260
+ * is refused BEFORE anything is archived; the file is still deleted (one
261
+ * shot — fix the key source and create it again);
262
+ * - locked because the STORE cannot be read → left armed: nothing could be
263
+ * reset, and the next boot that reaches the store decides.
264
+ *
265
+ * NO environment variable arms it. A flag left in a container template would
266
+ * re-arm on every boot; a file the hub deletes cannot.
267
+ */
268
+ /** The trigger's name, inside `<dataDir>/.keychain/`. */
269
+ var KEYCHAIN_RESET_TRIGGER = "RESET_KEYCHAIN";
270
+ /** Lock reasons a reset can cure — the master key, not the store. */
271
+ var RESETTABLE_REASONS = new Set([
272
+ "wrong-key",
273
+ "key-missing",
274
+ "key-file-unreadable"
275
+ ]);
276
+ function keychainResetTriggerPath(dataDir) {
277
+ return path$1.join(dataDir, ".keychain", KEYCHAIN_RESET_TRIGGER);
278
+ }
279
+ async function triggerExists(file) {
280
+ try {
281
+ await promises.access(file);
282
+ return true;
283
+ } catch {
284
+ return false;
285
+ }
286
+ }
287
+ async function consume(file, logger) {
288
+ try {
289
+ await promises.rm(file, { force: true });
290
+ } catch (err) {
291
+ logger.error("Could not delete the RESET_KEYCHAIN trigger — delete it by hand, or the next boot with a locked keychain resets it again", {
292
+ trigger: file,
293
+ error: err instanceof Error ? err.message : String(err)
294
+ });
295
+ }
296
+ }
297
+ async function applyKeychainResetTrigger(input) {
298
+ const { service, logger } = input;
299
+ const file = keychainResetTriggerPath(input.dataDir);
300
+ if (!await triggerExists(file)) return { kind: "absent" };
301
+ const state = service.getState();
302
+ if (state.state === "ready") {
303
+ logger.warn("RESET_KEYCHAIN ignored: the keychain is unlocked, so nothing is lost and nothing is reset. The trigger file was deleted.", { trigger: file });
304
+ await consume(file, logger);
305
+ return { kind: "ignored-unlocked" };
306
+ }
307
+ if (!RESETTABLE_REASONS.has(state.reason)) {
308
+ logger.error("RESET_KEYCHAIN not acted on yet: the keychain is locked because its store cannot be read, not because of the master key. The trigger stays until a boot can reach the store.", {
309
+ trigger: file,
310
+ reason: state.reason
311
+ });
312
+ return {
313
+ kind: "deferred",
314
+ reason: state.reason
315
+ };
316
+ }
317
+ let record;
318
+ try {
319
+ record = await service.resetAs(KEYCHAIN_RESET_TRIGGER_ACTOR);
320
+ } catch (err) {
321
+ const error = err instanceof Error ? err.message : String(err);
322
+ logger.error(`RESET_KEYCHAIN refused — nothing was archived, the keychain is still locked: ${error}. The trigger file was deleted; fix the key source and create it again.`, {
323
+ trigger: file,
324
+ reason: state.reason
325
+ });
326
+ await consume(file, logger);
327
+ return {
328
+ kind: "refused",
329
+ error
330
+ };
331
+ }
332
+ await consume(file, logger);
333
+ const toReenter = ((await service.resetReport().catch(() => null))?.pendingReentry ?? []).map((m) => `${m.owner}:${m.scope}:${m.fieldPath}`);
334
+ logger.error("*** KEYCHAIN RESET by the RESET_KEYCHAIN trigger file *** Every stored secret was archived (unreadable without the lost master key) and a new master key and data key were created. Every secret field now reads \"not set\" — re-enter them (Data → Secrets lists them). The session signing key is regenerated: everyone signs in again.", {
335
+ lockedReason: state.reason,
336
+ archived: record.archived,
337
+ archivedCollection: record.archivedCollection,
338
+ archivedKeysCollection: record.archivedKeysCollection,
339
+ clearedSettingsKeys: record.clearedSettingsKeys,
340
+ toReenter
341
+ });
342
+ return {
343
+ kind: "reset",
344
+ record
345
+ };
346
+ }
347
+ //#endregion
348
+ //#region src/builtins/keychain/system-held-secrets.ts
349
+ /** The refs `keychain-admin.setSystemSecret` may write, by name. */
350
+ var SYSTEM_HELD_SECRET_REFS = { "jwt-signing-key": JWT_SIGNING_KEY_REF };
351
+ /** System refs no blob points at — in use for as long as they exist. */
352
+ var PROCESS_HELD_SECRET_REFS = new Set([
353
+ JWT_SIGNING_KEY_REF,
354
+ MESH_CA_KEY_REF,
355
+ DEVICE_CA_KEY_REF
356
+ ]);
357
+ /** `system-settings` keys that may hold a system-owned secret's marker. */
358
+ var SYSTEM_SECRET_SETTINGS_KEYS = [];
359
+ var KeychainLockedError = class extends Error {
360
+ reason;
361
+ constructor(reason) {
362
+ super(`keychain is locked (${reason}) — no value can be stored or revealed`);
363
+ this.reason = reason;
364
+ this.name = "KeychainLockedError";
365
+ }
366
+ };
367
+ /** A reset that would archive the values and still end locked — refused before it starts. */
368
+ var KeychainResetRefusedError = class extends Error {
369
+ constructor(reason) {
370
+ super(`keychain reset refused: ${reason}`);
371
+ this.name = "KeychainResetRefusedError";
372
+ }
373
+ };
374
+ var KeychainForbiddenError = class extends Error {
375
+ ref;
376
+ constructor(ref, caller) {
377
+ super(`keychain: ${caller === null ? "an unidentified caller" : `"${caller}"`} does not own ${ref}`);
378
+ this.ref = ref;
379
+ this.name = "KeychainForbiddenError";
380
+ }
381
+ };
382
+ var NOT_INITIALIZED = {
383
+ state: "locked",
384
+ reason: "not-initialized"
385
+ };
386
+ /**
387
+ * Refs `importSecret` accepts for operator migration (D870): restream tokens and
388
+ * record-row secret refs (`recordSecretRef` — collection `records%3A<kind>`).
389
+ */
390
+ var IMPORTABLE_REF = /^(?:secret:\/\/stream-broker\/device\/[0-9]+\/rtspTokens|secret:\/\/[^/]+\/row\/records%3A[^/]+\/[^/]+\/.+)$/;
391
+ var KeychainService = class {
392
+ deps;
393
+ unlock = NOT_INITIALIZED;
394
+ configuredSource = null;
395
+ now;
396
+ constructor(deps) {
397
+ this.deps = deps;
398
+ this.now = deps.now ?? Date.now;
399
+ }
400
+ /** Load the keys and unlock. Never throws for a key problem — it locks. */
401
+ async init() {
402
+ try {
403
+ await this.deps.repo.init();
404
+ } catch (err) {
405
+ this.unlock = {
406
+ state: "locked",
407
+ reason: "store-unavailable"
408
+ };
409
+ this.deps.logger.error("keychain tables could not be declared — locked", { error: errMsg(err) });
410
+ return this.getState();
411
+ }
412
+ this.unlock = await this.computeUnlock();
413
+ if (this.unlock.state === "ready") this.deps.logger.info("keychain unlocked", {
414
+ source: this.unlock.source.kind,
415
+ path: this.unlock.source.path,
416
+ fingerprint: shortFingerprint(this.unlock.fingerprint),
417
+ rotationPending: this.unlock.rotationPending
418
+ });
419
+ else this.deps.logger.error("keychain LOCKED — every secret resolves unavailable", {
420
+ reason: this.unlock.reason,
421
+ path: this.configuredSource?.path
422
+ });
423
+ try {
424
+ await this.deps.repo.pruneAudit(this.now());
425
+ } catch (err) {
426
+ this.deps.logger.warn("keychain audit prune failed", { error: errMsg(err) });
427
+ }
428
+ return this.getState();
429
+ }
430
+ async computeUnlock() {
431
+ const candidates = await this.deps.candidates();
432
+ const primary = candidates.find((c) => c.primary) ?? null;
433
+ this.configuredSource = primary?.source ?? null;
434
+ let wraps;
435
+ try {
436
+ wraps = await this.deps.repo.listKeys();
437
+ } catch {
438
+ return {
439
+ state: "locked",
440
+ reason: "store-unavailable"
441
+ };
442
+ }
443
+ if (wraps.length === 0) return this.firstBoot(primary);
444
+ let anyLoaded = false;
445
+ let primaryUnreadable = false;
446
+ for (const candidate of candidates) {
447
+ const loaded = await candidate.load();
448
+ if (loaded.kind === "unreadable") {
449
+ if (candidate.primary) primaryUnreadable = true;
450
+ this.deps.logger.warn("keychain key source unreadable", {
451
+ source: candidate.source.kind,
452
+ path: candidate.source.path,
453
+ error: loaded.error
454
+ });
455
+ continue;
456
+ }
457
+ if (loaded.kind !== "loaded") continue;
458
+ anyLoaded = true;
459
+ const fingerprint = kekFingerprint(loaded.key);
460
+ const ordered = [...wraps].toSorted((a, b) => a.state === b.state ? b.createdAt - a.createdAt : a.state === "active" ? -1 : 1);
461
+ for (const wrap of ordered) {
462
+ if (!constantTimeEquals(wrap.kekFingerprint, fingerprint)) continue;
463
+ const dek = unwrapDek(loaded.key, wrap.wrappedDek, wrap.keyId);
464
+ if (dek === null) continue;
465
+ return {
466
+ state: "ready",
467
+ dek,
468
+ keyId: wrap.keyId,
469
+ kek: loaded.key,
470
+ fingerprint,
471
+ source: candidate.source,
472
+ wrap,
473
+ rotationPending: !candidate.primary || wrap.state !== "active"
474
+ };
475
+ }
476
+ }
477
+ if (primaryUnreadable) return {
478
+ state: "locked",
479
+ reason: "key-file-unreadable"
480
+ };
481
+ return {
482
+ state: "locked",
483
+ reason: anyLoaded ? "wrong-key" : "key-missing"
484
+ };
485
+ }
486
+ /** No wrapped data key yet: create one — only when nothing could be lost. */
487
+ async firstBoot(primary) {
488
+ let existing;
489
+ try {
490
+ existing = await this.deps.repo.listSecrets();
491
+ } catch {
492
+ return {
493
+ state: "locked",
494
+ reason: "store-unavailable"
495
+ };
496
+ }
497
+ if (existing.length > 0) return {
498
+ state: "locked",
499
+ reason: "key-missing"
500
+ };
501
+ if (primary === null) return {
502
+ state: "locked",
503
+ reason: "key-missing"
504
+ };
505
+ const loaded = await primary.load();
506
+ let kek;
507
+ if (loaded.kind === "loaded") kek = loaded.key;
508
+ else if (loaded.kind === "unreadable") return {
509
+ state: "locked",
510
+ reason: "key-file-unreadable"
511
+ };
512
+ else if (primary.source.kind === "default-file") {
513
+ kek = generateKey();
514
+ try {
515
+ await writeDefaultKeyFile(this.deps.dataDir, kek, {
516
+ replace: false,
517
+ nowMs: this.now()
518
+ });
519
+ } catch (err) {
520
+ this.deps.logger.error("keychain master key could NOT be generated — no key stored", {
521
+ path: primary.source.path,
522
+ error: errMsg(err)
523
+ });
524
+ throw err;
525
+ }
526
+ this.deps.logger.info("keychain master key generated", { path: primary.source.path });
527
+ } else return {
528
+ state: "locked",
529
+ reason: "key-missing"
530
+ };
531
+ const dek = generateKey();
532
+ const keyId = generateKeyId();
533
+ const fingerprint = kekFingerprint(kek);
534
+ const wrap = {
535
+ wrapId: randomUUID(),
536
+ keyId,
537
+ wrappedDek: wrapDek(kek, dek, keyId),
538
+ kekFingerprint: fingerprint,
539
+ kekSource: primary.source.kind,
540
+ createdAt: this.now(),
541
+ state: "active",
542
+ recoveryDownloadedAt: null
543
+ };
544
+ await this.deps.repo.putKey(wrap);
545
+ await this.audit("initialize", "system", null, `source=${primary.source.kind}`);
546
+ return {
547
+ state: "ready",
548
+ dek,
549
+ keyId,
550
+ kek,
551
+ fingerprint,
552
+ source: primary.source,
553
+ wrap,
554
+ rotationPending: false
555
+ };
556
+ }
557
+ getState() {
558
+ return this.unlock.state === "ready" ? { state: "ready" } : {
559
+ state: "locked",
560
+ reason: this.unlock.reason
561
+ };
562
+ }
563
+ requireReady() {
564
+ if (this.unlock.state !== "ready") throw new KeychainLockedError(this.unlock.reason);
565
+ return this.unlock;
566
+ }
567
+ /**
568
+ * Delete the values rows of a dropped record kind held. The engine is the
569
+ * authority that the rows are gone; the usage check cannot verify a record
570
+ * row scope, so it is not asked. Only `row/records:*` refs are accepted.
571
+ *
572
+ * @returns how many values were removed.
573
+ */
574
+ async releaseRecordRefs(caller, refs, onBehalfOf) {
575
+ if (caller === null || normalizeSecretOwner(caller) !== "sqlite-settings") throw new KeychainForbiddenError("records", caller);
576
+ const accepted = [];
577
+ for (const ref of new Set(refs)) {
578
+ const parts = parseSecretRef(ref);
579
+ if (parts === null || parts.scope.kind !== "row" || !parts.scope.collection.startsWith("records:")) throw new KeychainForbiddenError(ref, caller);
580
+ accepted.push(ref);
581
+ }
582
+ if (accepted.length === 0) return 0;
583
+ const existing = await this.deps.repo.getSecrets(accepted);
584
+ const present = accepted.filter((ref) => existing.has(ref));
585
+ if (present.length === 0) return 0;
586
+ const deleted = await this.deps.repo.deleteSecrets(present);
587
+ for (const ref of present) {
588
+ await this.audit("delete", `user:${onBehalfOf}`, ref, "record-kind-dropped");
589
+ this.deps.events.emit({
590
+ ref,
591
+ owner: parseSecretRef(ref)?.owner ?? "",
592
+ version: null,
593
+ change: "delete"
594
+ });
595
+ }
596
+ return deleted;
597
+ }
598
+ /** May `caller` touch values owned by `owner`? */
599
+ owns(caller, owner) {
600
+ if (caller === null) return false;
601
+ const c = normalizeSecretOwner(caller);
602
+ const o = normalizeSecretOwner(owner);
603
+ if (c.length === 0) return false;
604
+ if (c === o) return true;
605
+ return this.deps.runnerIdOf(o) === c;
606
+ }
607
+ ownerOf(ref, caller) {
608
+ const parts = parseSecretRef(ref);
609
+ if (parts === null || !this.owns(caller, parts.owner)) throw new KeychainForbiddenError(ref, caller);
610
+ return parts.owner;
611
+ }
612
+ /**
613
+ * @param actor who the audit names — the owner addon by default; the
614
+ * operator (`user:<id>`) for {@link setSystemSecret}.
615
+ */
616
+ async put(caller, ref, value, actor = actorOfAddon(caller)) {
617
+ const owner = this.ownerOf(ref, caller);
618
+ const unlocked = this.requireReady();
619
+ if (value.length === 0) throw new Error("keychain.put: an empty value is not stored — delete the ref");
620
+ const parts = parseSecretRef(ref);
621
+ if (parts === null) throw new KeychainForbiddenError(ref, caller);
622
+ const existing = (await this.deps.repo.getSecrets([ref])).get(ref);
623
+ if (existing !== void 0) {
624
+ const current = decryptValue(unlocked.dek, ref, existing.ciphertext);
625
+ if (current !== null && constantTimeEquals(current, value)) return {
626
+ ref,
627
+ version: existing.version
628
+ };
629
+ }
630
+ const t = this.now();
631
+ const version = (existing?.version ?? 0) + 1;
632
+ await this.deps.repo.putSecret({
633
+ ref,
634
+ owner,
635
+ scope: formatSecretScope(parts.scope),
636
+ fieldPath: parts.fieldPath,
637
+ ciphertext: encryptValue(unlocked.dek, unlocked.keyId, ref, value),
638
+ keyId: unlocked.keyId,
639
+ version,
640
+ createdAt: existing?.createdAt ?? t,
641
+ updatedAt: t,
642
+ updatedBy: actor,
643
+ lastReadAt: existing?.lastReadAt ?? null
644
+ });
645
+ await this.audit("put", actor, ref, `version=${version}`);
646
+ this.deps.events.emit({
647
+ ref,
648
+ owner,
649
+ version,
650
+ change: "put"
651
+ });
652
+ return {
653
+ ref,
654
+ version
655
+ };
656
+ }
657
+ async resolve(caller, refs) {
658
+ const out = {};
659
+ const owned = [];
660
+ for (const ref of new Set(refs)) {
661
+ const parts = parseSecretRef(ref);
662
+ if (parts === null || !this.owns(caller, parts.owner)) {
663
+ out[ref] = { kind: "forbidden" };
664
+ continue;
665
+ }
666
+ owned.push(ref);
667
+ }
668
+ if (owned.length === 0) return out;
669
+ if (this.unlock.state !== "ready") {
670
+ for (const ref of owned) out[ref] = {
671
+ kind: "unavailable",
672
+ reason: this.unlock.reason
673
+ };
674
+ return out;
675
+ }
676
+ const unlocked = this.unlock;
677
+ let rows;
678
+ try {
679
+ rows = await this.deps.repo.getSecrets(owned);
680
+ } catch {
681
+ for (const ref of owned) out[ref] = {
682
+ kind: "unavailable",
683
+ reason: "store-unavailable"
684
+ };
685
+ return out;
686
+ }
687
+ const t = this.now();
688
+ const stale = [];
689
+ for (const ref of owned) {
690
+ const row = rows.get(ref);
691
+ if (row === void 0) {
692
+ out[ref] = { kind: "missing" };
693
+ continue;
694
+ }
695
+ const value = decryptValue(unlocked.dek, ref, row.ciphertext);
696
+ if (value === null) {
697
+ out[ref] = {
698
+ kind: "unavailable",
699
+ reason: "decrypt-failed"
700
+ };
701
+ this.deps.logger.error("keychain value did not authenticate", { ref });
702
+ continue;
703
+ }
704
+ out[ref] = {
705
+ kind: "value",
706
+ value,
707
+ version: row.version
708
+ };
709
+ if (row.lastReadAt === null || t - row.lastReadAt >= 36e5) stale.push(row);
710
+ }
711
+ if (stale.length > 0) this.touchLastRead(stale, t);
712
+ return out;
713
+ }
714
+ async touchLastRead(rows, at) {
715
+ try {
716
+ for (const row of rows) await this.deps.repo.putSecret({
717
+ ...row,
718
+ lastReadAt: at
719
+ });
720
+ } catch (err) {
721
+ this.deps.logger.warn("keychain lastReadAt not recorded", { error: errMsg(err) });
722
+ }
723
+ }
724
+ async delete(caller, refs) {
725
+ const owners = /* @__PURE__ */ new Map();
726
+ for (const ref of new Set(refs)) owners.set(ref, this.ownerOf(ref, caller));
727
+ if (owners.size === 0) return 0;
728
+ const existing = await this.deps.repo.getSecrets([...owners.keys()]);
729
+ const present = [...owners.keys()].filter((ref) => existing.has(ref));
730
+ if (present.length === 0) return 0;
731
+ const deleted = await this.deps.repo.deleteSecrets(present);
732
+ for (const ref of present) {
733
+ await this.audit("delete", actorOfAddon(caller), ref, null);
734
+ this.deps.events.emit({
735
+ ref,
736
+ owner: owners.get(ref) ?? "",
737
+ version: null,
738
+ change: "delete"
739
+ });
740
+ }
741
+ return deleted;
742
+ }
743
+ /**
744
+ * Delete EVERY value whose scope is `device/<deviceId>`, whatever its owner
745
+ * (D864). A device-scoped secret is owned by the driver that declared it, so
746
+ * the device manager — which knows only that the device is gone — cannot name
747
+ * the owner; this is the one owner-spanning delete, and it is reserved to
748
+ * the device manager (a removal is the only moment a whole device scope
749
+ * stops being anybody's). Works while locked: it removes ciphertext, it
750
+ * never reads it.
751
+ *
752
+ * @returns the refs removed (never values), for the caller's one log line.
753
+ */
754
+ async deleteDeviceScope(caller, deviceId) {
755
+ if (caller === null || normalizeSecretOwner(caller) !== "device-manager") throw new KeychainForbiddenError(`device/${deviceId}`, caller);
756
+ const scope = formatSecretScope({
757
+ kind: "device",
758
+ deviceId
759
+ });
760
+ const rows = (await this.deps.repo.listSecrets()).filter((row) => row.scope === scope);
761
+ if (rows.length === 0) return [];
762
+ const refs = rows.map((row) => row.ref);
763
+ await this.deps.repo.deleteSecrets(refs);
764
+ for (const row of rows) {
765
+ await this.audit("delete", actorOfAddon(caller), row.ref, "device-removed");
766
+ this.deps.events.emit({
767
+ ref: row.ref,
768
+ owner: row.owner,
769
+ version: null,
770
+ change: "delete"
771
+ });
772
+ }
773
+ return refs;
774
+ }
775
+ async listMeta(caller) {
776
+ return (await this.deps.repo.listSecrets()).filter((row) => this.owns(caller, row.owner)).map(toMeta);
777
+ }
778
+ async status() {
779
+ const wraps = await this.deps.repo.listKeys().catch(() => []);
780
+ const secrets = await this.deps.repo.listSecrets().catch(() => []);
781
+ const unlocked = this.unlock.state === "ready" ? this.unlock : null;
782
+ const configured = this.configuredSource ?? {
783
+ kind: "default-file",
784
+ path: defaultKeyFilePath(this.deps.dataDir),
785
+ sharesBackupWithDatabase: true
786
+ };
787
+ return {
788
+ keychain: this.getState(),
789
+ keySource: unlocked?.source ?? null,
790
+ configuredSource: configured,
791
+ fingerprint: unlocked !== null ? shortFingerprint(unlocked.fingerprint) : null,
792
+ activeKeyId: unlocked?.keyId ?? null,
793
+ rotationPending: unlocked?.rotationPending ?? false,
794
+ retiredWraps: wraps.filter((w) => w.state === "retired").length,
795
+ recoveryKeyDownloadedAt: unlocked !== null ? wraps.find((w) => w.wrapId === unlocked.wrap.wrapId)?.recoveryDownloadedAt ?? null : null,
796
+ secretCount: secrets.length,
797
+ lastReset: await this.deps.repo.latestReset().catch(() => null)
798
+ };
799
+ }
800
+ async listSecrets() {
801
+ const rows = await this.deps.repo.listSecrets();
802
+ const usage = await this.deps.usage(rows).catch(() => /* @__PURE__ */ new Map());
803
+ return rows.map((row) => ({
804
+ ...toMeta(row),
805
+ usage: usage.get(row.ref) ?? "unknown"
806
+ }));
807
+ }
808
+ /**
809
+ * The operator replaces a system-held secret no form edits (D797) — the
810
+ * session signing key. Stored under owner `system`, audited as the user.
811
+ */
812
+ async setSystemSecret(userId, name, value) {
813
+ const ref = SYSTEM_HELD_SECRET_REFS[name];
814
+ return this.put(SYSTEM_SECRET_OWNER, ref, value, `user:${userId}`);
815
+ }
816
+ /**
817
+ * An operator tool stores a carried-over value at a migration ref (D870):
818
+ * restream tokens or a `recordSecretRef` row field. Stored under the ref's
819
+ * owner, audited as the operator; never overwrites an existing value.
820
+ */
821
+ async importSecret(userId, ref, value) {
822
+ if (!IMPORTABLE_REF.test(ref)) throw new Error(`keychain: "${ref}" is not an importable ref (restream tokens or record row secrets)`);
823
+ if ((await this.deps.repo.getSecrets([ref])).has(ref)) throw new Error(`keychain: a value is already stored at ${ref} - import refuses to overwrite`);
824
+ const parts = parseSecretRef(ref);
825
+ if (parts === null) throw new Error(`keychain: "${ref}" is not a secret ref`);
826
+ return this.put(parts.owner, ref, value, `user:${userId}`);
827
+ }
828
+ async listAudit(limit) {
829
+ return this.deps.repo.listAudit(limit);
830
+ }
831
+ async reveal(userId, ref) {
832
+ const unlocked = this.requireReady();
833
+ const row = (await this.deps.repo.getSecrets([ref])).get(ref);
834
+ if (row === void 0) throw new Error(`keychain: no value stored at ${ref}`);
835
+ const value = decryptValue(unlocked.dek, ref, row.ciphertext);
836
+ if (value === null) throw new Error(`keychain: the value at ${ref} did not authenticate`);
837
+ await this.audit("reveal", `user:${userId}`, ref, null);
838
+ return {
839
+ value,
840
+ version: row.version
841
+ };
842
+ }
843
+ async deleteOrphans(userId, refs) {
844
+ const rows = [...(await this.deps.repo.getSecrets(refs)).values()];
845
+ const usage = await this.deps.usage(rows);
846
+ const deleted = [];
847
+ const kept = [];
848
+ for (const row of rows) {
849
+ const u = usage.get(row.ref) ?? "unknown";
850
+ if (u === "orphan") deleted.push(row.ref);
851
+ else kept.push({
852
+ ref: row.ref,
853
+ usage: u
854
+ });
855
+ }
856
+ if (deleted.length > 0) {
857
+ await this.deps.repo.deleteSecrets(deleted);
858
+ for (const ref of deleted) {
859
+ const owner = parseSecretRef(ref)?.owner ?? "";
860
+ this.deps.events.emit({
861
+ ref,
862
+ owner,
863
+ version: null,
864
+ change: "delete"
865
+ });
866
+ }
867
+ await this.audit("delete-orphans", `user:${userId}`, null, `deleted=${deleted.length}`);
868
+ }
869
+ return {
870
+ deleted,
871
+ kept
872
+ };
873
+ }
874
+ async downloadRecoveryKey(userId) {
875
+ const unlocked = this.requireReady();
876
+ const t = this.now();
877
+ await this.deps.repo.putKey({
878
+ ...unlocked.wrap,
879
+ recoveryDownloadedAt: t
880
+ });
881
+ this.unlock = {
882
+ ...unlocked,
883
+ wrap: {
884
+ ...unlocked.wrap,
885
+ recoveryDownloadedAt: t
886
+ }
887
+ };
888
+ await this.audit("download-recovery-key", `user:${userId}`, null, `source=${unlocked.source.kind}`);
889
+ return {
890
+ key: encodeKeyMaterial(unlocked.kek),
891
+ fingerprint: shortFingerprint(unlocked.fingerprint),
892
+ keySource: unlocked.source
893
+ };
894
+ }
895
+ /** See `keychain-admin.rotateMasterKey`. */
896
+ async rotateMasterKey(userId) {
897
+ const unlocked = this.requireReady();
898
+ const primary = (await this.deps.candidates()).find((c) => c.primary);
899
+ if (primary === void 0) throw new Error("keychain: no primary key source is configured");
900
+ let newKek;
901
+ if (unlocked.rotationPending && primary.source.kind !== unlocked.source.kind) {
902
+ const loaded = await primary.load();
903
+ if (loaded.kind !== "loaded") throw new Error(`keychain: the configured ${primary.source.kind} key could not be loaded`);
904
+ newKek = loaded.key;
905
+ } else if (primary.source.kind === "default-file") {
906
+ newKek = generateKey();
907
+ await writeDefaultKeyFile(this.deps.dataDir, newKek, {
908
+ replace: true,
909
+ nowMs: this.now()
910
+ });
911
+ } else throw new Error(`keychain: the ${primary.source.kind} key is already in use. Put the new key at its source, set the old one as keychain.previousKeyFile, restart, then rotate.`);
912
+ const fingerprint = kekFingerprint(newKek);
913
+ if (constantTimeEquals(fingerprint, unlocked.fingerprint)) throw new Error("keychain: the new master key is the one already in use");
914
+ const wrap = {
915
+ wrapId: randomUUID(),
916
+ keyId: unlocked.keyId,
917
+ wrappedDek: wrapDek(newKek, unlocked.dek, unlocked.keyId),
918
+ kekFingerprint: fingerprint,
919
+ kekSource: primary.source.kind,
920
+ createdAt: this.now(),
921
+ state: "active",
922
+ recoveryDownloadedAt: null
923
+ };
924
+ await this.deps.repo.putKey(wrap);
925
+ for (const old of await this.deps.repo.listKeys()) if (old.wrapId !== wrap.wrapId && old.state === "active") await this.deps.repo.putKey({
926
+ ...old,
927
+ state: "retired"
928
+ });
929
+ this.unlock = {
930
+ state: "ready",
931
+ dek: unlocked.dek,
932
+ keyId: unlocked.keyId,
933
+ kek: newKek,
934
+ fingerprint,
935
+ source: primary.source,
936
+ wrap,
937
+ rotationPending: false
938
+ };
939
+ this.configuredSource = primary.source;
940
+ await this.audit("rotate-master-key", `user:${userId}`, null, `source=${primary.source.kind}`);
941
+ return {
942
+ fingerprint: shortFingerprint(fingerprint),
943
+ keySource: primary.source
944
+ };
945
+ }
946
+ /** Delete retired wraps, and the default file's previous copies with them. */
947
+ async purgeRetiredKeys(userId) {
948
+ this.requireReady();
949
+ const retired = (await this.deps.repo.listKeys()).filter((w) => w.state === "retired");
950
+ for (const wrap of retired) await this.deps.repo.deleteKey(wrap.wrapId);
951
+ const dir = path$1.dirname(defaultKeyFilePath(this.deps.dataDir));
952
+ try {
953
+ for (const name of await promises.readdir(dir)) if (name.startsWith("master.key.prev-")) await promises.rm(path$1.join(dir, name), { force: true });
954
+ } catch {}
955
+ await this.audit("purge-retired-keys", `user:${userId}`, null, `purged=${retired.length}`);
956
+ return retired.length;
957
+ }
958
+ /** Lost-key recovery from Data → Secrets — see `keychain-admin.resetKeychain`. */
959
+ async resetKeychain(userId) {
960
+ const record = await this.resetAs(`user:${userId}`);
961
+ return {
962
+ archivedCollection: record.archivedCollection,
963
+ archived: record.archived
964
+ };
965
+ }
966
+ /**
967
+ * Start over with a new master key and a new data key.
968
+ *
969
+ * 1. Refuse BEFORE touching anything when the configured primary source
970
+ * cannot give a key (a configured file that is missing or unreadable, a
971
+ * desktop key that did not arrive): archiving the values and then staying
972
+ * locked would lose them for nothing. The default file is always usable —
973
+ * the reset writes a new one (the old one is kept as `master.key.prev-*`).
974
+ * 2. Archive every value AND every wrapped data key — the archive stays
975
+ * openable if the lost master key turns up.
976
+ * 3. New data key under the new master key ({@link firstBoot}).
977
+ * 4. Clear the system-held markers (none remain since D857). The
978
+ * session signing key has no marker; it now resolves `missing`, and
979
+ * `local-auth` generates a new one (everyone signs in again).
980
+ * 5. One `delete` event per archived ref, so every keeper reloads.
981
+ * 6. A reset record for the Secrets page, and an audit row.
982
+ */
983
+ async resetAs(actor) {
984
+ const t = this.now();
985
+ const lockedReason = this.unlock.state === "locked" ? this.unlock.reason : null;
986
+ const primary = (await this.deps.candidates()).find((c) => c.primary) ?? null;
987
+ await this.assertResettable(primary);
988
+ const archiveName = `keychain:secrets-orphaned-${t}`;
989
+ const keysArchiveName = `keychain:keys-orphaned-${t}`;
990
+ const archivedRows = await this.deps.repo.listSecrets();
991
+ const archivedKeys = await this.deps.repo.archiveAllKeys(keysArchiveName);
992
+ const archived = await this.deps.repo.archiveAllSecrets(archiveName);
993
+ for (const wrap of await this.deps.repo.listKeys()) await this.deps.repo.deleteKey(wrap.wrapId);
994
+ if (primary?.source.kind === "default-file") {
995
+ if ((await primary.load()).kind !== "absent") await writeDefaultKeyFile(this.deps.dataDir, generateKey(), {
996
+ replace: true,
997
+ nowMs: t
998
+ });
999
+ }
1000
+ this.unlock = await this.firstBoot(primary);
1001
+ const clearedSettingsKeys = await this.deps.repo.clearSystemSettingsKeys(SYSTEM_SECRET_SETTINGS_KEYS);
1002
+ for (const row of archivedRows) this.deps.events.emit({
1003
+ ref: row.ref,
1004
+ owner: row.owner,
1005
+ version: null,
1006
+ change: "delete"
1007
+ });
1008
+ const record = {
1009
+ id: randomUUID(),
1010
+ at: t,
1011
+ actor,
1012
+ lockedReason,
1013
+ archived,
1014
+ archivedCollection: archived > 0 ? archiveName : null,
1015
+ archivedKeysCollection: archivedKeys > 0 ? keysArchiveName : null,
1016
+ clearedSettingsKeys,
1017
+ acknowledgedAt: null
1018
+ };
1019
+ await this.deps.repo.putReset(record);
1020
+ await this.audit("reset", actor, null, `archived=${archived} lockedReason=${lockedReason ?? "none"} cleared=${clearedSettingsKeys.join(",") || "none"}`);
1021
+ return record;
1022
+ }
1023
+ /** Throws {@link KeychainResetRefusedError} when no new master key could be had. */
1024
+ async assertResettable(primary) {
1025
+ if (primary === null) throw new KeychainResetRefusedError("no key source is configured");
1026
+ if (primary.source.kind === "default-file") return;
1027
+ const loaded = await primary.load();
1028
+ if (loaded.kind === "loaded") return;
1029
+ const where = primary.source.path ?? primary.source.kind;
1030
+ throw new KeychainResetRefusedError(loaded.kind === "absent" ? `the configured master key ${where} does not exist — put a new 32-byte key there (or remove keychain.keyFile to use the default file) first` : `the configured master key ${where} cannot be read (${loaded.error})`);
1031
+ }
1032
+ /** What the last reset left to re-enter (see `keychain-admin.resetReport`). */
1033
+ async resetReport() {
1034
+ const reset = await this.deps.repo.latestReset();
1035
+ if (reset === null || reset.archivedCollection === null) return {
1036
+ reset,
1037
+ pendingReentry: []
1038
+ };
1039
+ const archived = await this.deps.repo.listArchivedSecrets(reset.archivedCollection);
1040
+ const live = await this.deps.repo.getSecrets(archived.map((r) => r.ref));
1041
+ return {
1042
+ reset,
1043
+ pendingReentry: archived.filter((r) => !live.has(r.ref) && !PROCESS_HELD_SECRET_REFS.has(r.ref)).map(toMeta)
1044
+ };
1045
+ }
1046
+ async acknowledgeReset(userId) {
1047
+ const reset = await this.deps.repo.latestReset();
1048
+ if (reset === null || reset.acknowledgedAt !== null) return { acknowledged: false };
1049
+ await this.deps.repo.putReset({
1050
+ ...reset,
1051
+ acknowledgedAt: this.now()
1052
+ });
1053
+ await this.audit("acknowledge-reset", `user:${userId}`, null, `reset=${reset.id}`);
1054
+ return { acknowledged: true };
1055
+ }
1056
+ async audit(action, actor, ref, detail) {
1057
+ try {
1058
+ await this.deps.repo.appendAudit({
1059
+ id: randomUUID(),
1060
+ at: this.now(),
1061
+ action,
1062
+ actor,
1063
+ ref,
1064
+ detail
1065
+ });
1066
+ } catch (err) {
1067
+ this.deps.logger.warn("keychain audit row not written", {
1068
+ action,
1069
+ ref,
1070
+ error: errMsg(err)
1071
+ });
1072
+ }
1073
+ }
1074
+ /** Daily ring prune, driven by the addon's timer. */
1075
+ async pruneAudit() {
1076
+ await this.deps.repo.pruneAudit(this.now());
1077
+ }
1078
+ };
1079
+ function toMeta(row) {
1080
+ return {
1081
+ ref: row.ref,
1082
+ owner: row.owner,
1083
+ scope: row.scope,
1084
+ fieldPath: row.fieldPath,
1085
+ version: row.version,
1086
+ createdAt: row.createdAt,
1087
+ updatedAt: row.updatedAt,
1088
+ updatedBy: row.updatedBy,
1089
+ lastReadAt: row.lastReadAt
1090
+ };
1091
+ }
1092
+ function actorOfAddon(caller) {
1093
+ return caller === null ? "system" : `addon:${normalizeSecretOwner(caller)}`;
1094
+ }
1095
+ function errMsg(err) {
1096
+ return err instanceof Error ? err.message : String(err);
1097
+ }
1098
+ EventCategory.KeychainChanged;
1099
+ var KeychainAuditBodySchema = KeychainAuditEntrySchema.omit({
1100
+ id: true,
1101
+ at: true
1102
+ });
1103
+ var KeychainResetBodySchema = KeychainResetRecordSchema.omit({
1104
+ id: true,
1105
+ at: true
1106
+ });
1107
+ var _keychainRecordKinds = defineRecordKinds({
1108
+ audit: {
1109
+ schema: KeychainAuditBodySchema,
1110
+ class: "audit",
1111
+ writeTrigger: "one row per write / delete / rotation / reveal / recovery download",
1112
+ device: "none",
1113
+ at: "required",
1114
+ indexes: [{
1115
+ name: "audit_at",
1116
+ fields: ["at"]
1117
+ }],
1118
+ retention: {
1119
+ owner: "keychain",
1120
+ reason: "90 days and at most 20_000 rows, pruned at boot and daily"
1121
+ }
1122
+ },
1123
+ resets: {
1124
+ schema: KeychainResetBodySchema,
1125
+ class: "config",
1126
+ writeTrigger: "one row per keychain reset (Data → Secrets, or the RESET_KEYCHAIN trigger file); acknowledgeReset stamps acknowledgedAt",
1127
+ device: "none",
1128
+ at: "required",
1129
+ retention: { none: "a handful of rows over a hub life; they name archive tables a reset left behind" }
1130
+ }
1131
+ });
1132
+ var keychainRecordKinds = _keychainRecordKinds;
1133
+ _keychainRecordKinds.audit;
1134
+ _keychainRecordKinds.resets;
1135
+ //#endregion
1136
+ //#region src/builtins/keychain/keychain-store.ts
1137
+ var import_read_all_rows = require_read_all_rows();
1138
+ /**
1139
+ * @durable class=config owner=keychain
1140
+ * write="`keychain.put` upserts one row per ref; `delete` removes it"
1141
+ * retention="none — a row lives until its owner deletes the ref or the
1142
+ * operator deletes it as an orphan. Losing the table loses every secret
1143
+ * value; the settings blobs then point at refs that resolve `missing`."
1144
+ */
1145
+ var KEYCHAIN_SECRETS_COLLECTION = "keychain:secrets";
1146
+ /**
1147
+ * @durable class=config owner=keychain
1148
+ * write="first boot writes the wrapped data key; `rotateMasterKey` adds a
1149
+ * wrap and retires the previous one"
1150
+ * retention="retired wraps until `purgeRetiredKeys`. Losing the table with
1151
+ * the secrets intact makes every value undecryptable."
1152
+ */
1153
+ var KEYCHAIN_KEYS_COLLECTION = "keychain:keys";
1154
+ /**
1155
+ * @durable class=audit owner=keychain
1156
+ * write="one row per write / delete / rotation / reveal / recovery download"
1157
+ * retention="90 days and at most 20 000 rows, pruned at boot and daily"
1158
+ */
1159
+ var KEYCHAIN_AUDIT_COLLECTION = "keychain:audit";
1160
+ /**
1161
+ * @durable class=config owner=keychain
1162
+ * write="one row per keychain reset (Data → Secrets, or the RESET_KEYCHAIN
1163
+ * trigger file); `acknowledgeReset` stamps `acknowledgedAt`"
1164
+ * retention="none — a handful of rows over a hub's life; they name the
1165
+ * archive tables a reset left behind"
1166
+ */
1167
+ var KEYCHAIN_RESETS_COLLECTION = "keychain:resets";
1168
+ var AUDIT_RETENTION_MS = 2160 * 60 * 6e4;
1169
+ var AUDIT_MAX_ROWS = 2e4;
1170
+ var SECRET_COLUMNS = [
1171
+ {
1172
+ name: "ref",
1173
+ type: "TEXT",
1174
+ primaryKey: true,
1175
+ notNull: true
1176
+ },
1177
+ {
1178
+ name: "owner",
1179
+ type: "TEXT",
1180
+ notNull: true
1181
+ },
1182
+ {
1183
+ name: "scope",
1184
+ type: "TEXT",
1185
+ notNull: true
1186
+ },
1187
+ {
1188
+ name: "fieldPath",
1189
+ type: "TEXT",
1190
+ notNull: true
1191
+ },
1192
+ {
1193
+ name: "ciphertext",
1194
+ type: "TEXT",
1195
+ notNull: true
1196
+ },
1197
+ {
1198
+ name: "keyId",
1199
+ type: "TEXT",
1200
+ notNull: true
1201
+ },
1202
+ {
1203
+ name: "version",
1204
+ type: "INTEGER",
1205
+ notNull: true
1206
+ },
1207
+ {
1208
+ name: "createdAt",
1209
+ type: "INTEGER",
1210
+ notNull: true
1211
+ },
1212
+ {
1213
+ name: "updatedAt",
1214
+ type: "INTEGER",
1215
+ notNull: true
1216
+ },
1217
+ {
1218
+ name: "updatedBy",
1219
+ type: "TEXT",
1220
+ notNull: true
1221
+ },
1222
+ {
1223
+ name: "lastReadAt",
1224
+ type: "INTEGER"
1225
+ }
1226
+ ];
1227
+ var KEY_COLUMNS = [
1228
+ {
1229
+ name: "wrapId",
1230
+ type: "TEXT",
1231
+ primaryKey: true,
1232
+ notNull: true
1233
+ },
1234
+ {
1235
+ name: "keyId",
1236
+ type: "TEXT",
1237
+ notNull: true
1238
+ },
1239
+ {
1240
+ name: "wrappedDek",
1241
+ type: "TEXT",
1242
+ notNull: true
1243
+ },
1244
+ {
1245
+ name: "kekFingerprint",
1246
+ type: "TEXT",
1247
+ notNull: true
1248
+ },
1249
+ {
1250
+ name: "kekSource",
1251
+ type: "TEXT",
1252
+ notNull: true
1253
+ },
1254
+ {
1255
+ name: "createdAt",
1256
+ type: "INTEGER",
1257
+ notNull: true
1258
+ },
1259
+ {
1260
+ name: "state",
1261
+ type: "TEXT",
1262
+ notNull: true
1263
+ },
1264
+ {
1265
+ name: "recoveryDownloadedAt",
1266
+ type: "INTEGER"
1267
+ }
1268
+ ];
1269
+ var RESET_COLUMNS = [
1270
+ {
1271
+ name: "id",
1272
+ type: "TEXT",
1273
+ primaryKey: true,
1274
+ notNull: true
1275
+ },
1276
+ {
1277
+ name: "at",
1278
+ type: "INTEGER",
1279
+ notNull: true
1280
+ },
1281
+ {
1282
+ name: "actor",
1283
+ type: "TEXT",
1284
+ notNull: true
1285
+ },
1286
+ {
1287
+ name: "lockedReason",
1288
+ type: "TEXT"
1289
+ },
1290
+ {
1291
+ name: "archived",
1292
+ type: "INTEGER",
1293
+ notNull: true
1294
+ },
1295
+ {
1296
+ name: "archivedCollection",
1297
+ type: "TEXT"
1298
+ },
1299
+ {
1300
+ name: "archivedKeysCollection",
1301
+ type: "TEXT"
1302
+ },
1303
+ {
1304
+ name: "clearedSettingsKeys",
1305
+ type: "TEXT",
1306
+ notNull: true
1307
+ },
1308
+ {
1309
+ name: "acknowledgedAt",
1310
+ type: "INTEGER"
1311
+ }
1312
+ ];
1313
+ var AUDIT_COLUMNS = [
1314
+ {
1315
+ name: "id",
1316
+ type: "TEXT",
1317
+ primaryKey: true,
1318
+ notNull: true
1319
+ },
1320
+ {
1321
+ name: "at",
1322
+ type: "INTEGER",
1323
+ notNull: true
1324
+ },
1325
+ {
1326
+ name: "action",
1327
+ type: "TEXT",
1328
+ notNull: true
1329
+ },
1330
+ {
1331
+ name: "actor",
1332
+ type: "TEXT",
1333
+ notNull: true
1334
+ },
1335
+ {
1336
+ name: "ref",
1337
+ type: "TEXT"
1338
+ },
1339
+ {
1340
+ name: "detail",
1341
+ type: "TEXT"
1342
+ }
1343
+ ];
1344
+ function str(data, key) {
1345
+ const v = data[key];
1346
+ return typeof v === "string" ? v : "";
1347
+ }
1348
+ function num(data, key) {
1349
+ const v = data[key];
1350
+ return typeof v === "number" ? v : Number(v ?? 0);
1351
+ }
1352
+ function numOrNull(data, key) {
1353
+ const v = data[key];
1354
+ if (v === null || v === void 0) return null;
1355
+ const n = typeof v === "number" ? v : Number(v);
1356
+ return Number.isFinite(n) ? n : null;
1357
+ }
1358
+ function strOrNull(data, key) {
1359
+ const v = data[key];
1360
+ return typeof v === "string" ? v : null;
1361
+ }
1362
+ function toSecretRow(id, data) {
1363
+ return {
1364
+ ref: str(data, "ref") || id,
1365
+ owner: str(data, "owner"),
1366
+ scope: str(data, "scope"),
1367
+ fieldPath: str(data, "fieldPath"),
1368
+ ciphertext: str(data, "ciphertext"),
1369
+ keyId: str(data, "keyId"),
1370
+ version: num(data, "version"),
1371
+ createdAt: num(data, "createdAt"),
1372
+ updatedAt: num(data, "updatedAt"),
1373
+ updatedBy: str(data, "updatedBy"),
1374
+ lastReadAt: numOrNull(data, "lastReadAt")
1375
+ };
1376
+ }
1377
+ function toKeyRow(id, data) {
1378
+ const state = str(data, "state");
1379
+ return {
1380
+ wrapId: str(data, "wrapId") || id,
1381
+ keyId: str(data, "keyId"),
1382
+ wrappedDek: str(data, "wrappedDek"),
1383
+ kekFingerprint: str(data, "kekFingerprint"),
1384
+ kekSource: str(data, "kekSource"),
1385
+ createdAt: num(data, "createdAt"),
1386
+ state: state === "retired" ? "retired" : "active",
1387
+ recoveryDownloadedAt: numOrNull(data, "recoveryDownloadedAt")
1388
+ };
1389
+ }
1390
+ var AUDIT_ACTIONS = new Set([
1391
+ "put",
1392
+ "delete",
1393
+ "reveal",
1394
+ "rotate-master-key",
1395
+ "purge-retired-keys",
1396
+ "download-recovery-key",
1397
+ "delete-orphans",
1398
+ "reset",
1399
+ "acknowledge-reset",
1400
+ "initialize"
1401
+ ]);
1402
+ function isAuditAction(value) {
1403
+ return AUDIT_ACTIONS.has(value);
1404
+ }
1405
+ function toAuditRow(id, data) {
1406
+ const action = str(data, "action");
1407
+ if (!isAuditAction(action)) return null;
1408
+ return {
1409
+ id: str(data, "id") || id,
1410
+ at: num(data, "at"),
1411
+ action,
1412
+ actor: str(data, "actor"),
1413
+ ref: strOrNull(data, "ref"),
1414
+ detail: strOrNull(data, "detail")
1415
+ };
1416
+ }
1417
+ function toResetRecord(id, data) {
1418
+ const cleared = data["clearedSettingsKeys"];
1419
+ let keys = [];
1420
+ if (typeof cleared === "string") try {
1421
+ const parsed = JSON.parse(cleared);
1422
+ if (Array.isArray(parsed)) keys = parsed.filter((k) => typeof k === "string");
1423
+ } catch {
1424
+ keys = [];
1425
+ }
1426
+ else if (Array.isArray(cleared)) keys = cleared.filter((k) => typeof k === "string");
1427
+ return {
1428
+ id: str(data, "id") || id,
1429
+ at: num(data, "at"),
1430
+ actor: str(data, "actor"),
1431
+ lockedReason: strOrNull(data, "lockedReason"),
1432
+ archived: num(data, "archived"),
1433
+ archivedCollection: strOrNull(data, "archivedCollection"),
1434
+ archivedKeysCollection: strOrNull(data, "archivedKeysCollection"),
1435
+ clearedSettingsKeys: keys,
1436
+ acknowledgedAt: numOrNull(data, "acknowledgedAt")
1437
+ };
1438
+ }
1439
+ /** Rows one listing page asks for — the table is small, but a read names its bound. */
1440
+ var PAGE = 1e3;
1441
+ var KeychainRepository = class {
1442
+ door;
1443
+ records;
1444
+ constructor(door, records) {
1445
+ this.door = door;
1446
+ this.records = records;
1447
+ }
1448
+ static recordStoresOf(records) {
1449
+ return {
1450
+ audit: records.kind(keychainRecordKinds.audit),
1451
+ resets: records.kind(keychainRecordKinds.resets)
1452
+ };
1453
+ }
1454
+ async init() {
1455
+ await this.door.declareCollection({
1456
+ collection: KEYCHAIN_SECRETS_COLLECTION,
1457
+ columns: SECRET_COLUMNS,
1458
+ indexes: [{
1459
+ name: "idx_keychain_secrets_owner",
1460
+ columns: ["owner"]
1461
+ }]
1462
+ });
1463
+ await this.door.declareCollection({
1464
+ collection: KEYCHAIN_KEYS_COLLECTION,
1465
+ columns: KEY_COLUMNS
1466
+ });
1467
+ if (this.records === void 0) {
1468
+ await this.door.declareCollection({
1469
+ collection: KEYCHAIN_RESETS_COLLECTION,
1470
+ columns: RESET_COLUMNS
1471
+ });
1472
+ await this.door.declareCollection({
1473
+ collection: KEYCHAIN_AUDIT_COLLECTION,
1474
+ columns: AUDIT_COLUMNS,
1475
+ indexes: [{
1476
+ name: "idx_keychain_audit_at",
1477
+ columns: ["at"]
1478
+ }]
1479
+ });
1480
+ }
1481
+ }
1482
+ async getSecrets(refs) {
1483
+ const out = /* @__PURE__ */ new Map();
1484
+ if (refs.length === 0) return out;
1485
+ const rows = await this.door.query({
1486
+ collection: KEYCHAIN_SECRETS_COLLECTION,
1487
+ filter: {
1488
+ whereIn: { ref: [...refs] },
1489
+ limit: refs.length
1490
+ }
1491
+ });
1492
+ for (const row of rows) {
1493
+ const parsed = toSecretRow(row.id, row.data);
1494
+ out.set(parsed.ref, parsed);
1495
+ }
1496
+ return out;
1497
+ }
1498
+ /** Every row, paged by primary key. */
1499
+ async listSecrets() {
1500
+ const out = [];
1501
+ for (let offset = 0;; offset += PAGE) {
1502
+ const rows = await this.door.query({
1503
+ collection: KEYCHAIN_SECRETS_COLLECTION,
1504
+ filter: {
1505
+ orderBy: {
1506
+ field: "ref",
1507
+ direction: "asc"
1508
+ },
1509
+ limit: PAGE,
1510
+ offset
1511
+ }
1512
+ });
1513
+ for (const row of rows) out.push(toSecretRow(row.id, row.data));
1514
+ if (rows.length < PAGE) return out;
1515
+ }
1516
+ }
1517
+ async putSecret(row) {
1518
+ await this.door.set({
1519
+ collection: KEYCHAIN_SECRETS_COLLECTION,
1520
+ key: row.ref,
1521
+ value: row
1522
+ });
1523
+ }
1524
+ async deleteSecrets(refs) {
1525
+ if (refs.length === 0) return 0;
1526
+ return (await this.door.deleteWhere({
1527
+ collection: KEYCHAIN_SECRETS_COLLECTION,
1528
+ filter: { whereIn: { ref: [...refs] } }
1529
+ })).deleted;
1530
+ }
1531
+ async listKeys() {
1532
+ return (await this.door.query({
1533
+ collection: KEYCHAIN_KEYS_COLLECTION,
1534
+ filter: {
1535
+ orderBy: {
1536
+ field: "createdAt",
1537
+ direction: "asc"
1538
+ },
1539
+ limit: PAGE
1540
+ }
1541
+ })).map((row) => toKeyRow(row.id, row.data));
1542
+ }
1543
+ async putKey(row) {
1544
+ await this.door.set({
1545
+ collection: KEYCHAIN_KEYS_COLLECTION,
1546
+ key: row.wrapId,
1547
+ value: row
1548
+ });
1549
+ }
1550
+ async deleteKey(wrapId) {
1551
+ await this.door.delete({
1552
+ collection: KEYCHAIN_KEYS_COLLECTION,
1553
+ key: wrapId
1554
+ });
1555
+ }
1556
+ async appendAudit(row) {
1557
+ const kind = this.records?.audit;
1558
+ if (kind !== void 0) {
1559
+ const { id, at, action, actor, ref, detail } = row;
1560
+ await kind.put({
1561
+ id,
1562
+ at,
1563
+ data: {
1564
+ action,
1565
+ actor,
1566
+ ref,
1567
+ detail
1568
+ }
1569
+ });
1570
+ return;
1571
+ }
1572
+ await this.door.set({
1573
+ collection: KEYCHAIN_AUDIT_COLLECTION,
1574
+ key: row.id,
1575
+ value: row
1576
+ });
1577
+ }
1578
+ async listAudit(limit) {
1579
+ const kind = this.records?.audit;
1580
+ if (kind !== void 0) {
1581
+ const rows = await (0, import_read_all_rows.readAllRows)(kind);
1582
+ rows.sort((a, b) => (b.at ?? 0) - (a.at ?? 0));
1583
+ const out = [];
1584
+ for (const row of rows.slice(0, limit)) {
1585
+ const parsed = toAuditRow(row.id, {
1586
+ ...row.data,
1587
+ at: row.at ?? 0
1588
+ });
1589
+ if (parsed !== null) out.push(parsed);
1590
+ }
1591
+ return out;
1592
+ }
1593
+ const rows = await this.door.query({
1594
+ collection: KEYCHAIN_AUDIT_COLLECTION,
1595
+ filter: {
1596
+ orderBy: {
1597
+ field: "at",
1598
+ direction: "desc"
1599
+ },
1600
+ limit
1601
+ }
1602
+ });
1603
+ const out = [];
1604
+ for (const row of rows) {
1605
+ const parsed = toAuditRow(row.id, row.data);
1606
+ if (parsed !== null) out.push(parsed);
1607
+ }
1608
+ return out;
1609
+ }
1610
+ /** Drop audit rows older than the retention window, then beyond the row bound. */
1611
+ async pruneAudit(nowMs) {
1612
+ const kind = this.records?.audit;
1613
+ if (kind !== void 0) {
1614
+ const ageCutoff = nowMs - AUDIT_RETENTION_MS;
1615
+ let deleted = 0;
1616
+ for (const row of await (0, import_read_all_rows.readAllRows)(kind)) if ((row.at ?? 0) <= ageCutoff) {
1617
+ await kind.delete(row.id);
1618
+ deleted += 1;
1619
+ }
1620
+ const remaining = await (0, import_read_all_rows.readAllRows)(kind);
1621
+ remaining.sort((a, b) => (b.at ?? 0) - (a.at ?? 0));
1622
+ for (const row of remaining.slice(AUDIT_MAX_ROWS)) {
1623
+ await kind.delete(row.id);
1624
+ deleted += 1;
1625
+ }
1626
+ return deleted;
1627
+ }
1628
+ const aged = await this.door.deleteWhere({
1629
+ collection: KEYCHAIN_AUDIT_COLLECTION,
1630
+ filter: { whereBetween: { at: [0, nowMs - AUDIT_RETENTION_MS] } }
1631
+ });
1632
+ const cutoff = (await this.door.query({
1633
+ collection: KEYCHAIN_AUDIT_COLLECTION,
1634
+ filter: {
1635
+ orderBy: {
1636
+ field: "at",
1637
+ direction: "desc"
1638
+ },
1639
+ limit: 1,
1640
+ offset: AUDIT_MAX_ROWS
1641
+ }
1642
+ }))[0]?.data["at"];
1643
+ if (typeof cutoff !== "number") return aged.deleted;
1644
+ const bounded = await this.door.deleteWhere({
1645
+ collection: KEYCHAIN_AUDIT_COLLECTION,
1646
+ filter: { whereBetween: { at: [0, cutoff] } }
1647
+ });
1648
+ return aged.deleted + bounded.deleted;
1649
+ }
1650
+ /**
1651
+ * Lost-key recovery: copy every secret row into `archive`, then empty the
1652
+ * live table. The archive is ciphertext under a key nobody has — it exists
1653
+ * so a key that turns up later can still recover it.
1654
+ */
1655
+ async archiveAllSecrets(archive) {
1656
+ const rows = await this.listSecrets();
1657
+ if (rows.length === 0) return 0;
1658
+ await this.door.declareCollection({
1659
+ collection: archive,
1660
+ columns: SECRET_COLUMNS
1661
+ });
1662
+ for (const row of rows) await this.door.set({
1663
+ collection: archive,
1664
+ key: row.ref,
1665
+ value: row
1666
+ });
1667
+ await this.deleteSecrets(rows.map((r) => r.ref));
1668
+ return rows.length;
1669
+ }
1670
+ /**
1671
+ * Copy every wrapped data key into `archive` (the companion of
1672
+ * {@link archiveAllSecrets}): without the wrap, an archived value could
1673
+ * never be opened again even if the lost master key turned up.
1674
+ */
1675
+ async archiveAllKeys(archive) {
1676
+ const rows = await this.listKeys();
1677
+ if (rows.length === 0) return 0;
1678
+ await this.door.declareCollection({
1679
+ collection: archive,
1680
+ columns: KEY_COLUMNS
1681
+ });
1682
+ for (const row of rows) await this.door.set({
1683
+ collection: archive,
1684
+ key: row.wrapId,
1685
+ value: row
1686
+ });
1687
+ return rows.length;
1688
+ }
1689
+ /** Every secret row of an archive table (ciphertext — never decrypted here). */
1690
+ async listArchivedSecrets(archive) {
1691
+ const out = [];
1692
+ for (let offset = 0;; offset += PAGE) {
1693
+ const rows = await this.door.query({
1694
+ collection: archive,
1695
+ filter: {
1696
+ orderBy: {
1697
+ field: "ref",
1698
+ direction: "asc"
1699
+ },
1700
+ limit: PAGE,
1701
+ offset
1702
+ }
1703
+ });
1704
+ for (const row of rows) out.push(toSecretRow(row.id, row.data));
1705
+ if (rows.length < PAGE) return out;
1706
+ }
1707
+ }
1708
+ /**
1709
+ * Delete the `system-settings` rows among `keys` that exist; returns the
1710
+ * keys it deleted. A read that fails throws — never "nothing was there".
1711
+ */
1712
+ async clearSystemSettingsKeys(keys) {
1713
+ const cleared = [];
1714
+ for (const key of keys) {
1715
+ const current = await this.door.get({
1716
+ collection: "system-settings",
1717
+ key
1718
+ });
1719
+ if (current === void 0 || current === null) continue;
1720
+ await this.door.delete({
1721
+ collection: "system-settings",
1722
+ key
1723
+ });
1724
+ cleared.push(key);
1725
+ }
1726
+ return cleared;
1727
+ }
1728
+ async putReset(record) {
1729
+ const kind = this.records?.resets;
1730
+ if (kind !== void 0) {
1731
+ const { id, at, actor, lockedReason, archived, archivedCollection, archivedKeysCollection, clearedSettingsKeys, acknowledgedAt } = record;
1732
+ await kind.put({
1733
+ id,
1734
+ at,
1735
+ data: {
1736
+ actor,
1737
+ lockedReason,
1738
+ archived,
1739
+ archivedCollection,
1740
+ archivedKeysCollection,
1741
+ clearedSettingsKeys: [...clearedSettingsKeys],
1742
+ acknowledgedAt
1743
+ }
1744
+ });
1745
+ return;
1746
+ }
1747
+ await this.door.set({
1748
+ collection: KEYCHAIN_RESETS_COLLECTION,
1749
+ key: record.id,
1750
+ value: {
1751
+ ...record,
1752
+ clearedSettingsKeys: JSON.stringify(record.clearedSettingsKeys)
1753
+ }
1754
+ });
1755
+ }
1756
+ async latestReset() {
1757
+ const kind = this.records?.resets;
1758
+ if (kind !== void 0) {
1759
+ const rows = await (0, import_read_all_rows.readAllRows)(kind);
1760
+ rows.sort((a, b) => (b.at ?? 0) - (a.at ?? 0));
1761
+ const row = rows[0];
1762
+ if (row === void 0) return null;
1763
+ return toResetRecord(row.id, {
1764
+ ...row.data,
1765
+ at: row.at ?? 0
1766
+ });
1767
+ }
1768
+ const row = (await this.door.query({
1769
+ collection: KEYCHAIN_RESETS_COLLECTION,
1770
+ filter: {
1771
+ orderBy: {
1772
+ field: "at",
1773
+ direction: "desc"
1774
+ },
1775
+ limit: 1
1776
+ }
1777
+ }))[0];
1778
+ return row === void 0 ? null : toResetRecord(row.id, row.data);
1779
+ }
1780
+ };
1781
+ //#endregion
1782
+ //#region src/builtins/keychain/keychain-usage.ts
1783
+ /**
1784
+ * Is a stored value still pointed at? — the orphan check behind System →
1785
+ * Secrets.
1786
+ *
1787
+ * A ref says where its marker lives (owner + scope), so the check reads THAT
1788
+ * blob and looks for `{"$secret": ref}` anywhere in it. Three answers, and the
1789
+ * third is the important one: `unknown` when the blob could not be read, or
1790
+ * when the scope's store is not one this check knows how to read. A read that
1791
+ * did not answer is never "orphan" — and only an orphan can be deleted from
1792
+ * the page (D315: absence is claimed only from a query that answered).
1793
+ */
1794
+ /** Every `$secret` ref inside a value, at any depth. */
1795
+ function collectMarkerRefs(value, out = /* @__PURE__ */ new Set()) {
1796
+ if (Array.isArray(value)) {
1797
+ for (const item of value) collectMarkerRefs(item, out);
1798
+ return out;
1799
+ }
1800
+ if (value === null || typeof value !== "object") {
1801
+ if (typeof value === "string" && value.includes("\"$secret\"")) try {
1802
+ collectMarkerRefs(JSON.parse(value), out);
1803
+ } catch {}
1804
+ return out;
1805
+ }
1806
+ const ref = Reflect.get(value, "$secret");
1807
+ if (typeof ref === "string") out.add(ref);
1808
+ for (const child of Object.values(value)) collectMarkerRefs(child, out);
1809
+ return out;
1810
+ }
1811
+ /** Rows under an ASCII id prefix, one bounded page; `null` when the page filled. */
1812
+ async function prefixRows(door, collection, prefix) {
1813
+ const hi = `${prefix.slice(0, -1)}${String.fromCharCode(prefix.charCodeAt(prefix.length - 1) + 1)}`;
1814
+ const LIMIT = 2e3;
1815
+ const rows = await door.query({
1816
+ collection,
1817
+ filter: {
1818
+ whereBetween: { id: [prefix, hi] },
1819
+ limit: LIMIT
1820
+ }
1821
+ });
1822
+ if (rows.length >= LIMIT) return null;
1823
+ return rows.filter((r) => r.id.startsWith(prefix)).map((r) => r.data);
1824
+ }
1825
+ /** The blobs that may hold the marker of a ref in `scope`; `null` = cannot tell. */
1826
+ async function blobsFor(door, owner, scope) {
1827
+ if (owner === "system" && scope.kind === "global") return [[...PROCESS_HELD_SECRET_REFS].map((ref) => ({
1828
+ $secret: ref,
1829
+ v: 1
1830
+ })), ...await Promise.all(SYSTEM_SECRET_SETTINGS_KEYS.map((key) => door.get({
1831
+ collection: "system-settings",
1832
+ key
1833
+ })))];
1834
+ switch (scope.kind) {
1835
+ case "global":
1836
+ case "node": {
1837
+ const legacyBlob = await door.get({
1838
+ namespace: owner,
1839
+ collection: "addon-settings",
1840
+ key: "root"
1841
+ });
1842
+ const rows = await prefixRows(door, "addon-settings", `${owner}.`);
1843
+ return rows === null ? null : [legacyBlob, ...rows];
1844
+ }
1845
+ case "device": {
1846
+ const legacyBlob = await door.get({
1847
+ namespace: owner,
1848
+ collection: "addon-devices",
1849
+ key: String(scope.deviceId)
1850
+ });
1851
+ const own = await prefixRows(door, "addon-device-settings", `${owner}:${scope.deviceId}.`);
1852
+ const connection = owner === "device-manager" ? [] : await prefixRows(door, "addon-device-settings", `device-manager:${scope.deviceId}.`);
1853
+ if (own === null || connection === null) return null;
1854
+ return [
1855
+ legacyBlob,
1856
+ ...own,
1857
+ ...connection
1858
+ ];
1859
+ }
1860
+ case "integration": return (await door.query({
1861
+ collection: "integration_settings",
1862
+ filter: {
1863
+ where: { integration_id: scope.integrationId },
1864
+ limit: 2e3
1865
+ }
1866
+ })).map((r) => r.data);
1867
+ case "row": return [await door.get({
1868
+ collection: scope.collection,
1869
+ key: scope.rowId
1870
+ })];
1871
+ }
1872
+ }
1873
+ /** Build the usage check the service uses. */
1874
+ function createKeychainUsageCheck(door) {
1875
+ return async (rows) => {
1876
+ const out = /* @__PURE__ */ new Map();
1877
+ const groups = /* @__PURE__ */ new Map();
1878
+ for (const row of rows) {
1879
+ const parts = parseSecretRef(row.ref);
1880
+ if (parts === null) {
1881
+ out.set(row.ref, "unknown");
1882
+ continue;
1883
+ }
1884
+ const key = `${parts.owner}|${row.scope}`;
1885
+ const group = groups.get(key) ?? {
1886
+ owner: parts.owner,
1887
+ scope: parts.scope,
1888
+ refs: []
1889
+ };
1890
+ group.refs.push(row.ref);
1891
+ groups.set(key, group);
1892
+ }
1893
+ for (const group of groups.values()) {
1894
+ let blobs;
1895
+ try {
1896
+ blobs = await blobsFor(door, group.owner, group.scope);
1897
+ } catch {
1898
+ blobs = null;
1899
+ }
1900
+ if (blobs === null) {
1901
+ for (const ref of group.refs) out.set(ref, "unknown");
1902
+ continue;
1903
+ }
1904
+ const seen = /* @__PURE__ */ new Set();
1905
+ for (const blob of blobs) collectMarkerRefs(blob, seen);
1906
+ for (const ref of group.refs) out.set(ref, seen.has(ref) ? "in-use" : "orphan");
1907
+ }
1908
+ return out;
1909
+ };
1910
+ }
1911
+ //#endregion
1912
+ //#region src/builtins/keychain/keychain.addon.ts
1913
+ /**
1914
+ * `keychain` — hub-only, in-process builtin that owns every secret value
1915
+ * (D787). Boots in the infrastructure pass, right after the settings door, so
1916
+ * a forked addon's first `resolveConfig` already finds it.
1917
+ *
1918
+ * Registers two caps from one service:
1919
+ * - `keychain` (internal): the owner's door — put / resolve / delete /
1920
+ * listMeta / getState, owner-checked against the caller the transport
1921
+ * stamped (`callerAddonId`, never in the input schema);
1922
+ * - `keychain-admin`: Data → Secrets — status, list, audit, reveal,
1923
+ * orphans, rotation, recovery key, reset (and its report). Every method
1924
+ * admin; those that change or hand out material take the session's user
1925
+ * for the audit.
1926
+ *
1927
+ * At boot, right after the unlock, the one-shot `<dataDir>/.keychain/RESET_KEYCHAIN`
1928
+ * trigger file is honoured (see `keychain-reset-trigger.ts`) — the only way
1929
+ * back into a hub whose master key is lost.
1930
+ *
1931
+ * It does not run on agents: an agent's Phase 1 drops `keychain` from its infra
1932
+ * list (`server/backend/src/agent/agent-infra-capabilities.ts`), and an agent
1933
+ * addon reaches it through `$hub-cap-fwd` like every other hub cap. Until
1934
+ * 2026-10-08 agents DID boot it — their store door forwards to the hub, so an
1935
+ * agent wrote the hub's `keychain:keys` row with a key file on its own disk.
1936
+ * Booting first, it left the hub locked `key-missing`.
1937
+ */
1938
+ var DAY_MS = 1440 * 6e4;
1939
+ /** The caller the transport stamped (or an in-process caller stated). */
1940
+ function callerOf(input) {
1941
+ if (input === null || typeof input !== "object") return null;
1942
+ const raw = Reflect.get(input, "callerAddonId");
1943
+ return typeof raw === "string" && raw.length > 0 ? raw : null;
1944
+ }
1945
+ function readKeyConfig(section) {
1946
+ const keyFile = section["keyFile"];
1947
+ const previousKeyFile = section["previousKeyFile"];
1948
+ return {
1949
+ keyFile: typeof keyFile === "string" && keyFile.length > 0 ? keyFile : void 0,
1950
+ previousKeyFile: typeof previousKeyFile === "string" && previousKeyFile.length > 0 ? previousKeyFile : void 0
1951
+ };
1952
+ }
1953
+ var KeychainAddon = class extends BaseAddon {
1954
+ id = "keychain";
1955
+ pruneTimer = null;
1956
+ constructor() {
1957
+ super({});
1958
+ }
1959
+ async onInitialize() {
1960
+ const ctx = this.ctx;
1961
+ const store = ctx.api.settingsStore;
1962
+ const door = {
1963
+ declareCollection: (input) => store.declareCollection.mutate(input),
1964
+ get: (input) => store.get.query(input),
1965
+ set: (input) => store.set.mutate(input),
1966
+ query: (input) => store.query.query(input),
1967
+ delete: (input) => store.delete.mutate(input),
1968
+ deleteWhere: (input) => store.deleteWhere.mutate(input)
1969
+ };
1970
+ const dataDir = ctx.nodeDataDir;
1971
+ const runnerIdOf = ctx.kernel.runnerIdForAddon ?? ((addonId) => addonId);
1972
+ const serviceLogger = {
1973
+ info: (message, meta) => ctx.logger.info(message, meta ? { meta } : void 0),
1974
+ warn: (message, meta) => ctx.logger.warn(message, meta ? { meta } : void 0),
1975
+ error: (message, meta) => ctx.logger.error(message, meta ? { meta } : void 0)
1976
+ };
1977
+ const records = ctx.records;
1978
+ if (records !== void 0) await records.declare(keychainRecordKinds);
1979
+ const service = new KeychainService({
1980
+ repo: new KeychainRepository(door, records !== void 0 ? KeychainRepository.recordStoresOf(records) : void 0),
1981
+ candidates: async () => {
1982
+ return buildKeySourceCandidates({
1983
+ config: readKeyConfig(await ctx.settings?.getSection("keychain") ?? {}),
1984
+ dataDir
1985
+ });
1986
+ },
1987
+ dataDir,
1988
+ events: { emit: (payload) => {
1989
+ ctx.eventBus.emit({
1990
+ id: `keychain-${payload.ref}-${Date.now()}`,
1991
+ timestamp: /* @__PURE__ */ new Date(),
1992
+ source: {
1993
+ type: "addon",
1994
+ id: "keychain"
1995
+ },
1996
+ category: EventCategory.KeychainChanged,
1997
+ data: payload
1998
+ });
1999
+ } },
2000
+ logger: serviceLogger,
2001
+ runnerIdOf,
2002
+ usage: createKeychainUsageCheck(door)
2003
+ });
2004
+ await service.init();
2005
+ await applyKeychainResetTrigger({
2006
+ service,
2007
+ dataDir,
2008
+ logger: serviceLogger
2009
+ });
2010
+ this.pruneTimer = setInterval(() => {
2011
+ service.pruneAudit().catch((err) => {
2012
+ ctx.logger.warn("keychain audit prune failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
2013
+ });
2014
+ }, DAY_MS);
2015
+ this.pruneTimer.unref?.();
2016
+ return [{
2017
+ capability: keychainCapability,
2018
+ provider: {
2019
+ put: (input) => service.put(callerOf(input), input.ref, input.value),
2020
+ resolve: (input) => service.resolve(callerOf(input), input.refs),
2021
+ delete: async (input) => ({ deleted: await service.delete(callerOf(input), input.refs) }),
2022
+ deleteDeviceScope: async (input) => ({ refs: await service.deleteDeviceScope(callerOf(input), input.deviceId) }),
2023
+ releaseRecordRefs: async (input) => ({ released: await service.releaseRecordRefs(callerOf(input), input.refs, input.onBehalfOf) }),
2024
+ listMeta: (input) => service.listMeta(callerOf(input)),
2025
+ getState: async () => service.getState()
2026
+ }
2027
+ }, {
2028
+ capability: keychainAdminCapability,
2029
+ provider: {
2030
+ status: () => service.status(),
2031
+ listSecrets: () => service.listSecrets(),
2032
+ listAudit: (input) => service.listAudit(input.limit ?? 100),
2033
+ reveal: (input) => service.reveal(input.caller.userId, input.ref),
2034
+ setSystemSecret: (input) => service.setSystemSecret(input.caller.userId, input.name, input.value),
2035
+ importSecret: (input) => service.importSecret(input.caller.userId, input.ref, input.value),
2036
+ deleteOrphans: (input) => service.deleteOrphans(input.caller.userId, input.refs),
2037
+ rotateMasterKey: (input) => service.rotateMasterKey(input.caller.userId),
2038
+ purgeRetiredKeys: async (input) => ({ purged: await service.purgeRetiredKeys(input.caller.userId) }),
2039
+ downloadRecoveryKey: (input) => service.downloadRecoveryKey(input.caller.userId),
2040
+ resetKeychain: (input) => service.resetKeychain(input.caller.userId),
2041
+ resetReport: () => service.resetReport(),
2042
+ acknowledgeReset: (input) => service.acknowledgeReset(input.caller.userId)
2043
+ }
2044
+ }];
2045
+ }
2046
+ async onShutdown() {
2047
+ if (this.pruneTimer !== null) clearInterval(this.pruneTimer);
2048
+ this.pruneTimer = null;
2049
+ }
2050
+ };
2051
+ //#endregion
2052
+ export { KeychainAddon, KeychainAddon as default };