@camstack/server 1.2.594 → 1.2.596

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 (255) hide show
  1. package/dist/addon-root-inventory.js +50 -11
  2. package/dist/agent/addon-scan.js +44 -6
  3. package/dist/agent/agent-addon-runtime.js +8 -3
  4. package/dist/agent/agent-addon-updates.js +52 -12
  5. package/dist/agent/agent-cap-dispatch-service.js +5 -3
  6. package/dist/agent/agent-config.js +42 -7
  7. package/dist/agent/agent-deploy-swap.js +41 -5
  8. package/dist/agent/agent-group-runner.js +47 -8
  9. package/dist/agent/agent-http-auth.js +22 -10
  10. package/dist/agent/agent-http.js +113 -64
  11. package/dist/agent/agent-hub-addon-update.js +16 -10
  12. package/dist/agent/agent-hub-registration.js +7 -4
  13. package/dist/agent/agent-infra-capabilities.js +9 -5
  14. package/dist/agent/agent-json-file.js +42 -5
  15. package/dist/agent/agent-mesh-gate.js +8 -5
  16. package/dist/agent/agent-node-certificates.js +28 -25
  17. package/dist/agent/agent-pairing-local.js +47 -10
  18. package/dist/agent/agent-pairing-routes.js +20 -16
  19. package/dist/agent/agent-pairing-store.js +58 -18
  20. package/dist/agent/agent-reconnect.js +4 -1
  21. package/dist/agent/agent-service.js +71 -35
  22. package/dist/agent/agent-sniffing-listener.js +48 -11
  23. package/dist/agent/agent-undeploy.js +41 -5
  24. package/dist/agent/agent-update-routes.js +19 -14
  25. package/dist/agent/agent-update-service.js +80 -38
  26. package/dist/agent/apply-model-distribution.js +4 -1
  27. package/dist/agent/apply-stage-dev-uploads.js +9 -6
  28. package/dist/agent/derive-hub-url.js +8 -3
  29. package/dist/agent/fetch-bundle-from-hub.js +9 -6
  30. package/dist/agent/hubs-found.js +43 -6
  31. package/dist/agent/infra-boot-guard.js +4 -1
  32. package/dist/agent/infra-boot-plan.js +6 -2
  33. package/dist/agent/main.js +183 -148
  34. package/dist/agent/register-agent-cap-dispatch.js +6 -3
  35. package/dist/agent/serial-queue.js +7 -2
  36. package/dist/agent-status-page.js +4 -1
  37. package/dist/api/addon-upload.js +61 -22
  38. package/dist/api/agent-addon-delivery.js +11 -6
  39. package/dist/api/auth-whoami.js +4 -1
  40. package/dist/api/backup-download-pump.js +9 -5
  41. package/dist/api/backup-download.js +10 -7
  42. package/dist/api/core/addon-settings.router.js +19 -16
  43. package/dist/api/core/agent-pairing.router.js +79 -76
  44. package/dist/api/core/agents.router.js +24 -21
  45. package/dist/api/core/auth-admin-tokens.procedures.js +52 -48
  46. package/dist/api/core/auth-device-cert.procedures.js +67 -62
  47. package/dist/api/core/auth-limits.js +25 -16
  48. package/dist/api/core/auth-reauth.procedures.js +37 -32
  49. package/dist/api/core/auth-revoke-credentials.procedures.js +26 -22
  50. package/dist/api/core/auth-sessions.procedures.js +56 -52
  51. package/dist/api/core/auth.router.js +304 -300
  52. package/dist/api/core/cap-providers.js +121 -74
  53. package/dist/api/core/capabilities.router.js +37 -34
  54. package/dist/api/core/capability-preference-writes.js +17 -10
  55. package/dist/api/core/certificates.router.js +109 -106
  56. package/dist/api/core/cluster-nodes.router.js +18 -15
  57. package/dist/api/core/collection-preference.js +6 -2
  58. package/dist/api/core/event-bus-proxy.router.js +37 -34
  59. package/dist/api/core/failure-contributions.js +8 -4
  60. package/dist/api/core/hwaccel.router.js +20 -17
  61. package/dist/api/core/integration-secrets.js +12 -8
  62. package/dist/api/core/lifecycle-job-runner.js +49 -13
  63. package/dist/api/core/live-events.router.js +32 -29
  64. package/dist/api/core/load-contributions.js +8 -4
  65. package/dist/api/core/logging-settings.js +43 -30
  66. package/dist/api/core/logs.router.js +43 -40
  67. package/dist/api/core/notifications.router.js +18 -15
  68. package/dist/api/core/public-event-filter.js +8 -4
  69. package/dist/api/core/repl.router.js +21 -18
  70. package/dist/api/core/request-census-settings.js +16 -11
  71. package/dist/api/core/server-management.provider.js +4 -1
  72. package/dist/api/core/server-name.js +17 -9
  73. package/dist/api/core/site-location.js +24 -16
  74. package/dist/api/core/stream-probe.router.js +24 -21
  75. package/dist/api/core/system-events.router.js +26 -23
  76. package/dist/api/cors/cors-policy.js +29 -20
  77. package/dist/api/cors/register-cors-policy.js +14 -9
  78. package/dist/api/deploy-stage-registry.js +10 -6
  79. package/dist/api/dev-uploads-bundle.js +50 -12
  80. package/dist/api/health/adaptive-probe.routes.js +13 -9
  81. package/dist/api/health/health.routes.js +13 -8
  82. package/dist/api/hub-cluster-url.js +9 -3
  83. package/dist/api/model-distributor.js +50 -12
  84. package/dist/api/oauth2/consent-page.js +13 -10
  85. package/dist/api/oauth2/oauth2-routes.js +25 -17
  86. package/dist/api/oauth2/private-host.js +4 -1
  87. package/dist/api/server-upload-propagate.js +51 -15
  88. package/dist/api/server-upload.js +50 -13
  89. package/dist/api/sse-no-compression.js +4 -1
  90. package/dist/api/static/frame-policy.js +9 -4
  91. package/dist/api/static/precompressed-asset.js +57 -15
  92. package/dist/api/static/spa-mount.js +47 -8
  93. package/dist/api/static/spa-static.js +12 -5
  94. package/dist/api/tarball-manifest.js +44 -7
  95. package/dist/api/trpc/cap-mount-helpers.js +12 -7
  96. package/dist/api/trpc/cap-route-error-formatter.js +13 -10
  97. package/dist/api/trpc/cap-router-runtime.js +51 -40
  98. package/dist/api/trpc/client-ip.js +20 -9
  99. package/dist/api/trpc/core-cap-bridge.js +42 -32
  100. package/dist/api/trpc/device-collection-dispatch.js +27 -23
  101. package/dist/api/trpc/device-config-secret-redaction.js +40 -24
  102. package/dist/api/trpc/generated-cap-mounts.js +225 -219
  103. package/dist/api/trpc/generated-cap-routers.js +5167 -4852
  104. package/dist/api/trpc/http-request-census-hook.js +11 -8
  105. package/dist/api/trpc/http-request-census.js +41 -34
  106. package/dist/api/trpc/http-request-census.singleton.js +8 -4
  107. package/dist/api/trpc/localized-schema-paths.js +4 -1
  108. package/dist/api/trpc/principal-visibility.js +22 -14
  109. package/dist/api/trpc/remote-addon-update-grant.js +4 -1
  110. package/dist/api/trpc/scope-access.js +15 -10
  111. package/dist/api/trpc/server-provided-caps.js +7 -3
  112. package/dist/api/trpc/share-view-access.js +14 -6
  113. package/dist/api/trpc/trpc-error-device-tags.js +6 -3
  114. package/dist/api/trpc/trpc-error-principal.js +6 -2
  115. package/dist/api/trpc/trpc.context.js +25 -20
  116. package/dist/api/trpc/trpc.middleware.js +46 -38
  117. package/dist/api/trpc/trpc.router.js +99 -58
  118. package/dist/api/trpc/user-error.js +8 -5
  119. package/dist/api/trpc/ws-request-census.js +24 -17
  120. package/dist/api/trpc/ws-slow-consumer-guard.js +16 -11
  121. package/dist/api/upload-auth.js +9 -5
  122. package/dist/auth/addon-route-jwt-gate.js +7 -4
  123. package/dist/auth/addon-route-share-gate.js +12 -7
  124. package/dist/auth/app-confirm-page.js +22 -17
  125. package/dist/auth/app-confirm-routes.js +31 -26
  126. package/dist/auth/app-confirmations.js +44 -7
  127. package/dist/auth/app-page-shell.js +30 -17
  128. package/dist/auth/app-page-strings.js +17 -11
  129. package/dist/auth/app-passkey-page.js +21 -16
  130. package/dist/auth/app-passkey-routes.js +41 -37
  131. package/dist/auth/app-refused-route.js +18 -13
  132. package/dist/auth/auth-network-policy.js +15 -11
  133. package/dist/auth/auth-provider-gate.js +9 -4
  134. package/dist/auth/auth-rate-limit.js +7 -3
  135. package/dist/auth/client-address.js +9 -6
  136. package/dist/auth/device-enroll-proofs.js +43 -6
  137. package/dist/auth/external-link-intents.js +7 -3
  138. package/dist/auth/hub-sessions.js +12 -6
  139. package/dist/auth/native-link-completions.js +11 -7
  140. package/dist/auth/native-return.js +13 -9
  141. package/dist/auth/passkey-provider.js +32 -26
  142. package/dist/auth/second-factors.js +10 -6
  143. package/dist/auth/session-connections.js +12 -6
  144. package/dist/auth/session-cookie.js +23 -12
  145. package/dist/auth/session-lifetimes.js +12 -8
  146. package/dist/auth/session-mint.js +11 -4
  147. package/dist/auth/sso-finish-app.js +16 -13
  148. package/dist/auth/sso-finish-deps.js +27 -21
  149. package/dist/auth/sso-finish.js +38 -28
  150. package/dist/auth/sso-routes.js +25 -22
  151. package/dist/auth/used-bridge-ids.js +5 -1
  152. package/dist/boot/boot-config.js +55 -16
  153. package/dist/boot/init-sequence.js +4 -1
  154. package/dist/boot/integration-id-backfill.js +8 -3
  155. package/dist/boot/platform-keychain-key.js +42 -5
  156. package/dist/boot/post-boot.service.js +18 -14
  157. package/dist/boot/reconcile-lifecycle-jobs.js +6 -3
  158. package/dist/boot/retired-public-url-env.js +8 -4
  159. package/dist/bootstrap-packages.js +4 -1
  160. package/dist/closure-node-modules.js +38 -2
  161. package/dist/core/addon/addon-call-gateway.js +5 -1
  162. package/dist/core/addon/addon-package.service.js +123 -83
  163. package/dist/core/addon/addon-process-view.js +6 -2
  164. package/dist/core/addon/addon-realign-plan.js +4 -1
  165. package/dist/core/addon/addon-registry.service.js +187 -146
  166. package/dist/core/addon/addon-row-manifest.js +4 -1
  167. package/dist/core/addon/addon-search.service.js +7 -3
  168. package/dist/core/addon/addon-settings-provider.js +3 -1
  169. package/dist/core/addon/addon-uninstall.js +11 -4
  170. package/dist/core/addon/addon.tokens.js +5 -2
  171. package/dist/core/addon/device-meta-mirror.js +13 -8
  172. package/dist/core/addon/forked-custom-actions.js +11 -6
  173. package/dist/core/addon/integration-visibility.js +6 -3
  174. package/dist/core/addon/materialize-route-path.js +4 -1
  175. package/dist/core/addon/package-dir-utils.js +45 -8
  176. package/dist/core/addon/prune-misplaced-addons.js +43 -5
  177. package/dist/core/addon/runner-convergence.js +4 -1
  178. package/dist/core/addon/runner-serialization.js +4 -1
  179. package/dist/core/addon/runner-spawn-fanout.js +8 -3
  180. package/dist/core/addon/settings-door-wiring.js +8 -5
  181. package/dist/core/addon/single-flight-refresh.js +4 -1
  182. package/dist/core/addon-bridge/addon-bridge.service.js +44 -7
  183. package/dist/core/addon-pages/addon-pages.service.js +40 -3
  184. package/dist/core/addon-widgets/addon-widgets.service.js +42 -4
  185. package/dist/core/agent/agent-addon-backfill.js +17 -9
  186. package/dist/core/agent/agent-delivery-ledger.js +7 -3
  187. package/dist/core/agent/agent-liveness-event.js +6 -2
  188. package/dist/core/agent/agent-pairing-http.js +45 -41
  189. package/dist/core/agent/agent-registry.service.js +89 -50
  190. package/dist/core/agent/cluster-node-history-mirror.js +7 -3
  191. package/dist/core/agent/cluster-node-history-store.js +35 -31
  192. package/dist/core/agent/hub-agent-pairing.js +5 -1
  193. package/dist/core/agent/node-certificates-client.js +6 -3
  194. package/dist/core/agent/node-directory.js +4 -1
  195. package/dist/core/app-links/well-known-app-links.js +6 -2
  196. package/dist/core/auth/auth.service.js +8 -3
  197. package/dist/core/auth/handoff-code.service.js +49 -11
  198. package/dist/core/auth/record-kinds.js +19 -16
  199. package/dist/core/auth/share-token.service.js +79 -42
  200. package/dist/core/capability/capability.service.js +5 -1
  201. package/dist/core/config/config.schema.js +6 -1
  202. package/dist/core/config/config.service.js +6 -2
  203. package/dist/core/events/event-bus.service.js +7 -3
  204. package/dist/core/feature/feature.service.js +6 -2
  205. package/dist/core/lifecycle/lifecycle-runner.singleton.js +10 -5
  206. package/dist/core/lifecycle/lifecycle-state-machine.js +5 -1
  207. package/dist/core/logging/log-ring-buffer.js +5 -1
  208. package/dist/core/logging/logging.service.js +9 -5
  209. package/dist/core/logging/scoped-logger.js +5 -1
  210. package/dist/core/moleculer/agent-readiness-pull.js +4 -1
  211. package/dist/core/moleculer/agent-registration-request.js +7 -3
  212. package/dist/core/moleculer/cap-call-fn.js +7 -4
  213. package/dist/core/moleculer/cap-route-authority.js +8 -3
  214. package/dist/core/moleculer/hub-mesh-guard.js +9 -5
  215. package/dist/core/moleculer/moleculer.service.js +86 -79
  216. package/dist/core/network/network-quality.service.js +6 -2
  217. package/dist/core/notification/notification-wrapper.service.js +7 -3
  218. package/dist/core/notification/toast-wrapper.service.js +7 -3
  219. package/dist/core/provider/provider.tokens.js +4 -1
  220. package/dist/core/repl/repl-engine.service.js +8 -4
  221. package/dist/core/runner-health/runner-boot-check.js +15 -7
  222. package/dist/core/runner-health/update-preflight.js +14 -9
  223. package/dist/core/server-update/server-update.service.js +49 -12
  224. package/dist/core/server-update/system-apply-closure-patches.js +42 -6
  225. package/dist/core/server-update/system-ensure-prebuilds.js +6 -3
  226. package/dist/core/server-update/system-exec-npm.js +5 -2
  227. package/dist/core/storage/fs-storage-backend.js +5 -1
  228. package/dist/core/storage/storage-location-manager.js +5 -1
  229. package/dist/core/storage/storage.service.js +6 -2
  230. package/dist/core/streaming/ffmpeg-stream-info.js +8 -3
  231. package/dist/core/streaming/stream-probe.service.js +16 -12
  232. package/dist/core/streaming/ttl-cache.js +5 -1
  233. package/dist/core/topology/topology-emitter.service.js +23 -19
  234. package/dist/core/update-availability-emitter.js +7 -3
  235. package/dist/core/update-availability-store.js +45 -8
  236. package/dist/core/updates/agent-installed-packages.js +9 -5
  237. package/dist/core/updates/restart-marker.js +8 -3
  238. package/dist/core/updates/update-check-scheduler.js +18 -13
  239. package/dist/core/updates/wrapper-update-checker.js +7 -3
  240. package/dist/first-boot-addon-plan.js +6 -2
  241. package/dist/framework-nodepath.js +38 -2
  242. package/dist/i18n/request-lang.js +11 -7
  243. package/dist/launcher.js +65 -30
  244. package/dist/lifecycle-journal-path.js +38 -2
  245. package/dist/main.js +324 -286
  246. package/dist/manual-boot.js +156 -117
  247. package/dist/node-role.js +4 -1
  248. package/dist/package-inventory.js +48 -7
  249. package/dist/pending-restore.js +43 -7
  250. package/dist/single-copy-cleanup-runner.js +45 -9
  251. package/dist/single-copy-cleanup.js +15 -7
  252. package/dist/sqlite-restore.js +48 -9
  253. package/dist/starter.js +39 -4
  254. package/dist/ui-serving/lazy-ui-serving.js +39 -3
  255. package/package.json +7 -7
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * EventBus proxy router — allows forked workers to emit events to, and
3
4
  * read the recent-events registry of, the hub's EventBus via tRPC.
