@camstack/server 1.2.163 → 1.2.165
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.
- package/dist/agent/agent-http.js +14 -2
- package/dist/agent/main.js +33 -32
- package/dist/core/addon/addon-registry.service.js +24 -3
- package/dist/launcher.js +6 -3
- package/dist/package-inventory.js +21 -1
- package/package.json +3 -3
package/dist/agent/agent-http.js
CHANGED
|
@@ -53,9 +53,9 @@ exports.startAgentHttpServer = startAgentHttpServer;
|
|
|
53
53
|
const fs = __importStar(require("node:fs"));
|
|
54
54
|
const path = __importStar(require("node:path"));
|
|
55
55
|
const fastify_1 = __importDefault(require("fastify"));
|
|
56
|
+
const agent_http_auth_js_1 = require("./agent-http-auth.js");
|
|
56
57
|
const derive_hub_url_js_1 = require("./derive-hub-url.js");
|
|
57
58
|
Object.defineProperty(exports, "pickIpv4", { enumerable: true, get: function () { return derive_hub_url_js_1.pickIpv4; } });
|
|
58
|
-
const agent_http_auth_js_1 = require("./agent-http-auth.js");
|
|
59
59
|
/** Dotted-numeric version compare; `null` sorts lowest. */
|
|
60
60
|
function compareVersions(a, b) {
|
|
61
61
|
if (a === null && b === null)
|
|
@@ -101,6 +101,12 @@ function readUiDistCandidate(baseDir) {
|
|
|
101
101
|
* packaged desktop app that ships a newer agent-ui in its resources would
|
|
102
102
|
* otherwise keep serving the UI frozen at whatever version was first
|
|
103
103
|
* installed (observed live: an app at v1.1.27 serving the v1.1.1 UI).
|
|
104
|
+
*
|
|
105
|
+
* This is the ONE runtime reader of `CAMSTACK_BUNDLED_ADDONS_DIR` that reads a
|
|
106
|
+
* package OUT of it (the rest only seed from it, or use it to locate the
|
|
107
|
+
* Electron Resources root). It reads the bundled copy in place and serves it
|
|
108
|
+
* over `@fastify/static` — so which dir that variable names is load-bearing
|
|
109
|
+
* here, not just at first boot.
|
|
104
110
|
*/
|
|
105
111
|
function pickUiDist(installed, bundled) {
|
|
106
112
|
if (installed && bundled) {
|
|
@@ -108,7 +114,13 @@ function pickUiDist(installed, bundled) {
|
|
|
108
114
|
}
|
|
109
115
|
return installed?.dir ?? bundled?.dir ?? null;
|
|
110
116
|
}
|
|
111
|
-
function resolveUiDistDir(dataDir,
|
|
117
|
+
function resolveUiDistDir(dataDir,
|
|
118
|
+
// `CAMSTACK_BUNDLED_ADDONS_DIR` — a dir of package dirs keyed by SHORT name
|
|
119
|
+
// (`<dir>/addon-agent-ui`), the same shape `AddonInstaller.findLocalPackage`
|
|
120
|
+
// joins onto. On a packaged desktop that is the closure's own scope dir,
|
|
121
|
+
// `Contents/Resources/node_modules/@camstack`; it was a second, hand-copied
|
|
122
|
+
// `Contents/Resources/addons` tree until 2026-08-25.
|
|
123
|
+
bundledAddonsDir,
|
|
112
124
|
// Workspace / npm-package sibling — dev checkouts and Docker images where
|
|
113
125
|
// @camstack/addon-agent-ui sits next to @camstack/agent in node_modules.
|
|
114
126
|
// Always version-matched to the agent, so it keeps top priority.
|
package/dist/agent/main.js
CHANGED
|
@@ -36,22 +36,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.startAgent = startAgent;
|
|
37
37
|
const fs = __importStar(require("node:fs"));
|
|
38
38
|
const path = __importStar(require("node:path"));
|
|
39
|
-
const agent_http_js_1 = require("./agent-http.js");
|
|
40
|
-
const single_copy_cleanup_runner_js_1 = require("../single-copy-cleanup-runner.js");
|
|
41
|
-
const derive_hub_url_js_1 = require("./derive-hub-url.js");
|
|
42
39
|
const system_1 = require("@camstack/system");
|
|
43
|
-
const types_1 = require("@camstack/types");
|
|
44
40
|
// Capability definitions — must be declared before addon registerProvider() calls
|
|
45
|
-
const
|
|
46
|
-
const agent_config_js_1 = require("./agent-config.js");
|
|
47
|
-
const agent_update_service_js_1 = require("./agent-update-service.js");
|
|
41
|
+
const types_1 = require("@camstack/types");
|
|
48
42
|
const server_management_provider_js_1 = require("../api/core/server-management.provider.js");
|
|
49
|
-
const infra_boot_guard_js_1 = require("./infra-boot-guard.js");
|
|
50
|
-
const infra_boot_plan_js_1 = require("./infra-boot-plan.js");
|
|
51
43
|
const package_dir_utils_js_1 = require("../core/addon/package-dir-utils.js");
|
|
44
|
+
const single_copy_cleanup_runner_js_1 = require("../single-copy-cleanup-runner.js");
|
|
52
45
|
const addon_scan_js_1 = require("./addon-scan.js");
|
|
53
|
-
const
|
|
46
|
+
const agent_config_js_1 = require("./agent-config.js");
|
|
54
47
|
const agent_group_runner_js_1 = require("./agent-group-runner.js");
|
|
48
|
+
const agent_http_js_1 = require("./agent-http.js");
|
|
49
|
+
const agent_service_js_1 = require("./agent-service.js");
|
|
50
|
+
const agent_update_service_js_1 = require("./agent-update-service.js");
|
|
51
|
+
const derive_hub_url_js_1 = require("./derive-hub-url.js");
|
|
52
|
+
const infra_boot_guard_js_1 = require("./infra-boot-guard.js");
|
|
53
|
+
const infra_boot_plan_js_1 = require("./infra-boot-plan.js");
|
|
55
54
|
const register_agent_cap_dispatch_js_1 = require("./register-agent-cap-dispatch.js");
|
|
56
55
|
// ---------------------------------------------------------------------------
|
|
57
56
|
// Agent LogManager — shared log pipeline for all addon loggers.
|
|
@@ -71,7 +70,7 @@ const agentLogManager = new system_2.LogManager(5000);
|
|
|
71
70
|
* the hub singleton (which reads `nodeId` as data) instead of being pinned to
|
|
72
71
|
* a node with no provider (dead broker fallback → ServiceNotFoundError).
|
|
73
72
|
*/
|
|
74
|
-
const DATA_NODEID_CAPS = new Set(
|
|
73
|
+
const DATA_NODEID_CAPS = new Set(types_1.ALL_CAPABILITY_DEFINITIONS.filter((c) => c.nodeIdMode === 'data').map((c) => c.name));
|
|
75
74
|
// ---------------------------------------------------------------------------
|
|
76
75
|
// Main
|
|
77
76
|
// ---------------------------------------------------------------------------
|
|
@@ -100,8 +99,10 @@ async function startAgent(configPath) {
|
|
|
100
99
|
console.log(`[Agent] Data dir: ${config.dataDir}`);
|
|
101
100
|
// Ensure required addon packages are installed in the agent's addonsDir.
|
|
102
101
|
// Resolution order:
|
|
103
|
-
// 1. `CAMSTACK_BUNDLED_ADDONS_DIR` — Electron-packaged builds copy
|
|
104
|
-
//
|
|
102
|
+
// 1. `CAMSTACK_BUNDLED_ADDONS_DIR` — Electron-packaged builds copy out of
|
|
103
|
+
// the closure's own scope dir, `<resourcesPath>/node_modules/@camstack`
|
|
104
|
+
// (`'local'` mode). Was a second `<resourcesPath>/addons` tree until
|
|
105
|
+
// 2026-08-25 — see `packages/desktop/src/process-manager.ts`.
|
|
105
106
|
// 2. Otherwise npm from registry. Local dev pushes addons via
|
|
106
107
|
// `camstack deploy` (CLI tarball upload), bypassing this path.
|
|
107
108
|
const explicitSource = process.env['CAMSTACK_INSTALL_SOURCE'];
|
|
@@ -325,30 +326,30 @@ async function startAgent(configPath) {
|
|
|
325
326
|
const capabilityRegistry = new system_1.CapabilityRegistry(consoleLogger);
|
|
326
327
|
// Declare all capabilities the agent uses — required before registerProvider()
|
|
327
328
|
const agentCapabilities = [
|
|
328
|
-
|
|
329
|
-
|
|
329
|
+
types_1.storageCapability,
|
|
330
|
+
types_1.storageProviderCapability,
|
|
330
331
|
// The path browser for "add a storage location on this node" — the agent
|
|
331
332
|
// registers the provider since day one, but without DECLARING the cap
|
|
332
333
|
// here the hub's manifest never learns of it and node-routed browse
|
|
333
334
|
// answers "not available on node X" (2026-07-30 fix).
|
|
334
|
-
|
|
335
|
+
types_1.filesystemBrowseCapability,
|
|
335
336
|
// The agent runs the same two-addon data topology as the hub (D44):
|
|
336
337
|
// `settings-store` is the door served by storage-orchestrator,
|
|
337
338
|
// `data-store-provider` is the engine sqlite-settings registers. BOTH
|
|
338
339
|
// must be declared here — this array is hand-curated and nothing else
|
|
339
340
|
// teaches an agent a capability, so omitting the engine leaves the
|
|
340
341
|
// agent's door with nothing behind it.
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
342
|
+
types_1.settingsStoreCapability,
|
|
343
|
+
types_1.dataStoreProviderCapability,
|
|
344
|
+
types_1.logDestinationCapability,
|
|
345
|
+
types_1.metricsProviderCapability,
|
|
346
|
+
types_1.decoderCapability,
|
|
347
|
+
types_1.motionDetectionCapability,
|
|
348
|
+
types_1.pipelineExecutorCapability,
|
|
349
|
+
types_1.pipelineRunnerCapability,
|
|
350
|
+
types_1.audioAnalyzerCapability,
|
|
351
|
+
types_1.platformProbeCapability,
|
|
352
|
+
types_1.serverManagementCapability,
|
|
352
353
|
];
|
|
353
354
|
for (const cap of agentCapabilities) {
|
|
354
355
|
capabilityRegistry.declareCapability(cap);
|
|
@@ -817,7 +818,7 @@ async function bootCoreAddons(broker, config, registry, loadedAddons, loggerFact
|
|
|
817
818
|
await loader.loadFromAddonDir(dir);
|
|
818
819
|
}
|
|
819
820
|
catch (err) {
|
|
820
|
-
console.warn(`[Agent] Failed to scan ${dir}: ${(0,
|
|
821
|
+
console.warn(`[Agent] Failed to scan ${dir}: ${(0, types_1.errMsg)(err)}`);
|
|
821
822
|
}
|
|
822
823
|
}
|
|
823
824
|
// Resolution is per-CAPABILITY (the guard names every missing required
|
|
@@ -888,7 +889,7 @@ async function bootCoreAddons(broker, config, registry, loadedAddons, loggerFact
|
|
|
888
889
|
console.log(`[Agent] Core addon "${addonId}" initialized`);
|
|
889
890
|
}
|
|
890
891
|
catch (err) {
|
|
891
|
-
const msg = (0,
|
|
892
|
+
const msg = (0, types_1.errMsg)(err);
|
|
892
893
|
console.error(`[Agent] Failed to initialize core addon "${addonId}": ${msg}`);
|
|
893
894
|
if (step.required) {
|
|
894
895
|
throw new Error(`Required infrastructure addon "${addonId}" failed: ${msg}`, { cause: err });
|
|
@@ -931,7 +932,7 @@ async function loadClusterCapableAddons(broker, config, capabilityRegistry, load
|
|
|
931
932
|
await loader.loadFromAddonDir(dir);
|
|
932
933
|
}
|
|
933
934
|
catch (err) {
|
|
934
|
-
console.warn(`[Agent] Skipping ${dir}: ${(0,
|
|
935
|
+
console.warn(`[Agent] Skipping ${dir}: ${(0, types_1.errMsg)(err)}`);
|
|
935
936
|
continue;
|
|
936
937
|
}
|
|
937
938
|
dirToLoader.set(dir, loader);
|
|
@@ -1092,7 +1093,7 @@ async function loadInProcessDeployedAddons(broker, dirs, dataDir, loadedAddons,
|
|
|
1092
1093
|
await loader.loadFromAddonDir(dir);
|
|
1093
1094
|
}
|
|
1094
1095
|
catch (err) {
|
|
1095
|
-
console.warn(`[Agent] Skipping ${dir}: ${(0,
|
|
1096
|
+
console.warn(`[Agent] Skipping ${dir}: ${(0, types_1.errMsg)(err)}`);
|
|
1096
1097
|
continue;
|
|
1097
1098
|
}
|
|
1098
1099
|
for (const registered of loader.listAddons()) {
|
|
@@ -1121,7 +1122,7 @@ async function loadInProcessDeployedAddons(broker, dirs, dataDir, loadedAddons,
|
|
|
1121
1122
|
console.log(`[Agent] Deployed addon "${addonId}" loaded in-process`);
|
|
1122
1123
|
}
|
|
1123
1124
|
catch (err) {
|
|
1124
|
-
const msg = (0,
|
|
1125
|
+
const msg = (0, types_1.errMsg)(err);
|
|
1125
1126
|
console.error(`[Agent] Failed to load deployed addon "${addonId}": ${msg}`);
|
|
1126
1127
|
loadedAddons.set(addonId, { id: addonId, status: 'error' });
|
|
1127
1128
|
}
|
|
@@ -1069,10 +1069,26 @@ class AddonRegistryService {
|
|
|
1069
1069
|
// Forked addons only for now — co-located builtins would publish into the
|
|
1070
1070
|
// registry directly via a hub-side sink (deferred; no builtin serves a
|
|
1071
1071
|
// data-plane yet).
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1072
|
+
//
|
|
1073
|
+
// Each of these three exits means "this addon CANNOT serve a data-plane
|
|
1074
|
+
// right now", and every one of them used to leave the previous registration
|
|
1075
|
+
// standing. The registry then held a `baseUrl` pointing at the port of a
|
|
1076
|
+
// process that no longer exists, and `/addon/:addonId/*` kept reverse-
|
|
1077
|
+
// proxying to it — a 502 per request until the replacement child finished
|
|
1078
|
+
// its handshake, or forever if the addon was removed. `unregisterAddon`
|
|
1079
|
+
// existed for exactly this and had no call site anywhere in the repo.
|
|
1080
|
+
//
|
|
1081
|
+
// Dropping is the safe direction: a data-plane that is absent from the
|
|
1082
|
+
// registry falls through to the control-route path, while a stale one
|
|
1083
|
+
// sends live traffic at a dead socket.
|
|
1084
|
+
if (!(0, system_1.canServeDataPlane)({
|
|
1085
|
+
hasEntry: entry !== undefined,
|
|
1086
|
+
isForked: entry !== undefined && this.isForkedAddonEntry(entry),
|
|
1087
|
+
childKnown: childRegistry !== null && childRegistry.isChildKnown(this.childIdForAddon(addonId)),
|
|
1088
|
+
})) {
|
|
1089
|
+
registry.unregisterAddon(addonId);
|
|
1075
1090
|
return;
|
|
1091
|
+
}
|
|
1076
1092
|
const raw = await this.addonCallGateway.callForked(addonId, { target: 'data-planes' });
|
|
1077
1093
|
const endpoints = parseDataPlaneEndpoints(raw);
|
|
1078
1094
|
registry.registerAddon(addonId, endpoints);
|
|
@@ -2344,6 +2360,11 @@ class AddonRegistryService {
|
|
|
2344
2360
|
await this.drainDisposerChain(id);
|
|
2345
2361
|
}
|
|
2346
2362
|
this.addonEntries.delete(id);
|
|
2363
|
+
// An addon that is gone from disk will never re-handshake, so nothing
|
|
2364
|
+
// else will ever refresh or drop its data-plane. Without this the
|
|
2365
|
+
// registry keeps proxying `/addon/<id>/*` at a dead port for the rest
|
|
2366
|
+
// of the process lifetime.
|
|
2367
|
+
this.dataPlaneRegistry?.unregisterAddon(id);
|
|
2347
2368
|
this.logger.info('Removed addon (no longer on disk)', { tags: { addonId: id } });
|
|
2348
2369
|
}
|
|
2349
2370
|
}
|
package/dist/launcher.js
CHANGED
|
@@ -333,9 +333,11 @@ async function launch() {
|
|
|
333
333
|
console.warn('[launcher] quarantineAddonResidue unavailable — skipping residue quarantine');
|
|
334
334
|
}
|
|
335
335
|
// Install source resolution:
|
|
336
|
-
// 1. CAMSTACK_BUNDLED_ADDONS_DIR — set by Electron-packaged builds
|
|
337
|
-
//
|
|
338
|
-
//
|
|
336
|
+
// 1. CAMSTACK_BUNDLED_ADDONS_DIR — set by Electron-packaged builds to
|
|
337
|
+
// the closure's own scope dir, <resourcesPath>/node_modules/@camstack.
|
|
338
|
+
// Pre-built addons ship inside that closure and are copied out of it at
|
|
339
|
+
// first launch (`'local'` mode). ONE copy in the bundle: the app used to
|
|
340
|
+
// ship a second, hand-copied <resourcesPath>/addons tree as well (D45).
|
|
339
341
|
// 2. CAMSTACK_INSTALL_SOURCE=local — explicit opt-in to copy from
|
|
340
342
|
// the monorepo workspace (used by e2e + dev bootstrap). Hub
|
|
341
343
|
// auto-detects `packages/` via detectWorkspacePackagesDir.
|
|
@@ -561,6 +563,7 @@ async function launch() {
|
|
|
561
563
|
pathSeparator: process.platform === 'win32' ? ';' : ':',
|
|
562
564
|
dataDir: DATA_DIR,
|
|
563
565
|
serverNodeModules: nodeModulesDir,
|
|
566
|
+
frameworkRoots: frameworkPaths,
|
|
564
567
|
seedRoots: (0, package_inventory_js_1.seedNodeModulesRoots)(fs),
|
|
565
568
|
}), {
|
|
566
569
|
exists: (dir) => fs.existsSync(path.join(dir, 'package.json')),
|
|
@@ -100,8 +100,27 @@ function hostProvidedSearchRoots(input) {
|
|
|
100
100
|
.map((p) => p.trim())
|
|
101
101
|
.filter((p) => p.length > 0);
|
|
102
102
|
const seedPaths = new Set(input.seedRoots);
|
|
103
|
+
// BOTH deposit directories are active, and calling only one of them so is how
|
|
104
|
+
// this guard spent every boot accusing the healthy layout.
|
|
105
|
+
//
|
|
106
|
+
// `serverNodeModules` is `@camstack/server/node_modules` — the NESTED tree,
|
|
107
|
+
// which resolves that package's own dependencies. The framework packages
|
|
108
|
+
// (`system`, `types`, `sdk`) do NOT live there: they resolve from the closure
|
|
109
|
+
// directory one level up, which the launcher puts on NODE_PATH and logs as
|
|
110
|
+
// "Framework dir on NODE_PATH". With only the nested tree marked active, the
|
|
111
|
+
// closure arrived through NODE_PATH and was classified `unexpected`, so on
|
|
112
|
+
// the live hub of 2026-08-25 the guard called the copies that actually run
|
|
113
|
+
// "UNEXPECTED — remove it" and, left with the baked seeds as the only
|
|
114
|
+
// candidates, declared them "CONFLICTS — could run" against each other.
|
|
115
|
+
//
|
|
116
|
+
// The runtime's own single-copy sweep disagreed in the same boot
|
|
117
|
+
// (`single-copy cleanup — 0 copy(ies) to remove`). Two checkers, one disk,
|
|
118
|
+
// opposite verdicts — and the one that shouts is the one that was wrong. A
|
|
119
|
+
// guard that fires on the healthy state is ignored when it fires on the
|
|
120
|
+
// broken one, which is the failure D45 exists to catch.
|
|
121
|
+
const activePaths = new Set([input.serverNodeModules, ...(input.frameworkRoots ?? [])]);
|
|
103
122
|
const expectationFor = (dir) => {
|
|
104
|
-
if (dir
|
|
123
|
+
if (activePaths.has(dir))
|
|
105
124
|
return 'active';
|
|
106
125
|
if (seedPaths.has(dir))
|
|
107
126
|
return 'seed';
|
|
@@ -109,6 +128,7 @@ function hostProvidedSearchRoots(input) {
|
|
|
109
128
|
};
|
|
110
129
|
const roots = [
|
|
111
130
|
{ path: input.serverNodeModules, expectation: 'active' },
|
|
131
|
+
...(input.frameworkRoots ?? []).map((p) => ({ path: p, expectation: expectationFor(p) })),
|
|
112
132
|
...fromNodePath.map((p) => ({ path: p, expectation: expectationFor(p) })),
|
|
113
133
|
{ path: path.join(input.dataDir, 'framework', 'node_modules'), expectation: 'unexpected' },
|
|
114
134
|
{ path: path.join(input.dataDir, 'addons'), expectation: 'unexpected' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.165",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@camstack/addon-auth": "1.2.31",
|
|
39
39
|
"@camstack/addon-decoder-nodeav": "1.2.27",
|
|
40
40
|
"@camstack/addon-notifiers": "1.2.32",
|
|
41
|
-
"@camstack/addon-pipeline": "1.2.
|
|
41
|
+
"@camstack/addon-pipeline": "1.2.127",
|
|
42
42
|
"@camstack/addon-pipeline-orchestrator": "1.2.105",
|
|
43
43
|
"@camstack/addon-post-analysis": "1.2.124",
|
|
44
44
|
"@camstack/sdk": "1.2.31",
|
|
45
|
-
"@camstack/system": "1.2.
|
|
45
|
+
"@camstack/system": "1.2.133",
|
|
46
46
|
"@camstack/types": "1.2.105",
|
|
47
47
|
"@camstack/ui-library": "1.2.71",
|
|
48
48
|
"@fastify/compress": "^9.0.0",
|