@camstack/server 1.2.593 → 1.2.594

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