@camstack/server 1.2.592 → 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 +219 -221
  103. package/dist/api/trpc/generated-cap-routers.js +4878 -4726
  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 +254 -197
  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
  * Extracted, testable helper for registering the agent-side cap-dispatch
4
3
  * service with a Moleculer broker.
@@ -7,9 +6,7 @@
7
6
  * (undefined → no-op; defined → create service) can be exercised in a unit
8
7
  * test independently of the full bootstrap lifecycle.
9
8
  */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.registerAgentCapDispatch = registerAgentCapDispatch;
12
- const agent_cap_dispatch_service_js_1 = require("./agent-cap-dispatch-service.js");
9
+ import { createAgentCapDispatchService } from './agent-cap-dispatch-service.js';
13
10
  // ---------------------------------------------------------------------------
14
11
  // Exported helper
15
12
  // ---------------------------------------------------------------------------
@@ -30,8 +27,8 @@ const agent_cap_dispatch_service_js_1 = require("./agent-cap-dispatch-service.js
30
27
  * of failing with "no provider".
31
28
  * @param logger Optional scoped logger forwarded to the service.
32
29
  */
33
- function registerAgentCapDispatch(registrar, agentUdsRegistry, inProcessLookup, logger) {
30
+ export function registerAgentCapDispatch(registrar, agentUdsRegistry, inProcessLookup, logger) {
34
31
  if (agentUdsRegistry === undefined)
35
32
  return;
36
- registrar.createService((0, agent_cap_dispatch_service_js_1.createAgentCapDispatchService)(registrar.nodeID, agentUdsRegistry, inProcessLookup, logger));
33
+ registrar.createService(createAgentCapDispatchService(registrar.nodeID, agentUdsRegistry, inProcessLookup, logger));
37
34
  }
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SerialQueueTimeoutError = void 0;
4
- exports.createSerialQueue = createSerialQueue;
5
- class SerialQueueTimeoutError extends Error {
1
+ export class SerialQueueTimeoutError extends Error {
6
2
  deadlineMs;
7
3
  constructor(deadlineMs) {
8
4
  super(`the job did not finish within ${deadlineMs} ms and was abandoned`);
@@ -10,13 +6,12 @@ class SerialQueueTimeoutError extends Error {
10
6
  this.name = 'SerialQueueTimeoutError';
11
7
  }
12
8
  }
13
- exports.SerialQueueTimeoutError = SerialQueueTimeoutError;
14
9
  function defaultSetTimer(fn, ms) {
15
10
  const timer = setTimeout(fn, ms);
16
11
  timer.unref?.();
17
12
  return { cancel: () => clearTimeout(timer) };
18
13
  }
19
- function createSerialQueue(job, options = {}) {
14
+ export function createSerialQueue(job, options = {}) {
20
15
  let tail = Promise.resolve();
21
16
  const setTimer = options.setTimer ?? defaultSetTimer;
22
17
  const guarded = () => {
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderAgentStatusPage = renderAgentStatusPage;
4
1
  function formatUptime(seconds) {
5
2
  const days = Math.floor(seconds / 86400);
6
3
  const hours = Math.floor((seconds % 86400) / 3600);
@@ -25,7 +22,7 @@ function escapeHtml(str) {
25
22
  * No React, no build system. Pure HTML + inline CSS.
26
23
  * Designed for local debugging only.
27
24
  */
28
- function renderAgentStatusPage(data) {
25
+ export function renderAgentStatusPage(data) {
29
26
  const statusColor = data.connected ? '#22c55e' : '#ef4444';
30
27
  const statusText = data.connected ? 'Connected' : 'Disconnected';
31
28
  const memUsedMB = data.memoryTotalMB - data.memoryFreeMB;
@@ -1,53 +1,14 @@
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.getDeployStageRegistry = getDeployStageRegistry;
37
- exports.registerDeployBundleRoute = registerDeployBundleRoute;
38
- exports.buildHubHttpSource = buildHubHttpSource;
39
- exports.registerAddonUploadRoute = registerAddonUploadRoute;
40
- const fs = __importStar(require("node:fs"));
41
- const os = __importStar(require("node:os"));
42
- const path = __importStar(require("node:path"));
43
- const addon_package_service_js_1 = require("../core/addon/addon-package.service.js");
44
- const index_js_1 = require("../server-root/index.js");
45
- const agent_addon_delivery_js_1 = require("./agent-addon-delivery.js");
46
- const deploy_stage_registry_js_1 = require("./deploy-stage-registry.js");
47
- const tarball_manifest_js_1 = require("./tarball-manifest.js");
48
- const upload_auth_js_1 = require("./upload-auth.js");
49
- const deployStageRegistry = new deploy_stage_registry_js_1.DeployStageRegistry();
50
- function getDeployStageRegistry() {
1
+ import * as fs from 'node:fs';
2
+ import * as os from 'node:os';
3
+ import * as path from 'node:path';
4
+ import { isFrameworkPackage } from '../core/addon/addon-package.service.js';
5
+ import { detectWorkspaceRoot } from '../server-root/index.js';
6
+ import { deliverAddonToAgent, } from './agent-addon-delivery.js';
7
+ import { DeployStageRegistry } from './deploy-stage-registry.js';
8
+ import { isTarballFilename, readTarballManifest } from './tarball-manifest.js';
9
+ import { authorizeUploadRequest } from './upload-auth.js';
10
+ const deployStageRegistry = new DeployStageRegistry();
11
+ export function getDeployStageRegistry() {
51
12
  return deployStageRegistry;
52
13
  }
53
14
  /**
@@ -55,7 +16,7 @@ function getDeployStageRegistry() {
55
16
  * the per-deploy token minted in `DeployStageRegistry.stage()` and carried to
56
17
  * the agent in the `$agent.deploy` `hub-http` source descriptor.
57
18
  */
58
- function registerDeployBundleRoute(fastify) {
19
+ export function registerDeployBundleRoute(fastify) {
59
20
  // `compress: false` — never gzip/brotli this route. The body is a large
60
21
  // binary tarball (addon bundle / model artifact) the agent pulls with undici
61
22
  // + sha256 verification. With global @fastify/compress on, the 1–2MB response
@@ -102,7 +63,7 @@ async function resolveBaseUrlOrReason(resolve) {
102
63
  return { ok: false, error: err instanceof Error ? err.message : String(err) };
103
64
  }
104
65
  }
105
- function buildHubHttpSource(buffer, hubBaseUrl) {
66
+ export function buildHubHttpSource(buffer, hubBaseUrl) {
106
67
  const staged = getDeployStageRegistry().stage(buffer);
107
68
  return {
108
69
  kind: 'hub-http',
@@ -112,7 +73,7 @@ function buildHubHttpSource(buffer, hubBaseUrl) {
112
73
  bytes: staged.bytes,
113
74
  };
114
75
  }
115
- async function registerAddonUploadRoute(fastify, addonBridge, authService, moleculer, addonRegistry, addonPackageService, logger,
76
+ export async function registerAddonUploadRoute(fastify, addonBridge, authService, moleculer, addonRegistry, addonPackageService, logger,
116
77
  /**
117
78
  * The base URL agents pull the staged bundle from — the `local-network`
118
79
  * cap's cluster address (`hub-cluster-url.ts`), resolved per delivery.
@@ -125,7 +86,7 @@ resolveClusterBaseUrl,
125
86
  * not build one; `main.ts` always passes the AgentRegistryService's.
126
87
  */
127
88
  deliveryLedger) {
128
- await fastify.register(Promise.resolve().then(() => __importStar(require('@fastify/multipart'))), {
89
+ await fastify.register(import('@fastify/multipart'), {
129
90
  limits: { fileSize: MAX_UPLOAD_BYTES },
130
91
  });
131
92
  registerDeployBundleRoute(fastify);
@@ -133,7 +94,7 @@ deliveryLedger) {
133
94
  // Auth chain (shared with /api/server-upload): JWT (isAdmin) OR scoped
134
95
  // token whose scopes grant `create` access on the `addons` capability.
135
96
  // See upload-auth.ts for the full rationale.
136
- const auth = await (0, upload_auth_js_1.authorizeUploadRequest)({
97
+ const auth = await authorizeUploadRequest({
137
98
  authHeader: request.headers.authorization,
138
99
  authService,
139
100
  addonRegistry,
@@ -145,7 +106,7 @@ deliveryLedger) {
145
106
  if (!data) {
146
107
  return reply.status(400).send({ error: 'No file uploaded' });
147
108
  }
148
- if (!(0, tarball_manifest_js_1.isTarballFilename)(data.filename)) {
109
+ if (!isTarballFilename(data.filename)) {
149
110
  return reply.status(400).send({ error: 'File must be a .tgz or .tar.gz archive' });
150
111
  }
151
112
  // Drain the file part FIRST. `data.fields` is the plugin's live `body`
@@ -170,7 +131,7 @@ deliveryLedger) {
170
131
  // Gate: reject archives that don't expose a parseable package.json with
171
132
  // name + version. The hub installer did this implicitly via npm; the
172
133
  // agent path would otherwise fail mid-extraction with no clean rollback.
173
- const manifest = (0, tarball_manifest_js_1.readTarballManifest)(buffer, data.filename);
134
+ const manifest = readTarballManifest(buffer, data.filename);
174
135
  if (!manifest) {
175
136
  return reply.status(400).send({
176
137
  error: 'Tarball missing or malformed package/package.json (name + version required)',
@@ -256,7 +217,7 @@ async function propagateToAgents(moleculer, logger, packageName, buffer, resolve
256
217
  // yet. Wiring it later must also make the agent's npm path evict the addon's
257
218
  // declaration ids before `$agent.reload`, otherwise an npm update pins the
258
219
  // stale version.
259
- results.push(await (0, agent_addon_delivery_js_1.deliverAddonToAgent)({
220
+ results.push(await deliverAddonToAgent({
260
221
  broker,
261
222
  logger,
262
223
  nodeId,
@@ -319,7 +280,7 @@ async function installToHub(reply, addonBridge, addonRegistry, addonPackageServi
319
280
  // settings. The new code is now on disk; a clean server restart reloads it
320
281
  // and re-runs boot initialization. The 10s restart grace lets this response
321
282
  // flush before the process exits, so the CLI sees a clean confirmation.
322
- if ((0, addon_package_service_js_1.isFrameworkPackage)(result.name)) {
283
+ if (isFrameworkPackage(result.name)) {
323
284
  // Framework live-sync is GONE (superseded by the runtime-updatable root
324
285
  // package — the hub main + its framework deps now update as ONE
325
286
  // `@camstack/server` closure via the `server-management` cap).
@@ -329,7 +290,7 @@ async function installToHub(reply, addonBridge, addonRegistry, addonPackageServi
329
290
  // BEFORE uploading — a plain restart loads the new code, no mirror
330
291
  // needed. `camstack deploy packages/system` therefore keeps working in
331
292
  // dev unchanged.
332
- const workspaceRoot = (0, index_js_1.detectWorkspaceRoot)(__dirname);
293
+ const workspaceRoot = detectWorkspaceRoot(__dirname);
333
294
  if (workspaceRoot !== null) {
334
295
  logger.info('framework package deployed (workspace) — scheduling server restart', {
335
296
  meta: { packageName: result.name, packageVersion: result.version, workspaceRoot },
@@ -446,7 +407,7 @@ async function deployToAgent(reply, moleculer, logger, nodeId, addonId, buffer,
446
407
  // yet. Wiring it later must also make the agent's npm path evict the addon's
447
408
  // declaration ids before `$agent.reload`, otherwise an npm update pins the
448
409
  // stale version.
449
- const result = await (0, agent_addon_delivery_js_1.deliverAddonToAgent)({
410
+ const result = await deliverAddonToAgent({
450
411
  broker: moleculer.broker,
451
412
  logger,
452
413
  nodeId,
@@ -1,8 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AGENT_RELOAD_TIMEOUT_MS = exports.AGENT_DEPLOY_CONTROL_TIMEOUT_MS = void 0;
4
- exports.isAgentDeployResponse = isAgentDeployResponse;
5
- exports.deliverAddonToAgent = deliverAddonToAgent;
6
1
  /**
7
2
  * Delivering an addon bundle to an agent — the single implementation.
8
3
  *
@@ -45,13 +40,13 @@ exports.deliverAddonToAgent = deliverAddonToAgent;
45
40
  * exactly like a deploy that worked. `agent-deploy-timeout.spec.ts` pins the
46
41
  * relationship so they cannot separate again.
47
42
  */
48
- exports.AGENT_DEPLOY_CONTROL_TIMEOUT_MS = 300_000;
43
+ export const AGENT_DEPLOY_CONTROL_TIMEOUT_MS = 300_000;
49
44
  /**
50
45
  * `$agent.reload` re-forks group runners and re-registers their capabilities —
51
46
  * legitimately slow on a node with a Python inference pool.
52
47
  */
53
- exports.AGENT_RELOAD_TIMEOUT_MS = 60_000;
54
- function isAgentDeployResponse(value) {
48
+ export const AGENT_RELOAD_TIMEOUT_MS = 60_000;
49
+ export function isAgentDeployResponse(value) {
55
50
  if (value === null || typeof value !== 'object')
56
51
  return false;
57
52
  const v = value;
@@ -79,7 +74,7 @@ function readLoaded(value) {
79
74
  * Never throws: a per-node failure is returned so one unreachable agent cannot
80
75
  * abort a cluster propagation or the hub's own install.
81
76
  */
82
- async function deliverAddonToAgent(args) {
77
+ export async function deliverAddonToAgent(args) {
83
78
  const { broker, logger, nodeId, packageName, source } = args;
84
79
  // Opened BEFORE the first byte and closed in the `finally` below — the window
85
80
  // must cover `$agent.deploy` (which evicts the package's declaration ids) AND
@@ -87,7 +82,7 @@ async function deliverAddonToAgent(args) {
87
82
  // happy path.
88
83
  const closeWindow = args.deliveryLedger?.begin(nodeId, packageName);
89
84
  try {
90
- const deployRaw = await broker.call('$agent.deploy', { addonId: packageName, source }, { nodeID: nodeId, timeout: exports.AGENT_DEPLOY_CONTROL_TIMEOUT_MS });
85
+ const deployRaw = await broker.call('$agent.deploy', { addonId: packageName, source }, { nodeID: nodeId, timeout: AGENT_DEPLOY_CONTROL_TIMEOUT_MS });
91
86
  if (!isAgentDeployResponse(deployRaw)) {
92
87
  logger.warn('agent deploy: malformed deploy response', {
93
88
  meta: { nodeId, packageName },
@@ -119,7 +114,7 @@ async function deliverAddonToAgent(args) {
119
114
  });
120
115
  // Reload. Without this the deploy is write-to-disk-only and the node keeps
121
116
  // running the previous dist — the whole point of this module.
122
- const reloadRaw = await broker.call('$agent.reload', {}, { nodeID: nodeId, timeout: exports.AGENT_RELOAD_TIMEOUT_MS });
117
+ const reloadRaw = await broker.call('$agent.reload', {}, { nodeID: nodeId, timeout: AGENT_RELOAD_TIMEOUT_MS });
123
118
  const loaded = readLoaded(reloadRaw);
124
119
  if (loaded.length === 0) {
125
120
  // Not fatal — a reload can legitimately find nothing to (re)instantiate
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerAuthWhoamiRoute = registerAuthWhoamiRoute;
4
- async function registerAuthWhoamiRoute(fastify, authService, addonRegistry) {
1
+ export async function registerAuthWhoamiRoute(fastify, authService, addonRegistry) {
5
2
  fastify.get('/api/auth/whoami', async (request, reply) => {
6
3
  const authHeader = request.headers.authorization;
7
4
  if (!authHeader) {
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * backup-download-pump — a backup archive is streamed at the pace the client
4
3
  * READS it, and a client that stops reading is cut, never buffered until
@@ -43,18 +42,15 @@
43
42
  * `warn` for a cut client or a failed source. The route previously logged
44
43
  * nothing on success and `console.error` on failure.
45
44
  */
46
- Object.defineProperty(exports, "__esModule", { value: true });
47
- exports.BACKUP_DOWNLOAD_DRAIN_GRACE_MS = exports.BACKUP_DOWNLOAD_CHUNK_BYTES = void 0;
48
- exports.pumpDownload = pumpDownload;
49
45
  /** Bytes read from the storage cap per round trip; one chunk is the most the response holds. */
50
- exports.BACKUP_DOWNLOAD_CHUNK_BYTES = 8 * 1024 * 1024;
46
+ export const BACKUP_DOWNLOAD_CHUNK_BYTES = 8 * 1024 * 1024;
51
47
  /**
52
48
  * How long a `write` may stay unacknowledged by `drain` before the client is
53
49
  * cut. A `ServerResponse` signals `drain` once the socket has taken its
54
50
  * buffer (16 KiB by default): a client that cannot take 16 KiB in a minute is
55
51
  * under 0.3 KB/s — not a slow link, an absent reader.
56
52
  */
57
- exports.BACKUP_DOWNLOAD_DRAIN_GRACE_MS = 60_000;
53
+ export const BACKUP_DOWNLOAD_DRAIN_GRACE_MS = 60_000;
58
54
  function waitForDrain(sink, graceMs) {
59
55
  return new Promise((resolve) => {
60
56
  const settle = (outcome) => {
@@ -78,10 +74,10 @@ function errorOf(err) {
78
74
  * next only once the socket has taken the previous. Never throws: every exit
79
75
  * is a {@link PumpResult} the caller can log.
80
76
  */
81
- async function pumpDownload(options) {
77
+ export async function pumpDownload(options) {
82
78
  const { sizeBytes, read, sink } = options;
83
- const chunkBytes = options.chunkBytes ?? exports.BACKUP_DOWNLOAD_CHUNK_BYTES;
84
- const graceMs = options.graceMs ?? exports.BACKUP_DOWNLOAD_DRAIN_GRACE_MS;
79
+ const chunkBytes = options.chunkBytes ?? BACKUP_DOWNLOAD_CHUNK_BYTES;
80
+ const graceMs = options.graceMs ?? BACKUP_DOWNLOAD_DRAIN_GRACE_MS;
85
81
  const now = options.now ?? (() => Date.now());
86
82
  const startedAt = now();
87
83
  let offset = 0;
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerBackupDownloadRoute = registerBackupDownloadRoute;
4
- const backup_download_pump_js_1 = require("./backup-download-pump.js");
5
- const client_ip_js_1 = require("./trpc/client-ip.js");
1
+ import { BACKUP_DOWNLOAD_CHUNK_BYTES, BACKUP_DOWNLOAD_DRAIN_GRACE_MS, pumpDownload, } from './backup-download-pump.js';
2
+ import { extractClientIp } from './trpc/client-ip.js';
6
3
  /** Strip what would break the `Content-Disposition` header. Whitespace is fine. */
7
4
  function safeAttachmentName(name) {
8
5
  return name.replace(/[\r\n"]/g, '_');
9
6
  }
10
- function registerBackupDownloadRoute(fastify, options) {
7
+ export function registerBackupDownloadRoute(fastify, options) {
11
8
  const { verifier, capabilities, logger } = options;
12
- const chunkBytes = options.chunkBytes ?? backup_download_pump_js_1.BACKUP_DOWNLOAD_CHUNK_BYTES;
13
- const graceMs = options.graceMs ?? backup_download_pump_js_1.BACKUP_DOWNLOAD_DRAIN_GRACE_MS;
9
+ const chunkBytes = options.chunkBytes ?? BACKUP_DOWNLOAD_CHUNK_BYTES;
10
+ const graceMs = options.graceMs ?? BACKUP_DOWNLOAD_DRAIN_GRACE_MS;
14
11
  fastify.get('/api/backup/download/:locationId/:archiveId', async (request, reply) => {
15
12
  const authHeader = request.headers.authorization;
16
13
  if (!authHeader) {
@@ -60,13 +57,13 @@ function registerBackupDownloadRoute(fastify, options) {
60
57
  archiveId,
61
58
  filename: archive.filename,
62
59
  sizeBytes,
63
- ip: (0, client_ip_js_1.extractClientIp)(request.raw) ?? '(unidentified)',
60
+ ip: extractClientIp(request.raw) ?? '(unidentified)',
64
61
  chunkBytes,
65
62
  graceMs,
66
63
  };
67
64
  let result;
68
65
  try {
69
- result = await (0, backup_download_pump_js_1.pumpDownload)({
66
+ result = await pumpDownload({
70
67
  sizeBytes,
71
68
  chunkBytes,
72
69
  graceMs,
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAddonSettingsRouter = createAddonSettingsRouter;
4
1
  /**
5
2
  * `addonSettingsRaw` — admin read of an addon's RAW stored settings.
6
3
  *
@@ -56,21 +53,21 @@ exports.createAddonSettingsRouter = createAddonSettingsRouter;
56
53
  * merging (defaults → global → per-device). That happens on the consumer side
57
54
  * where the addon's `ConfigUISchema` is available.
58
55
  */
59
- const server_1 = require("@trpc/server");
60
- const system_1 = require("@camstack/system");
61
- const zod_1 = require("zod");
62
- const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
63
- const AddonSettingsRecordSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
64
- const AddonIdInputSchema = zod_1.z.object({
65
- addonId: zod_1.z.string().min(1),
56
+ import { TRPCError } from '@trpc/server';
57
+ import { isSettingsReadUnavailable } from '@camstack/system';
58
+ import { z } from 'zod';
59
+ import { trpcRouter, adminProcedure } from '../trpc/trpc.middleware.js';
60
+ const AddonSettingsRecordSchema = z.record(z.string(), z.unknown());
61
+ const AddonIdInputSchema = z.object({
62
+ addonId: z.string().min(1),
66
63
  });
67
64
  /**
68
65
  * `deviceId` stays a STRING on the wire (the shape callers already send) but
69
66
  * must be a numeric device id: the per-device rows are keyed by the numeric id.
70
67
  */
71
- const AddonDeviceInputSchema = zod_1.z.object({
72
- addonId: zod_1.z.string().min(1),
73
- deviceId: zod_1.z.string().regex(/^\d+$/, 'deviceId must be a numeric device id'),
68
+ const AddonDeviceInputSchema = z.object({
69
+ addonId: z.string().min(1),
70
+ deviceId: z.string().regex(/^\d+$/, 'deviceId must be a numeric device id'),
74
71
  });
75
72
  /** A settings read that could not be answered is an error, never `{}`. */
76
73
  async function answerOrRefuse(read) {
@@ -78,20 +75,20 @@ async function answerOrRefuse(read) {
78
75
  return await read();
79
76
  }
80
77
  catch (err) {
81
- if ((0, system_1.isSettingsReadUnavailable)(err)) {
82
- throw new server_1.TRPCError({ code: 'SERVICE_UNAVAILABLE', message: err.message, cause: err });
78
+ if (isSettingsReadUnavailable(err)) {
79
+ throw new TRPCError({ code: 'SERVICE_UNAVAILABLE', message: err.message, cause: err });
83
80
  }
84
81
  throw err;
85
82
  }
86
83
  }
87
- function createAddonSettingsRouter(cfg) {
88
- return (0, trpc_middleware_js_1.trpcRouter)({
84
+ export function createAddonSettingsRouter(cfg) {
85
+ return trpcRouter({
89
86
  /**
90
87
  * The addon-global stored record for the given addon — raw values, no
91
88
  * defaults, no device overrides. `{}` only when the store answered with no
92
89
  * row for this addon; a failed read is `SERVICE_UNAVAILABLE`.
93
90
  */
94
- getGlobal: trpc_middleware_js_1.adminProcedure
91
+ getGlobal: adminProcedure
95
92
  .input(AddonIdInputSchema)
96
93
  .output(AddonSettingsRecordSchema)
97
94
  .query(({ input }) => answerOrRefuse(() => cfg.readAddonGlobalStrict(input.addonId))),
@@ -100,7 +97,7 @@ function createAddonSettingsRouter(cfg) {
100
97
  * values. `{}` only when the store answered with none; a failed read is
101
98
  * `SERVICE_UNAVAILABLE`.
102
99
  */
103
- getDeviceOverrides: trpc_middleware_js_1.adminProcedure
100
+ getDeviceOverrides: adminProcedure
104
101
  .input(AddonDeviceInputSchema)
105
102
  .output(AddonSettingsRecordSchema)
106
103
  .query(({ input }) => answerOrRefuse(() => cfg.readAddonDeviceStrict(input.addonId, Number(input.deviceId)))),