@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,43 +1,3 @@
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.AgentUpdateService = exports.AgentRestartAnnouncer = exports.AGENT_RESTART_GRACE_MS = exports.AGENT_RUNTIME_ADDON_ID = void 0;
37
- exports.isRunningInContainer = isRunningInContainer;
38
- exports.resolveAgentPackageJsonPath = resolveAgentPackageJsonPath;
39
- exports.scheduleAgentRestart = scheduleAgentRestart;
40
- exports.agentRuntimeManifestEntry = agentRuntimeManifestEntry;
41
1
  /**
42
2
  * AgentUpdateService — agent-side adapter over the SHARED `RootUpdateService`
43
3
  * (`@camstack/node-root`, bundled into the `@camstack/server` dist by tsup).
@@ -60,33 +20,33 @@ exports.agentRuntimeManifestEntry = agentRuntimeManifestEntry;
60
20
  *
61
21
  * Spec: docs/superpowers/specs/2026-07-18-single-framework-copy-collapse-design.md
62
22
  */
63
- const node_crypto_1 = require("node:crypto");
64
- const fs = __importStar(require("node:fs"));
65
- const path = __importStar(require("node:path"));
66
- const system_1 = require("@camstack/system");
67
- const types_1 = require("@camstack/types");
68
- const system_ensure_prebuilds_js_1 = require("../core/server-update/system-ensure-prebuilds.js");
69
- const system_apply_closure_patches_js_1 = require("../core/server-update/system-apply-closure-patches.js");
70
- const system_exec_npm_js_1 = require("../core/server-update/system-exec-npm.js");
71
- const update_availability_emitter_js_1 = require("../core/update-availability-emitter.js");
72
- const update_availability_store_js_1 = require("../core/update-availability-store.js");
73
- const index_js_1 = require("../server-root/index.js");
74
- const restart_marker_js_1 = require("../core/updates/restart-marker.js");
23
+ import { randomUUID } from 'node:crypto';
24
+ import * as fs from 'node:fs';
25
+ import * as path from 'node:path';
26
+ import { readPendingRestart, writePendingRestart } from '@camstack/system';
27
+ import { EventCategory } from '@camstack/types';
28
+ import { buildSystemEnsureNativePrebuilds, } from '../core/server-update/system-ensure-prebuilds.js';
29
+ import { buildSystemApplyClosurePatches, } from '../core/server-update/system-apply-closure-patches.js';
30
+ import { buildSystemExecNpm } from '../core/server-update/system-exec-npm.js';
31
+ import { UpdateAvailabilityEmitter } from '../core/update-availability-emitter.js';
32
+ import { FileUpdateAvailabilityStore } from '../core/update-availability-store.js';
33
+ import { HUB_ROOT_SPEC, RootUpdateService, serverRootDir, writeRestartIntentMarker, } from '../server-root/index.js';
34
+ import { buildRestartMarker } from '../core/updates/restart-marker.js';
75
35
  /**
76
36
  * The synthetic addonId the agent's OWN runtime registers infra providers
77
37
  * under (no addon owns them — the bootstrap does). Appears in the agent's
78
38
  * `$hub.registerNode` manifest so the hub's cap routing can reach the
79
39
  * agent-hosted `server-management` provider via `nodeId` pinning.
80
40
  */
81
- exports.AGENT_RUNTIME_ADDON_ID = 'agent-runtime';
41
+ export const AGENT_RUNTIME_ADDON_ID = 'agent-runtime';
82
42
  /** Grace before the self-SIGTERM so the tRPC reply can flush to the hub. */
83
- exports.AGENT_RESTART_GRACE_MS = 2_000;
43
+ export const AGENT_RESTART_GRACE_MS = 2_000;
84
44
  /**
85
45
  * Best-effort container detection for the restart-policy startup warning
86
46
  * (security review #3). `/.dockerenv` is present in Docker/Podman containers;
87
47
  * this is diagnostic only — never gates any logic.
88
48
  */