@@ -21,10 +22,12 @@
21
22
  *
22
23
  * Introduced in session 7 (EventBus wiring for forked addons).
23
24
  */
24
- import { z } from 'zod';
25
- import { adminProcedure, protectedProcedure, trpcRouter } from '../trpc/trpc.middleware.js';
26
- import { scopedEventVisibility } from '../trpc/principal-visibility.js';
27
- import { publicRecent } from './public-event-filter.js';
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.createEventBusProxyRouter = createEventBusProxyRouter;
27
+ const zod_1 = require("zod");
28
+ const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
29
+ const principal_visibility_js_1 = require("../trpc/principal-visibility.js");
30
+ const public_event_filter_js_1 = require("./public-event-filter.js");
28
31
  /**
29
32
  * Upper bound on the `getRecent` limit — kept in step with the hub's
30
33
  * `recent[]` ring-buffer size (`MAX_RECENT_EVENTS` in `event-bus-core.ts`).
@@ -32,15 +35,15 @@ import { publicRecent } from './public-event-filter.js';
32
35
  * not depend on the event-bus core internals.
33
36
  */
34
37
  const MAX_RECENT_EVENTS = 1000;
35
- const SystemEventInputSchema = z.object({
36
- id: z.string(),
37
- timestamp: z.string(), // ISO 8601 — converted to Date on emit
38
- source: z.object({
39
- type: z.string(),
40
- id: z.string(),
38
+ const SystemEventInputSchema = zod_1.z.object({
39
+ id: zod_1.z.string(),
40
+ timestamp: zod_1.z.string(), // ISO 8601 — converted to Date on emit
41
+ source: zod_1.z.object({
42
+ type: zod_1.z.string(),
43
+ id: zod_1.z.string(),
41
44
  }),
42
- category: z.string(),
43
- data: z.record(z.string(), z.unknown()),
45
+ category: zod_1.z.string(),
46
+ data: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
44
47
  });
45
48
  /**
46
49
  * `getRecent` input — mirrors `systemEvents.getRecent`'s category/limit
@@ -48,9 +51,9 @@ const SystemEventInputSchema = z.object({
48
51
  * can whitelist the categories it cares about server-side; `limit` is
49
52
  * capped at the hub's `recent[]` buffer size (`MAX_RECENT_EVENTS`).
50
53
  */
51
- const GetRecentInputSchema = z.object({
52
- category: z.union([z.string(), z.array(z.string())]).optional(),
53
- limit: z.number().int().min(1).max(MAX_RECENT_EVENTS).optional(),
54
+ const GetRecentInputSchema = zod_1.z.object({
55
+ category: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]).optional(),
56
+ limit: zod_1.z.number().int().min(1).max(MAX_RECENT_EVENTS).optional(),
54
57
  });
55
58
  /**
56
59
  * Serialized recent event — `timestamp` is an ISO-8601 string so the
@@ -58,18 +61,18 @@ const GetRecentInputSchema = z.object({
58
61
  * Callers reconstruct the `Date` on receipt. Mirrors the serialization
59
62
  * used by `systemEvents.getRecent`.
60
63
  */
61
- const RecentEventOutputSchema = z.object({
62
- id: z.string(),
63
- timestamp: z.string(),
64
- source: z.object({
65
- type: z.string(),
66
- id: z.union([z.string(), z.number()]),
67
- nodeId: z.string().optional(),
68
- addonId: z.string().optional(),
69
- deviceId: z.number().optional(),
64
+ const RecentEventOutputSchema = zod_1.z.object({
65
+ id: zod_1.z.string(),
66
+ timestamp: zod_1.z.string(),
67
+ source: zod_1.z.object({
68
+ type: zod_1.z.string(),
69
+ id: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]),
70
+ nodeId: zod_1.z.string().optional(),
71
+ addonId: zod_1.z.string().optional(),
72
+ deviceId: zod_1.z.number().optional(),
70
73
  }),
71
- category: z.string(),
72
- data: z.record(z.string(), z.unknown()),
74
+ category: zod_1.z.string(),
75
+ data: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
73
76
  });
74
77
  function serializeRecentEvent(e) {
75
78
  return {
@@ -86,17 +89,17 @@ function serializeRecentEvent(e) {
86
89
  data: e.data,
87
90
  };
88
91
  }
89
- export function createEventBusProxyRouter(eventBus) {
90
- return trpcRouter({
92
+ function createEventBusProxyRouter(eventBus) {
93
+ return (0, trpc_middleware_js_1.trpcRouter)({
91
94
  // ADMIN-ONLY. `emit` injects a fully-attributed SystemEvent onto the hub's
92
95
  // real EventBus — including a spoofable `source` (a fake `device`/`addon`
93
96
  // origin). Forked addons that legitimately emit reach this over the
94
97
  // trusted core-cap/UDS mesh, whose context is `createMeshTrpcContext`
95
98
  // (`isAdmin: true`), so gating it here withholds the surface from
96
99
  // non-admin HTTP/WS principals without blinding a worker.
97
- emit: adminProcedure
100
+ emit: trpc_middleware_js_1.adminProcedure
98
101
  .input(SystemEventInputSchema)
99
- .output(z.object({ ok: z.literal(true) }))
102
+ .output(zod_1.z.object({ ok: zod_1.z.literal(true) }))
100
103
  .mutation(({ input }) => {
101
104
  eventBus.emit({
102
105
  id: input.id,
@@ -107,9 +110,9 @@ export function createEventBusProxyRouter(eventBus) {
107
110
  });
108
111
  return { ok: true };
109
112
  }),
110
- getRecent: protectedProcedure
113
+ getRecent: trpc_middleware_js_1.protectedProcedure
111
114
  .input(GetRecentInputSchema)
112
- .output(z.array(RecentEventOutputSchema))
115
+ .output(zod_1.z.array(RecentEventOutputSchema))
113
116
  .query(({ input, ctx }) => {
114
117
  // This router is on the PUBLIC app router too, not only the worker
115
118
  // bridge: the same two projections as `systemEvents.getRecent` apply —
@@ -117,8 +120,8 @@ export function createEventBusProxyRouter(eventBus) {
117
120
  // scoped token reads only its devices (F0.5). A worker reaches this over
118
121
  // the mesh context (`isAdmin: true`), so it skips only the SCOPE
119
122
  // projection — owner-only categories are stripped for every caller.
120
- const keep = scopedEventVisibility(ctx.user, ctx.deviceScopeLookup);
121
- return publicRecent(eventBus, input.category !== undefined ? { category: input.category } : undefined, input.limit, keep).map(serializeRecentEvent);
123
+ const keep = (0, principal_visibility_js_1.scopedEventVisibility)(ctx.user, ctx.deviceScopeLookup);
124
+ return (0, public_event_filter_js_1.publicRecent)(eventBus, input.category !== undefined ? { category: input.category } : undefined, input.limit, keep).map(serializeRecentEvent);
122
125
  }),
123
126
  });
124
127
  }
@@ -1,9 +1,13 @@
1
- import { errMsg } from '@camstack/types';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EMPTY_FAILURE_CONTRIBUTION_PLANE = void 0;
4
+ exports.buildFailureContributionPlane = buildFailureContributionPlane;
5
+ const types_1 = require("@camstack/types");
2
6
  /** A plane that reaches nothing. The shape of a hub with no addon booted yet. */
3
- export const EMPTY_FAILURE_CONTRIBUTION_PLANE = {
7
+ exports.EMPTY_FAILURE_CONTRIBUTION_PLANE = {
4
8
  contributions: async () => [],
5
9
  };
6
- export function buildFailureContributionPlane(source, onProviderError) {
10
+ function buildFailureContributionPlane(source, onProviderError) {
7
11
  return {
8
12
  contributions: async () => {
9
13
  const out = [];
@@ -14,7 +18,7 @@ export function buildFailureContributionPlane(source, onProviderError) {
14
18
  }
15
19
  }
16
20
  catch (err) {
17
- onProviderError?.(addonId, errMsg(err));
21
+ onProviderError?.(addonId, (0, types_1.errMsg)(err));
18
22
  }
19
23
  }
20
24
  return out;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createHwAccelRouter = createHwAccelRouter;
1
4
  /**
2
5
  * Hwaccel router — fixed core API (not a capability).
3
6
  *
@@ -12,9 +15,9 @@
12
15
  * The tRPC input/output shapes are UNCHANGED for clients (`{prefer}` in,
13
16
  * `{preferred, rationale}` out) — no SDK break.
14
17
  */
15
- import { z } from 'zod';
16
- import { trpcRouter, adminProcedure } from '../trpc/trpc.middleware.js';
17
- const HwAccelBackendSchema = z.enum([
18
+ const zod_1 = require("zod");
19
+ const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
20
+ const HwAccelBackendSchema = zod_1.z.enum([
18
21
  'videotoolbox',
19
22
  'cuda',
20
23
  'nvdec',
@@ -26,17 +29,17 @@ const HwAccelBackendSchema = z.enum([
26
29
  'vdpau',
27
30
  'drm',
28
31
  ]);
29
- const HwAccelPreferSchema = z
30
- .union([HwAccelBackendSchema, z.literal('none')])
32
+ const HwAccelPreferSchema = zod_1.z
33
+ .union([HwAccelBackendSchema, zod_1.z.literal('none')])
31
34
  .nullable()
32
35
  .optional();
33
36
  // `preferred` is a plain string array (not the decode-backend enum) to match
34
37
  // the `platform-probe` cap's own resolution schema: the resolver only ever
35
38
  // emits decode backends, but a narrow enum would reject any future addition and
36
39
  // force a cast at the cap boundary.
37
- const HwAccelResolutionSchema = z.object({
38
- preferred: z.array(z.string()).readonly(),
39
- rationale: z.string(),
40
+ const HwAccelResolutionSchema = zod_1.z.object({
41
+ preferred: zod_1.z.array(zod_1.z.string()).readonly(),
42
+ rationale: zod_1.z.string(),
40
43
  });
41
44
  /**
42
45
  * Resolve hwaccel on a specific cluster node through the `platform-probe` cap
@@ -74,11 +77,11 @@ function listAvailableNodeIds(moleculer) {
74
77
  const withRegistry = broker;
75
78
  return withRegistry.registry.getNodeList({ onlyAvailable: true }).map((n) => n.id);
76
79
  }
77
- export function createHwAccelRouter(capabilityRegistry, moleculer) {
78
- return trpcRouter({
80
+ function createHwAccelRouter(capabilityRegistry, moleculer) {
81
+ return (0, trpc_middleware_js_1.trpcRouter)({
79
82
  /** Probe the current hub process via the local `platform-probe` singleton. */
80
- resolve: adminProcedure
81
- .input(z.object({ prefer: HwAccelPreferSchema }).optional())
83
+ resolve: trpc_middleware_js_1.adminProcedure
84
+ .input(zod_1.z.object({ prefer: HwAccelPreferSchema }).optional())
82
85
  .output(HwAccelResolutionSchema)
83
86
  .query(async ({ input }) => {
84
87
  const provider = capabilityRegistry?.getSingleton('platform-probe') ?? null;
@@ -88,16 +91,16 @@ export function createHwAccelRouter(capabilityRegistry, moleculer) {
88
91
  return provider.resolveHwAccel({ prefer: input?.prefer ?? null });
89
92
  }),
90
93
  /** Probe a specific node in the cluster — used by per-agent UI cards. */
91
- resolveForNode: adminProcedure
92
- .input(z.object({ nodeId: z.string(), prefer: HwAccelPreferSchema }))
94
+ resolveForNode: trpc_middleware_js_1.adminProcedure
95
+ .input(zod_1.z.object({ nodeId: zod_1.z.string(), prefer: HwAccelPreferSchema }))
93
96
  .output(HwAccelResolutionSchema)
94
97
  .query(async ({ input }) => {
95
98
  return resolveHwAccelOnNode(moleculer, input.nodeId, input.prefer ?? null);
96
99
  }),
97
100
  /** List every node currently reachable and the hwaccel each resolves to. */
98
- resolveAll: adminProcedure
99
- .output(z.array(z.object({
100
- nodeId: z.string(),
101
+ resolveAll: trpc_middleware_js_1.adminProcedure
102
+ .output(zod_1.z.array(zod_1.z.object({
103
+ nodeId: zod_1.z.string(),
101
104
  resolution: HwAccelResolutionSchema,
102
105
  })))
103
106
  .query(async () => {
@@ -1,3 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeIntegrationSettings = writeIntegrationSettings;
4
+ exports.readIntegrationSettings = readIntegrationSettings;
1
5
  /**
2
6
  * The integration-settings door of the keychain (D787). An integration's
3
7
  * settings (a Wyze password, a PetKit account password) live in the
@@ -13,20 +17,20 @@
13
17
  * resolve to values. READ, by anyone else (the admin form): markers become
14
18
  * their "set" views — the value never leaves the hub.
15
19
  */
16
- import { isSecretMarker, resolveSecretMarkers, secretTreeFromPaths, toSecretFieldView, transformSecretWrite, } from '@camstack/types';
17
- export async function writeIntegrationSettings(deps, input) {
20
+ const types_1 = require("@camstack/types");
21
+ async function writeIntegrationSettings(deps, input) {
18
22
  if (deps.secrets === null) {
19
23
  return deps.registry.setIntegrationSettings(input.integrationId, input.settings);
20
24
  }
21
25
  const stored = (await deps.registry.getIntegrationSettings(input.integrationId)) ?? {};
22
26
  const markerKeys = Object.entries(stored)
23
- .filter(([, v]) => isSecretMarker(v))
27
+ .filter(([, v]) => (0, types_1.isSecretMarker)(v))
24
28
  .map(([k]) => k);
25
- const tree = secretTreeFromPaths([...new Set([...input.secretKeys, ...markerKeys])]);
29
+ const tree = (0, types_1.secretTreeFromPaths)([...new Set([...input.secretKeys, ...markerKeys])]);
26
30
  if (tree.size === 0) {
27
31
  return deps.registry.setIntegrationSettings(input.integrationId, input.settings);
28
32
  }
29
- const result = await transformSecretWrite({
33
+ const result = await (0, types_1.transformSecretWrite)({
30
34
  tree,
31
35
  secrets: deps.secrets,
32
36
  patch: input.settings,
@@ -41,16 +45,16 @@ export async function writeIntegrationSettings(deps, input) {
41
45
  if (orphaned.length > 0)
42
46
  deps.onOrphaned?.(orphaned);
43
47
  }
44
- export async function readIntegrationSettings(deps, input) {
48
+ async function readIntegrationSettings(deps, input) {
45
49
  const stored = await deps.registry.getIntegrationSettings(input.integrationId);
46
50
  if (input.forOwner) {
47
51
  if (deps.secrets === null)
48
52
  return stored;
49
- return (await resolveSecretMarkers(stored, deps.secrets)).value;
53
+ return (await (0, types_1.resolveSecretMarkers)(stored, deps.secrets)).value;
50
54
  }
51
55
  const out = {};
52
56
  for (const [key, value] of Object.entries(stored)) {
53
- out[key] = isSecretMarker(value) ? toSecretFieldView(value) : value;
57
+ out[key] = (0, types_1.isSecretMarker)(value) ? (0, types_1.toSecretFieldView)(value) : value;
54
58
  }
55
59
  return out;
56
60
  }
@@ -1,8 +1,44 @@
1
- import * as path from 'node:path';
2
- import { randomUUID } from 'node:crypto';
3
- import { JobJournal, StagingArea, LifecycleJobEngine, } from '@camstack/system';
4
- import { SYSTEM_PACKAGE } from '../../core/addon/addon-package.service.js';
5
- import { lifecycleJobsDir } from '../../lifecycle-journal-path.js';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createLifecycleJobRunner = createLifecycleJobRunner;
37
+ const path = __importStar(require("node:path"));
38
+ const node_crypto_1 = require("node:crypto");
39
+ const system_1 = require("@camstack/system");
40
+ const addon_package_service_js_1 = require("../../core/addon/addon-package.service.js");
41
+ const lifecycle_journal_path_js_1 = require("../../lifecycle-journal-path.js");
6
42
  /**
7
43
  * Resolve a target's `TaskTarget` discriminant.
8
44
  * Explicit `target` field wins; otherwise auto-detected from package name.
@@ -10,7 +46,7 @@ import { lifecycleJobsDir } from '../../lifecycle-journal-path.js';
10
46
  function resolveTaskTarget(t) {
11
47
  if (t.target !== undefined)
12
48
  return t.target;
13
- return t.name === SYSTEM_PACKAGE ? 'framework' : 'addon';
49
+ return t.name === addon_package_service_js_1.SYSTEM_PACKAGE ? 'framework' : 'addon';
14
50
  }
15
51
  /**
16
52
  * Factory that wires `JobJournal` + `StagingArea` + `LifecycleJobEngine`
@@ -19,12 +55,12 @@ function resolveTaskTarget(t) {
19
55
  * Each server boot creates a fresh instance (journals persist on disk; the
20
56
  * in-memory running-set does not).
21
57
  */
22
- export function createLifecycleJobRunner(deps) {
58
+ function createLifecycleJobRunner(deps) {
23
59
  const nowFn = deps.now ?? (() => Date.now());
24
- const journalDir = lifecycleJobsDir(deps.dataDir);
60
+ const journalDir = (0, lifecycle_journal_path_js_1.lifecycleJobsDir)(deps.dataDir);
25
61
  const stagingDir = path.join(deps.dataDir, 'lifecycle', 'staging');
26
- const journal = new JobJournal(journalDir);
27
- const staging = new StagingArea(stagingDir, {
62
+ const journal = new system_1.JobJournal(journalDir);
63
+ const staging = new system_1.StagingArea(stagingDir, {
28
64
  fetchTarball: deps.fetchTarball,
29
65
  extract: deps.extract,
30
66
  });
@@ -33,7 +69,7 @@ export function createLifecycleJobRunner(deps) {
33
69
  // from a restart that interrupted a job before its per-job cleanup() ran —
34
70
  // these otherwise accumulate forever. Sweep them once, here.
35
71
  staging.sweepOrphans();
36
- const engine = new LifecycleJobEngine({
72
+ const engine = new system_1.LifecycleJobEngine({
37
73
  journal,
38
74
  staging,
39
75
  applyAddonUpdate: deps.applyAddonUpdate,
@@ -47,7 +83,7 @@ export function createLifecycleJobRunner(deps) {
47
83
  const runningJobs = new Set();
48
84
  return {
49
85
  async startJob(input) {
50
- const jobId = randomUUID();
86
+ const jobId = (0, node_crypto_1.randomUUID)();
51
87
  const job = {
52
88
  jobId,
53
89
  kind: input.kind,
@@ -57,7 +93,7 @@ export function createLifecycleJobRunner(deps) {
57
93
  schemaVersion: 1,
58
94
  state: 'running',
59
95
  tasks: input.targets.map((t) => ({
60
- taskId: randomUUID(),
96
+ taskId: (0, node_crypto_1.randomUUID)(),
61
97
  nodeId: 'hub',
62
98
  packageName: t.name,
63
99
  fromVersion: null,
@@ -1,28 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLiveEventsRouter = createLiveEventsRouter;
1
4
  /**
2
5
  * Live events router — fixed core API (not a capability).
3
6
  *
4
7
  * Higher-level live-subscription API consumed by the admin UI dashboard.
5
8
  * Wraps `EventBusService` with per-device permission enforcement.
6
9
  */
7
- import { z } from 'zod';
8
- import { trpcRouter, protectedProcedure, iterableSubscription } from '../trpc/trpc.middleware.js';
9
- import { liveEventInShareScope } from '../trpc/share-view-access.js';
10
- import { scopedEventVisibility } from '../trpc/principal-visibility.js';
11
- import { isPublicEvent, publicRecent } from './public-event-filter.js';
12
- import { userError } from '@camstack/types';
10
+ const zod_1 = require("zod");
11
+ const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
12
+ const share_view_access_js_1 = require("../trpc/share-view-access.js");
13
+ const principal_visibility_js_1 = require("../trpc/principal-visibility.js");
14
+ const public_event_filter_js_1 = require("./public-event-filter.js");
15
+ const types_1 = require("@camstack/types");
13
16
  // The pushed wire shape is `SystemEvent` from @camstack/types — the exact
14
17
  // type `EventBusService.subscribe` hands its handlers. It MUST be a type
15
18
  // exported from @camstack/types (not a local interface): the AppRouter
16
19
  // type expansion (`scripts/generate-api-types.ts`) prints subscription
17
20
  // output types by name, and a router-local name is unresolvable from the
18
21
  // generated `packages/types/src/generated/addon-api.ts`.
19
- export function createLiveEventsRouter(eb, ar) {
20
- return trpcRouter({
21
- recentSystemEvents: protectedProcedure
22
- .input(z
22
+ function createLiveEventsRouter(eb, ar) {
23
+ return (0, trpc_middleware_js_1.trpcRouter)({
24
+ recentSystemEvents: trpc_middleware_js_1.protectedProcedure
25
+ .input(zod_1.z
23
26
  .object({
24
- category: z.string().optional(),
25
- limit: z.number().optional(),
27
+ category: zod_1.z.string().optional(),
28
+ limit: zod_1.z.number().optional(),
26
29
  })
27
30
  .optional())
28
31
  .query(({ input, ctx }) => {
@@ -33,11 +36,11 @@ export function createLiveEventsRouter(eb, ar) {
33
36
  // view. (Share-view tokens cannot reach this method — not allowlisted.)
34
37
  // An owner-only category (D224) is not history anyone may read. Both
35
38
  // projections run BEFORE the limit (`publicRecent`).
36
- const keep = scopedEventVisibility(ctx.user, ctx.deviceScopeLookup);
37
- return publicRecent(eb, input?.category ? { category: input.category } : {}, input?.limit ?? 50, keep);
39
+ const keep = (0, principal_visibility_js_1.scopedEventVisibility)(ctx.user, ctx.deviceScopeLookup);
40
+ return (0, public_event_filter_js_1.publicRecent)(eb, input?.category ? { category: input.category } : {}, input?.limit ?? 50, keep);
38
41
  }),
39
- onEvent: protectedProcedure
40
- .input(z.object({ category: z.string().optional() }))
42
+ onEvent: trpc_middleware_js_1.protectedProcedure
43
+ .input(zod_1.z.object({ category: zod_1.z.string().optional() }))
41
44
  .subscription(({ input, ctx }) => {
42
45
  // Share-view principals get a device-filtered stream: only events
43
46
  // attributable to an in-scope device are pushed (fail closed —
@@ -47,8 +50,8 @@ export function createLiveEventsRouter(eb, ar) {
47
50
  // view (F0.5); admins and broad category-view operators are unfiltered.
48
51
  const scopedKeep = shareScope
49
52
  ? null
50
- : scopedEventVisibility(ctx.user, ctx.deviceScopeLookup);
51
- return iterableSubscription((push) => {
53
+ : (0, principal_visibility_js_1.scopedEventVisibility)(ctx.user, ctx.deviceScopeLookup);
54
+ return (0, trpc_middleware_js_1.iterableSubscription)((push) => {
52
55
  const filter = {};
53
56
  if (input.category)
54
57
  filter.category = input.category;
@@ -57,49 +60,49 @@ export function createLiveEventsRouter(eb, ar) {
57
60
  if (shareScope) {
58
61
  const allowedDeviceIds = new Set(shareScope.deviceIds);
59
62
  return eb.subscribe(filter, (evt) => {
60
- if (isPublicEvent(evt) && liveEventInShareScope(evt, allowedDeviceIds))
63
+ if ((0, public_event_filter_js_1.isPublicEvent)(evt) && (0, share_view_access_js_1.liveEventInShareScope)(evt, allowedDeviceIds))
61
64
  push(evt);
62
65
  });
63
66
  }
64
67
  if (scopedKeep) {
65
68
  return eb.subscribe(filter, (evt) => {
66
- if (isPublicEvent(evt) && scopedKeep(evt))
69
+ if ((0, public_event_filter_js_1.isPublicEvent)(evt) && scopedKeep(evt))
67
70
  push(evt);
68
71
  });
69
72
  }
70
73
  return eb.subscribe(filter, (evt) => {
71
- if (isPublicEvent(evt))
74
+ if ((0, public_event_filter_js_1.isPublicEvent)(evt))
72
75
  push(evt);
73
76
  });
74
77
  });
75
78
  }),
76
- onDeviceEvent: protectedProcedure
77
- .input(z.object({ deviceId: z.number() }))
79
+ onDeviceEvent: trpc_middleware_js_1.protectedProcedure
80
+ .input(zod_1.z.object({ deviceId: zod_1.z.number() }))
78
81
  .subscription(({ input, ctx }) => {
79
- return iterableSubscription((push) => {
82
+ return (0, trpc_middleware_js_1.iterableSubscription)((push) => {
80
83
  const deviceRegistry = ar.getDeviceRegistry();
81
84
  const device = deviceRegistry.getById(input.deviceId);
82
85
  if (!device)
83
- throw userError('device.not-found', { id: input.deviceId }, `Device id=${input.deviceId} not found`);
86
+ throw (0, types_1.userError)('device.not-found', { id: input.deviceId }, `Device id=${input.deviceId} not found`);
84
87
  // Permission check — new IDevice has no providerId; admin bypass only
85
88
  if (!ctx.user.isAdmin) {
86
89
  const ad = ctx.user.permissions?.allowedDevices;
87
90
  if (!ad)
88
- throw userError('auth.access-denied', undefined, 'Access denied');
91
+ throw (0, types_1.userError)('auth.access-denied', undefined, 'Access denied');
89
92
  // Find which addon owns this device to determine the provider key
90
93
  const ownerAddonId = deviceRegistry.getAddonId(input.deviceId);
91
94
  if (!ownerAddonId)
92
- throw userError('auth.access-denied', undefined, 'Access denied');
95
+ throw (0, types_1.userError)('auth.access-denied', undefined, 'Access denied');
93
96
  const pd = ad[ownerAddonId];
94
97
  // Permission lists are still keyed by stableId — that's the
95
98
  // external admin-facing identifier. Resolve the device's
96
99
  // stableId for the membership check.
97
100
  if (!pd || (pd !== '*' && !pd.includes(device.stableId))) {
98
- throw userError('auth.access-denied', undefined, 'Access denied');
101
+ throw (0, types_1.userError)('auth.access-denied', undefined, 'Access denied');
99
102
  }
100
103
  }
101
104
  return eb.subscribe({ source: { type: 'device', id: input.deviceId } }, (evt) => {
102
- if (isPublicEvent(evt))
105
+ if ((0, public_event_filter_js_1.isPublicEvent)(evt))
103
106
  push(evt);
104
107
  });
105
108
  });
@@ -1,9 +1,13 @@
1
- import { errMsg } from '@camstack/types';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EMPTY_LOAD_CONTRIBUTION_PLANE = void 0;
4
+ exports.buildLoadContributionPlane = buildLoadContributionPlane;
5
+ const types_1 = require("@camstack/types");
2
6
  /** A plane that reaches nothing. The shape of a hub with no addon booted yet. */
3
- export const EMPTY_LOAD_CONTRIBUTION_PLANE = {
7
+ exports.EMPTY_LOAD_CONTRIBUTION_PLANE = {
4
8
  contributions: async () => [],
5
9
  };
6
- export function buildLoadContributionPlane(source, onProviderError) {
10
+ function buildLoadContributionPlane(source, onProviderError) {
7
11
  return {
8
12
  contributions: async () => {
9
13
  const out = [];
@@ -14,7 +18,7 @@ export function buildLoadContributionPlane(source, onProviderError) {
14
18
  }
15
19
  }
16
20
  catch (err) {
17
- onProviderError?.(addonId, errMsg(err));
21
+ onProviderError?.(addonId, (0, types_1.errMsg)(err));
18
22
  }
19
23
  }
20
24
  return out;