@camstack/server 1.2.1 → 1.2.3

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.
@@ -64,6 +64,7 @@ const fs = __importStar(require("node:fs"));
64
64
  const path = __importStar(require("node:path"));
65
65
  const index_js_1 = require("../server-root/index.js");
66
66
  const system_exec_npm_js_1 = require("../core/server-update/system-exec-npm.js");
67
+ const system_ensure_prebuilds_js_1 = require("../core/server-update/system-ensure-prebuilds.js");
67
68
  /**
68
69
  * The synthetic addonId the agent's OWN runtime registers infra providers
69
70
  * under (no addon owns them — the bootstrap does). Appears in the agent's
@@ -167,6 +168,10 @@ class AgentUpdateService extends index_js_1.RootUpdateService {
167
168
  cacheDir: path.join(options.dataDir, 'addons', '.npm-bootstrap'),
168
169
  logger: options.logger,
169
170
  }),
171
+ // Same native-prebuild ensure step as the hub — a packaged desktop AGENT
172
+ // ships the identical bare Node, so its `applyServerUpdate` staging would
173
+ // hit the same source-only `better-sqlite3` miss without this.
174
+ ensureNativePrebuilds: options.ensureNativePrebuilds ?? (0, system_ensure_prebuilds_js_1.buildSystemEnsureNativePrebuilds)(options.logger),
170
175
  env: options.env,
171
176
  now: options.now,
172
177
  });
@@ -54,6 +54,7 @@ exports.ServerUpdateService = void 0;
54
54
  const path = __importStar(require("node:path"));
55
55
  const index_js_1 = require("../../server-root/index.js");
56
56
  const system_exec_npm_js_1 = require("./system-exec-npm.js");
57
+ const system_ensure_prebuilds_js_1 = require("./system-ensure-prebuilds.js");
57
58
  class ServerUpdateService extends index_js_1.RootUpdateService {
58
59
  constructor(options) {
59
60
  const dataDir = path.resolve(options.dataDir ??
@@ -82,6 +83,10 @@ class ServerUpdateService extends index_js_1.RootUpdateService {
82
83
  cacheDir: path.join(dataDir, 'addons', '.npm-bootstrap'),
83
84
  logger: options.logger,
84
85
  }),
86
+ // Fetch a missing `better-sqlite3` prebuild for the running ABI before the
87
+ // native-prebuild validator refuses the swap (toolchain-less packaged
88
+ // desktop). No-op on docker where the install already carried it.
89
+ ensureNativePrebuilds: options.ensureNativePrebuilds ?? (0, system_ensure_prebuilds_js_1.buildSystemEnsureNativePrebuilds)(options.logger),
85
90
  env: options.env,
86
91
  now: options.now,
87
92
  });
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildSystemEnsureNativePrebuilds = buildSystemEnsureNativePrebuilds;
4
+ /**
5
+ * `buildSystemEnsureNativePrebuilds` — the `@camstack/system`-backed
6
+ * `ensureNativePrebuilds` adapter the shared `RootUpdateService` uses as its
7
+ * post-install native-prebuild ENSURE step (`RootUpdateServiceOptions.
8
+ * ensureNativePrebuilds`).
9
+ *
10
+ * The zero-dep `@camstack/node-root` layer cannot fetch npm packages itself, so
11
+ * the fetcher lives in `@camstack/system` (next to `runNpm` / the addon
12
+ * native-deps installer) and is injected here at the hub/agent construction
13
+ * sites — exactly like `buildSystemExecNpm`. Harmless on docker (the prebuilds
14
+ * already landed → a no-op); it only acts on a toolchain-less packaged desktop
15
+ * whose `npm install` left `better-sqlite3` source-only.
16
+ */
17
+ const system_1 = require("@camstack/system");
18
+ function buildSystemEnsureNativePrebuilds(logger) {
19
+ return async (closureDir) => {
20
+ await (0, system_1.ensureNativePrebuilds)(closureDir, { logger });
21
+ };
22
+ }
@@ -873,6 +873,7 @@ var require_dist = __commonJS({
873
873
  restartServerFn;
874
874
  dataDir;
875
875
  execNpm;
876
+ ensureNativePrebuildsFn;
876
877
  env;
877
878
  now;
878
879
  runningPackageJsonPath;
@@ -896,6 +897,7 @@ var require_dist = __commonJS({
896
897
  stdout
897
898
  };
898
899
  });
900
+ this.ensureNativePrebuildsFn = options.ensureNativePrebuilds ?? (async () => void 0);
899
901
  this.env = options.env ?? process.env;
900
902
  this.now = options.now ?? Date.now;
901
903
  this.runningPackageJsonPath = options.runningPackageJsonPath;
@@ -1178,6 +1180,15 @@ var require_dist = __commonJS({
1178
1180
  if (invalid !== null) {
1179
1181
  throw new Error(`staged closure invalid: ${invalid}`);
1180
1182
  }
1183
+ try {
1184
+ await this.ensureNativePrebuildsFn(stagingDir);
1185
+ } catch (err) {
1186
+ this.logger.warn("native-prebuild ensure step failed \u2014 validator will decide", {
1187
+ meta: {
1188
+ error: err instanceof Error ? err.message : String(err)
1189
+ }
1190
+ });
1191
+ }
1181
1192
  const missingNatives = findMissingNativePrebuilds(stagingDir);
1182
1193
  if (missingNatives.length > 0) {
1183
1194
  throw new Error(`staged closure missing native prebuilds: ${missingNatives.join(", ")} \u2014 refusing to arm a swap that would break the forked runners`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",
@@ -33,20 +33,20 @@
33
33
  ]
34
34
  },
35
35
  "dependencies": {
36
- "@camstack/addon-admin-ui": "1.2.1",
37
- "@camstack/addon-advanced-notifier": "1.2.1",
38
- "@camstack/addon-agent-ui": "1.2.1",
39
- "@camstack/addon-auth": "1.2.1",
40
- "@camstack/addon-decoder-nodeav": "1.2.1",
41
- "@camstack/addon-notifiers": "1.2.1",
42
- "@camstack/addon-pipeline": "1.2.1",
43
- "@camstack/addon-pipeline-orchestrator": "1.2.1",
44
- "@camstack/addon-post-analysis": "1.2.1",
45
- "@camstack/sdk": "1.2.1",
46
- "@camstack/shm-ring": "1.1.1",
47
- "@camstack/system": "1.2.1",
48
- "@camstack/types": "1.2.1",
49
- "@camstack/ui-library": "1.2.1",
36
+ "@camstack/addon-admin-ui": "1.2.3",
37
+ "@camstack/addon-advanced-notifier": "1.2.3",
38
+ "@camstack/addon-agent-ui": "1.2.3",
39
+ "@camstack/addon-auth": "1.2.3",
40
+ "@camstack/addon-decoder-nodeav": "1.2.3",
41
+ "@camstack/addon-notifiers": "1.2.3",
42
+ "@camstack/addon-pipeline": "1.2.3",
43
+ "@camstack/addon-pipeline-orchestrator": "1.2.3",
44
+ "@camstack/addon-post-analysis": "1.2.3",
45
+ "@camstack/sdk": "1.2.3",
46
+ "@camstack/shm-ring": "1.1.3",
47
+ "@camstack/system": "1.2.3",
48
+ "@camstack/types": "1.2.3",
49
+ "@camstack/ui-library": "1.2.3",
50
50
  "@fastify/compress": "^9.0.0",
51
51
  "@fastify/cookie": "^11.0.2",
52
52
  "@fastify/cors": "^11.2.0",