89
- function isRunningInContainer(existsSyncFn) {
49
+ export function isRunningInContainer(existsSyncFn) {
90
50
  return existsSyncFn('/.dockerenv');
91
51
  }
92
52
  /**
@@ -95,7 +55,7 @@ function isRunningInContainer(existsSyncFn) {
95
55
  * `<pkg>/dist/*.js`, so `../package.json` is the normal hit; the second
96
56
  * candidate covers a nested layout.
97
57
  */
98
- function resolveAgentPackageJsonPath(fromDir) {
58
+ export function resolveAgentPackageJsonPath(fromDir) {
99
59
  const candidates = [
100
60
  path.resolve(fromDir, '..', 'package.json'),
101
61
  path.resolve(fromDir, '..', '..', 'package.json'),
@@ -103,7 +63,7 @@ function resolveAgentPackageJsonPath(fromDir) {
103
63
  for (const candidate of candidates) {
104
64
  try {
105
65
  const raw = JSON.parse(fs.readFileSync(candidate, 'utf-8'));
106
- if (raw.name === index_js_1.HUB_ROOT_SPEC.packageName)
66
+ if (raw.name === HUB_ROOT_SPEC.packageName)
107
67
  return candidate;
108
68
  }
109
69
  catch {
@@ -125,10 +85,10 @@ function resolveAgentPackageJsonPath(fromDir) {
125
85
  * marker (it relaunches regardless), so this is a no-op there. Best-effort: a
126
86
  * marker-write failure must never block the restart.
127
87
  */
128
- function scheduleAgentRestart(logger, requestedBy, dataDir) {
88
+ export function scheduleAgentRestart(logger, requestedBy, dataDir) {
129
89
  if (dataDir !== undefined && dataDir.length > 0) {
130
90
  try {
131
- (0, index_js_1.writeRestartIntentMarker)((0, index_js_1.serverRootDir)(dataDir), {
91
+ writeRestartIntentMarker(serverRootDir(dataDir), {
132
92
  requestedAtMs: Date.now(),
133
93
  reason: requestedBy,
134
94
  });
@@ -140,13 +100,13 @@ function scheduleAgentRestart(logger, requestedBy, dataDir) {
140
100
  }
141
101
  }
142
102
  logger.warn('agent restart requested — exiting for supervisor relaunch', {
143
- meta: { requestedBy, graceMs: exports.AGENT_RESTART_GRACE_MS },
103
+ meta: { requestedBy, graceMs: AGENT_RESTART_GRACE_MS },
144
104
  });
145
105
  const grace = setTimeout(() => {
146
106
  process.kill(process.pid, 'SIGTERM');
147
107
  const hard = setTimeout(() => process.exit(0), 15_000);
148
108
  hard.unref();
149
- }, exports.AGENT_RESTART_GRACE_MS);
109
+ }, AGENT_RESTART_GRACE_MS);
150
110
  grace.unref();
151
111
  }
152
112
  /**
@@ -161,7 +121,7 @@ function scheduleAgentRestart(logger, requestedBy, dataDir) {
161
121
  * once the mesh is up). A restart before that has nobody to tell — said, never
162
122
  * silent.
163
123
  */
164
- class AgentRestartAnnouncer {
124
+ export class AgentRestartAnnouncer {
165
125
  logger;
166
126
  eventBus;
167
127
  nodeId;
@@ -185,10 +145,10 @@ class AgentRestartAnnouncer {
185
145
  const payload = { ...marker, nodeId: this.nodeId };
186
146
  try {
187
147
  bus.emit({
188
- id: (0, node_crypto_1.randomUUID)(),
148
+ id: randomUUID(),
189
149
  timestamp: new Date(),
190
150
  source: { type: 'core', id: 'agent-update-service' },
191
- category: types_1.EventCategory.SystemRestarting,
151
+ category: EventCategory.SystemRestarting,
192
152
  data: payload,
193
153
  });
194
154
  }
@@ -201,8 +161,7 @@ class AgentRestartAnnouncer {
201
161
  }
202
162
  }
203
163
  }
204
- exports.AgentRestartAnnouncer = AgentRestartAnnouncer;
205
- class AgentUpdateService extends index_js_1.RootUpdateService {
164
+ export class AgentUpdateService extends RootUpdateService {
206
165
  restartAnnouncer;
207
166
  updateAvailability;
208
167
  eventBus;
@@ -220,7 +179,7 @@ class AgentUpdateService extends index_js_1.RootUpdateService {
220
179
  const nodeId = options.nodeId ?? process.env['CAMSTACK_NODE_ID'] ?? 'agent';
221
180
  const restartAnnouncer = new AgentRestartAnnouncer(options.logger, options.eventBus ?? null, nodeId);
222
181
  super({
223
- spec: index_js_1.HUB_ROOT_SPEC,
182
+ spec: HUB_ROOT_SPEC,
224
183
  nodeId,
225
184
  // The agent's on-disk root IS `@camstack/server` (booted via
226
185
  // CAMSTACK_ROLE=agent by the shared starter), so it reads the SAME
@@ -243,19 +202,19 @@ class AgentUpdateService extends index_js_1.RootUpdateService {
243
202
  // bare Node with no system npm, so the raw `execFile('npm')` default would
244
203
  // ENOENT. `cacheDir` mirrors AddonInstaller's `<dataDir>/addons/.npm-bootstrap`.
245
204
  execNpm: options.execNpm ??
246
- (0, system_exec_npm_js_1.buildSystemExecNpm)({
205
+ buildSystemExecNpm({
247
206
  cacheDir: path.join(options.dataDir, 'addons', '.npm-bootstrap'),
248
207
  logger: options.logger,
249
208
  }),
250
209
  // Same native-prebuild ensure step as the hub — a packaged desktop AGENT
251
210
  // ships the identical bare Node, so its `applyServerUpdate` staging would
252
211
  // hit the same source-only `better-sqlite3` miss without this.
253
- ensureNativePrebuilds: options.ensureNativePrebuilds ?? (0, system_ensure_prebuilds_js_1.buildSystemEnsureNativePrebuilds)(options.logger),
212
+ ensureNativePrebuilds: options.ensureNativePrebuilds ?? buildSystemEnsureNativePrebuilds(options.logger),
254
213
  // Apply the closure patches ourselves. npm 12 blocks the root package's
255
214
  // postinstall by default, and a silently-unpatched closure is refused by
256
215
  // the validator — an update that can never apply. Idempotent, so this
257
216
  // costs nothing where npm did run the lifecycle.
258
- applyClosurePatches: options.applyClosurePatches ?? (0, system_apply_closure_patches_js_1.buildSystemApplyClosurePatches)(options.logger),
217
+ applyClosurePatches: options.applyClosurePatches ?? buildSystemApplyClosurePatches(options.logger),
259
218
  env: options.env,
260
219
  now: options.now,
261
220
  ...(options.runnerBootCheck !== undefined
@@ -269,7 +228,7 @@ class AgentUpdateService extends index_js_1.RootUpdateService {
269
228
  this.eventBus = options.eventBus ?? null;
270
229
  this.updateAvailability =
271
230
  options.eventBus !== undefined
272
- ? new update_availability_emitter_js_1.UpdateAvailabilityEmitter(options.eventBus, { type: 'core', id: 'agent-update-service' }, options.updateAvailabilityStore)
231
+ ? new UpdateAvailabilityEmitter(options.eventBus, { type: 'core', id: 'agent-update-service' }, options.updateAvailabilityStore)
273
232
  : null;
274
233
  }
275
234
  /**
@@ -281,7 +240,7 @@ class AgentUpdateService extends index_js_1.RootUpdateService {
281
240
  this.eventBus = eventBus;
282
241
  this.nodeId = nodeId;
283
242
  this.restartAnnouncer.bind(eventBus, nodeId);
284
- this.updateAvailability = new update_availability_emitter_js_1.UpdateAvailabilityEmitter(eventBus, { type: 'core', id: 'agent-update-service' }, new update_availability_store_js_1.FileUpdateAvailabilityStore(this.agentDataDir, 'agent-update', this.agentLogger));
243
+ this.updateAvailability = new UpdateAvailabilityEmitter(eventBus, { type: 'core', id: 'agent-update-service' }, new FileUpdateAvailabilityStore(this.agentDataDir, 'agent-update', this.agentLogger));
285
244
  }
286
245
  async checkServerUpdate() {
287
246
  const result = await super.checkServerUpdate();
@@ -305,7 +264,7 @@ class AgentUpdateService extends index_js_1.RootUpdateService {
305
264
  const bus = this.eventBus;
306
265
  if (bus === null)
307
266
  return;
308
- const marker = (0, system_1.readPendingRestart)(this.agentDataDir);
267
+ const marker = readPendingRestart(this.agentDataDir);
309
268
  if (marker === null)
310
269
  return;
311
270
  const payload = {
@@ -318,26 +277,25 @@ class AgentUpdateService extends index_js_1.RootUpdateService {
318
277
  ...(marker.requestedBy !== undefined ? { requestedBy: marker.requestedBy } : {}),
319
278
  };
320
279
  bus.emit({
321
- id: (0, node_crypto_1.randomUUID)(),
280
+ id: randomUUID(),
322
281
  timestamp: new Date(),
323
282
  source: { type: 'core', id: 'agent-update-service' },
324
- category: types_1.EventCategory.SystemRestartCompleted,
283
+ category: EventCategory.SystemRestartCompleted,
325
284
  data: payload,
326
285
  });
327
286
  }
328
287
  }
329
- exports.AgentUpdateService = AgentUpdateService;
330
288
  /** Write the marker and return it — the same payload is the announcement (D723). */
331
289
  function writeAgentRestartMarker(dataDir, requestedBy, update) {
332
290
  // Same builder as the hub: an agent's "Server aggiornato" notification must
333
291
  // name both versions too — see `core/updates/restart-marker.ts`.
334
- const marker = (0, restart_marker_js_1.buildRestartMarker)({
292
+ const marker = buildRestartMarker({
335
293
  requestedAt: Date.now(),
336
294
  requestedBy,
337
295
  ...(update !== undefined ? { update } : {}),
338
296
  });
339
297
  try {
340
- (0, system_1.writePendingRestart)(dataDir, marker);
298
+ writePendingRestart(dataDir, marker);
341
299
  }
342
300
  catch {
343
301
  // Marker write must never block the restart.
@@ -350,9 +308,9 @@ function writeAgentRestartMarker(dataDir, requestedBy, update) {
350
308
  * `HubNodeRegistry` (and therefore `createCapabilityProxy` node routing) even
351
309
  * though no `loadedAddons` entry owns it.
352
310
  */
353
- function agentRuntimeManifestEntry() {
311
+ export function agentRuntimeManifestEntry() {
354
312
  return {
355
- addonId: exports.AGENT_RUNTIME_ADDON_ID,
313
+ addonId: AGENT_RUNTIME_ADDON_ID,
356
314
  capabilities: ['server-management', 'node-certificates'],
357
315
  };
358
316
  }
@@ -1,12 +1,9 @@
1
- "use strict";
2
1
  /**
3
2
  * Agent-side model distribution (P2): pull a staged model tarball from the hub
4
3
  * and untar it into this node's modelsDir. Factored behind a seam so the
5
4
  * fetch/extract/fs effects are injectable in tests.
6
5
  */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.applyModelDistribution = applyModelDistribution;
9
- async function applyModelDistribution(seam, params) {
6
+ export async function applyModelDistribution(seam, params) {
10
7
  seam.mkdirp(seam.modelsDir);
11
8
  const buffer = await seam.fetchBundle(params.source);
12
9
  await seam.extract(buffer, seam.modelsDir);
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyStageDevUploads = applyStageDevUploads;
4
1
  /**
5
2
  * Pure seam for `$agent.stageDevUploads` — fetch a hub-staged pack of
6
3
  * `dev-uploads/<version>/` and write it under this node's server-root.
7
4
  */
8
- const node_crypto_1 = require("node:crypto");
9
- const index_js_1 = require("../server-root/index.js");
10
- async function applyStageDevUploads(seam, params) {
5
+ import { createHash } from 'node:crypto';
6
+ import { isDevChannelVersion, serverRootDir } from '../server-root/index.js';
7
+ export async function applyStageDevUploads(seam, params) {
11
8
  const { version, source } = params;
12
- if (!(0, index_js_1.isDevChannelVersion)(version)) {
9
+ if (!isDevChannelVersion(version)) {
13
10
  throw new Error(`$agent.stageDevUploads: version "${version}" is not dev-channel shaped`);
14
11
  }
15
12
  const bundle = await seam.fetchBundle(source);
16
- const appliedSha256 = (0, node_crypto_1.createHash)('sha256').update(bundle).digest('hex');
13
+ const appliedSha256 = createHash('sha256').update(bundle).digest('hex');
17
14
  const unpacked = await seam.unpack({
18
- serverRoot: (0, index_js_1.serverRootDir)(seam.dataDir),
15
+ serverRoot: serverRootDir(seam.dataDir),
19
16
  version,
20
17
  bundle,
21
18
  });
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Derive the agent's `CAMSTACK_HUB_URL` from its friendly `hubAddress`.
4
3
  *
@@ -24,12 +23,8 @@
24
23
  * Because every current consumer keeps only the host, the port is convention;
25
24
  * a future full-URL consumer must treat it as the default, not authoritative.
26
25
  */
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.deriveHubUrlFromHubAddress = deriveHubUrlFromHubAddress;
29
- exports.deriveHubUrlForExport = deriveHubUrlForExport;
30
- exports.pickIpv4 = pickIpv4;
31
26
  const HUB_API_PORT = 4443;
32
- function deriveHubUrlFromHubAddress(hubAddress) {
27
+ export function deriveHubUrlFromHubAddress(hubAddress) {
33
28
  const trimmed = hubAddress.trim();
34
29
  if (trimmed.length === 0)
35
30
  return undefined;
@@ -49,7 +44,7 @@ function deriveHubUrlFromHubAddress(hubAddress) {
49
44
  * today's working deployments. Kept pure (env is passed in) so both the
50
45
  * boot-time derivation and the reconnect path can be unit-tested.
51
46
  */
52
- function deriveHubUrlForExport(hubUrlWasExplicit, hubAddress) {
47
+ export function deriveHubUrlForExport(hubUrlWasExplicit, hubAddress) {
53
48
  if (hubUrlWasExplicit)
54
49
  return undefined;
55
50
  if (hubAddress === undefined)
@@ -75,7 +70,7 @@ function extractHostFromAuthority(authority) {
75
70
  * Canonical home of this helper — `resolveHubEndpoint` in `agent-http.ts`
76
71
  * (UI-facing `resolvedHubAddress`) re-exports and reuses it.
77
72
  */
78
- function pickIpv4(ipList) {
73
+ export function pickIpv4(ipList) {
79
74
  if (!ipList)
80
75
  return null;
81
76
  for (const ip of ipList) {
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchBundleFromHub = fetchBundleFromHub;
4
- const node_crypto_1 = require("node:crypto");
5
- const undici_1 = require("undici");
1
+ import { createHash } from 'node:crypto';
2
+ import { Agent, fetch as undicicFetch } from 'undici';
6
3
  /**
7
4
  * Stream a staged addon tgz from the hub's one-time-token bundle route and
8
5
  * verify integrity (byte count + sha256) before handing it to the installer.
9
6
  */
10
- async function fetchBundleFromHub(opts) {
7
+ export async function fetchBundleFromHub(opts) {
11
8
  // When a fetchImpl is injected (tests), call it as-is — the stub ignores dispatcher.
12
9
  // For production (global fetch against the real hub's self-signed TLS cert), use
13
10
  // undici.fetch with an Agent that disables CA verification. The hub serves HTTPS with a
@@ -27,9 +24,9 @@ async function fetchBundleFromHub(opts) {
27
24
  const authHeader = { Authorization: `Bearer ${opts.token}`, 'accept-encoding': 'identity' };
28
25
  const res = opts.fetchImpl
29
26
  ? await opts.fetchImpl(opts.url, { headers: authHeader })
30
- : await (0, undici_1.fetch)(opts.url, {
27
+ : await undicicFetch(opts.url, {
31
28
  headers: authHeader,
32
- dispatcher: new undici_1.Agent({ connect: { rejectUnauthorized: false } }),
29
+ dispatcher: new Agent({ connect: { rejectUnauthorized: false } }),
33
30
  });
34
31
  if (!res.ok) {
35
32
  throw new Error(`bundle fetch failed: HTTP ${res.status}`);
@@ -38,7 +35,7 @@ async function fetchBundleFromHub(opts) {
38
35
  if (buffer.length !== opts.bytes) {
39
36
  throw new Error(`bundle bytes mismatch: expected ${opts.bytes}, got ${buffer.length}`);
40
37
  }
41
- const sha = (0, node_crypto_1.createHash)('sha256').update(buffer).digest('hex');
38
+ const sha = createHash('sha256').update(buffer).digest('hex');
42
39
  if (sha !== opts.sha256) {
43
40
  throw new Error(`bundle sha256 mismatch: expected ${opts.sha256}, got ${sha}`);
44
41
  }
@@ -1,43 +1,6 @@
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.CONFIGURED_HUB_SOURCE = void 0;
37
- exports.createHubsFinder = createHubsFinder;
38
- const derive_hub_url_js_1 = require("./derive-hub-url.js");
1
+ import { deriveHubUrlFromHubAddress } from './derive-hub-url.js';
39
2
  /** Label of the configured hub in {@link FoundHub.sources}. */
40
- exports.CONFIGURED_HUB_SOURCE = 'configured hub address';
3
+ export const CONFIGURED_HUB_SOURCE = 'configured hub address';
41
4
  /** A scan newer than this answers a refresh without scanning again. */
42
5
  const MIN_RESCAN_INTERVAL_MS = 5_000;
43
6
  const BROWSE_TIMEOUT_MS = 3_000;
@@ -52,10 +15,10 @@ function toFoundHub(candidate) {
52
15
  }
53
16
  async function defaultDiscover(deps) {
54
17
  // Lazy: the socket library is only loaded when an operator asks.
55
- const { discoverHubs } = await Promise.resolve().then(() => __importStar(require('@camstack/develop/hub-discovery')));
18
+ const { discoverHubs } = await import('@camstack/develop/hub-discovery');
56
19
  return discoverHubs(deps);
57
20
  }
58
- function createHubsFinder(deps) {
21
+ export function createHubsFinder(deps) {
59
22
  const discover = deps.discover ?? defaultDiscover;
60
23
  const now = deps.now ?? Date.now;
61
24
  let hubs = [];
@@ -64,13 +27,13 @@ function createHubsFinder(deps) {
64
27
  const snapshot = () => ({ hubs, scannedAt, scanning: inFlight !== null });
65
28
  const scan = async () => {
66
29
  const configured = deps.getConfiguredHubAddress();
67
- const configuredUrl = configured === null ? undefined : (0, derive_hub_url_js_1.deriveHubUrlFromHubAddress)(configured);
30
+ const configuredUrl = configured === null ? undefined : deriveHubUrlFromHubAddress(configured);
68
31
  try {
69
32
  const found = await discover({
70
33
  mdnsTimeoutMs: BROWSE_TIMEOUT_MS,
71
34
  known: configuredUrl === undefined
72
35
  ? []
73
- : [{ url: configuredUrl, source: exports.CONFIGURED_HUB_SOURCE }],
36
+ : [{ url: configuredUrl, source: CONFIGURED_HUB_SOURCE }],
74
37
  onProblem: (message) => deps.log?.(`hub browse problem: ${message}`),
75
38
  });
76
39
  hubs = found.map(toFoundHub);
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * infra-boot-guard.ts — the agent's "did my infrastructure actually load?" gate.
4
3
  *
@@ -33,8 +32,6 @@
33
32
  * first — an operator staring at a crash-loop needs the whole list, and the
34
33
  * four that vanished together on little-unraid vanished for one single reason.
35
34
  */
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.assertRequiredInfraResolved = assertRequiredInfraResolved;
38
35
  /**
39
36
  * Throw when any `required` infra capability resolved to no addon at all.
40
37
  *
@@ -43,7 +40,7 @@ exports.assertRequiredInfraResolved = assertRequiredInfraResolved;
43
40
  * `metrics-provider`, `log-destination`) are the caller's business — they are
44
41
  * already logged individually and are legitimately absent on some nodes.
45
42
  */
46
- function assertRequiredInfraResolved(resolutions, addonsDir) {
43
+ export function assertRequiredInfraResolved(resolutions, addonsDir) {
47
44
  const missing = resolutions.filter((r) => r.required && r.addonId === null).map((r) => r.name);
48
45
  if (missing.length === 0)
49
46
  return;
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.planInfraBoot = planInfraBoot;
4
- exports.planToResolutions = planToResolutions;
5
1
  /**
6
2
  * `log-destination` prefers `hub-forwarder` (ships agent logs to the hub)
7
3
  * over a local winston — mirrors the historical inline choice.
@@ -12,7 +8,7 @@ function pickCandidate(capName, candidates) {
12
8
  }
13
9
  return candidates[0];
14
10
  }
15
- function planInfraBoot(addons, infraList) {
11
+ export function planInfraBoot(addons, infraList) {
16
12
  const initialized = new Set();
17
13
  const steps = [];
18
14
  for (const infra of infraList) {
@@ -40,6 +36,6 @@ function planInfraBoot(addons, infraList) {
40
36
  return steps;
41
37
  }
42
38
  /** Project a plan onto the guard's resolution shape. */
43
- function planToResolutions(steps) {
39
+ export function planToResolutions(steps) {
44
40
  return steps.map((s) => ({ name: s.capName, required: s.required, addonId: s.addonId }));
45
41
  }