@camstack/server 1.2.722 → 1.2.723

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/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.723] - 2026-11-01
11
+
12
+ ### Changed
13
+
14
+ - A browser viewer on an allowed origin can sign in again: the hub accepts the language header in cross-origin requests.
15
+ - An agent no longer spawns an addon whose package is older than the running server requires, and retries a crash-breaker-failed runner once when a reconcile installs a different version of its package
16
+
10
17
  ## [1.2.722] - 2026-11-01
11
18
 
12
19
  ### Changed
@@ -578,11 +578,18 @@ function createAgentService(deps) {
578
578
  * surface a per-agent diff in the upload response.
579
579
  */
580
580
  reload: {
581
- handler: async () => {
581
+ handler: async (ctx) => {
582
582
  if (!deps.reloadDeployedAddons) {
583
583
  return { success: false, loaded: [] };
584
584
  }
585
585
  const loaded = await deps.reloadDeployedAddons();
586
+ // A runner the crash breaker parked `failed` is retried once when this
587
+ // delivery changed its package version (#346). Bounded in the kernel.
588
+ await (0, system_1.asBrokerLike)(ctx.broker)
589
+ .call('$process.retryFailedOnVersionChange', {}, { nodeID: ctx.broker.nodeID, timeout: AGENT_PROCESS_RESTART_TIMEOUT_MS })
590
+ .catch((err) => {
591
+ deploySwapLogger.warn(`failed-runner retry after reload did not run: ${err instanceof Error ? err.message : String(err)}`);
592
+ });
586
593
  // The reload just changed this node's capability set. Re-run the
587
594
  // atomic registerNode so the hub's routing authority learns it now,
588
595
  // instead of at the next restart / reconnect. Unconditional: an
@@ -55,6 +55,9 @@ const agent_pairing_store_js_1 = require("./agent-pairing-store.js");
55
55
  const hub_membership_client_js_1 = require("./hub-membership-client.js");
56
56
  const agent_config_js_1 = require("./agent-config.js");
57
57
  const agent_group_runner_js_1 = require("./agent-group-runner.js");
58
+ const stale_addon_gate_js_1 = require("./stale-addon-gate.js");
59
+ const addon_requirements_js_1 = require("../core/addon/addon-requirements.js");
60
+ const installed_addon_versions_js_1 = require("../core/addon/installed-addon-versions.js");
58
61
  const agent_http_js_1 = require("./agent-http.js");
59
62
  const agent_node_certificates_js_1 = require("./agent-node-certificates.js");
60
63
  const agent_reconnect_js_1 = require("./agent-reconnect.js");
@@ -1300,6 +1303,24 @@ async function bootCoreAddons(broker, config, registry, loadedAddons, loggerFact
1300
1303
  // ---------------------------------------------------------------------------
1301
1304
  // Phase 1.5: Load cluster-capable addon packages
1302
1305
  // ---------------------------------------------------------------------------
1306
+ /**
1307
+ * Hold back the candidates whose package is stale for THIS server (#346) and name
1308
+ * each one. They stay unspawned; the hub's registration reconcile delivers the
1309
+ * right version and the deploy's reload spawns it.
1310
+ */
1311
+ function spawnableCandidates(candidates, addonsDir, log) {
1312
+ if (candidates.length === 0)
1313
+ return candidates;
1314
+ const { ready, deferred } = (0, stale_addon_gate_js_1.gateStaleCandidates)(candidates, {
1315
+ serverVersion: (0, addon_requirements_js_1.readRunningServerVersion)(),
1316
+ serverRequiresAddons: (0, addon_requirements_js_1.readRunningServerAddonMinimums)(),
1317
+ installedVersions: (0, installed_addon_versions_js_1.readInstalledAddonVersions)(addonsDir),
1318
+ requiresOfDir: stale_addon_gate_js_1.readPackageRequires,
1319
+ });
1320
+ for (const d of deferred)
1321
+ log(`[Agent] ${d.reason}`);
1322
+ return ready;
1323
+ }
1303
1324
  async function loadClusterCapableAddons(broker, config, capabilityRegistry, loadedAddons) {
1304
1325
  // Builtins are in-process infra, never group-spawned, and they come from the
1305
1326
  // closure — so the addon-root copy is skipped here too. Leaving it in would
@@ -1349,9 +1370,10 @@ async function loadClusterCapableAddons(broker, config, capabilityRegistry, load
1349
1370
  });
1350
1371
  }
1351
1372
  }
1352
- if (allGroupCandidates.length > 0) {
1373
+ const spawnableGroupCandidates = spawnableCandidates(allGroupCandidates, config.addonsDir, (l) => console.warn(l));
1374
+ if (spawnableGroupCandidates.length > 0) {
1353
1375
  const grouped = new Map();
1354
- for (const c of allGroupCandidates) {
1376
+ for (const c of spawnableGroupCandidates) {
1355
1377
  const arr = grouped.get(c.groupId) ?? [];
1356
1378
  arr.push(c);
1357
1379
  grouped.set(c.groupId, arr);
@@ -1456,7 +1478,7 @@ async function loadDeployedAddons(broker, addonsDir, dataDir, loadedAddons, stor
1456
1478
  return;
1457
1479
  }
1458
1480
  const grouped = new Map();
1459
- for (const c of groupCandidates) {
1481
+ for (const c of spawnableCandidates(groupCandidates, addonsDir, (l) => console.warn(l))) {
1460
1482
  const arr = grouped.get(c.groupId) ?? [];
1461
1483
  arr.push(c);
1462
1484
  grouped.set(c.groupId, arr);
@@ -0,0 +1,102 @@
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.gateStaleCandidates = gateStaleCandidates;
37
+ exports.readPackageRequires = readPackageRequires;
38
+ /**
39
+ * The boot gate for an addon whose package is stale (#346).
40
+ *
41
+ * After `applyServerUpdate` an agent restarts with the addons already on disk.
42
+ * An addon built for the previous framework imports a package the new server no
43
+ * longer carries and crash-loops until the hub's reconcile (D982) replaces it,
44
+ * which can trip the D6 breaker long before the new bytes arrive. The gate
45
+ * decides, from facts both packages declare (D989), that an addon cannot run on
46
+ * this server yet and leaves it unspawned: the hub's registration reconcile
47
+ * delivers the right version, and the deploy's reload spawns it then.
48
+ *
49
+ * Stale means either:
50
+ * - the RUNNING server requires a newer version of this addon's package
51
+ * (`requires.addons` of the server), or
52
+ * - the addon's own `requires.server` is above the running server.
53
+ *
54
+ * A running server version that cannot be read judges nothing (D49: a failed
55
+ * read changes nothing); the addon-minimum check does not need it and still runs.
56
+ */
57
+ const fs = __importStar(require("node:fs"));
58
+ const path = __importStar(require("node:path"));
59
+ const types_1 = require("@camstack/types");
60
+ function gateStaleCandidates(candidates, context) {
61
+ const ready = [];
62
+ const deferred = [];
63
+ for (const candidate of candidates) {
64
+ const minimum = context.serverRequiresAddons[candidate.packageName];
65
+ const fromServer = (0, types_1.unmetRequirements)(minimum === undefined ? undefined : { addons: { [candidate.packageName]: minimum } }, { server: context.serverVersion, addons: context.installedVersions, wrapper: null });
66
+ const own = context.requiresOfDir(candidate.addonDir);
67
+ const fromAddon = context.serverVersion === null
68
+ ? []
69
+ : (0, types_1.unmetRequirements)(own?.server === undefined ? undefined : { server: own.server }, {
70
+ server: context.serverVersion,
71
+ addons: {},
72
+ wrapper: null,
73
+ });
74
+ const unmet = [...fromServer, ...fromAddon];
75
+ if (unmet.length === 0) {
76
+ ready.push(candidate);
77
+ continue;
78
+ }
79
+ deferred.push({
80
+ candidate,
81
+ unmet,
82
+ reason: `addon "${candidate.addonId}" (${candidate.packageName}@${candidate.packageVersion}) deferred until its package is reconciled: ${unmet.map(types_1.describeUnmet).join('; ')}`,
83
+ });
84
+ }
85
+ return { ready, deferred };
86
+ }
87
+ /** `camstack.requires` of the package.json in `dir`; `undefined` when absent or malformed. */
88
+ function readPackageRequires(dir) {
89
+ try {
90
+ const raw = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
91
+ if (typeof raw !== 'object' || raw === null)
92
+ return undefined;
93
+ const camstack = Reflect.get(raw, 'camstack');
94
+ if (typeof camstack !== 'object' || camstack === null)
95
+ return undefined;
96
+ const parsed = types_1.PackageRequiresSchema.safeParse(Reflect.get(camstack, 'requires'));
97
+ return parsed.success ? parsed.data : undefined;
98
+ }
99
+ catch {
100
+ return undefined;
101
+ }
102
+ }
@@ -50,11 +50,12 @@ exports.CORS_ALLOWED_METHODS = 'GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS';
50
50
  /**
51
51
  * Request headers a cross-origin caller may send. `authorization` is the
52
52
  * whole point; `range` is recorded-media seeking; the `trpc-*` / `x-trpc-*`
53
- * names are what `@trpc/client` links may add. NOT `x-camstack-exchange`:
53
+ * names are what `@trpc/client` links may add; `x-camstack-lang` is the
54
+ * language the SDK sends on every request. NOT `x-camstack-exchange`:
54
55
  * the cookie→bearer exchange is a same-origin mechanism and a cross-origin
55
56
  * page has no business asking for it.
56
57
  */
57
- exports.CORS_ALLOWED_HEADERS = 'authorization, content-type, range, if-range, if-none-match, cache-control, trpc-accept, x-trpc-source, x-trpc-batch-mode';
58
+ exports.CORS_ALLOWED_HEADERS = 'authorization, content-type, range, if-range, if-none-match, cache-control, trpc-accept, x-trpc-source, x-trpc-batch-mode, x-camstack-lang';
58
59
  /**
59
60
  * Response headers a cross-origin script may read. The byte-range trio is
60
61
  * recorded playback (a seek reads `content-range`); `content-disposition` is
@@ -122,6 +122,23 @@
122
122
  "`node-turn` in `dependencies` or `peerDependencies`, `dev-only` becomes",
123
123
  "a false claim and CI fails."
124
124
  ]
125
+ },
126
+ {
127
+ "patch": "alexa-cookie2+5.0.6.patch",
128
+ "package": "alexa-cookie2",
129
+ "version": "5.0.6",
130
+ "reach": "bundled",
131
+ "bundledInto": [
132
+ "packages/addon-import-alexa/dist/addon.js",
133
+ "packages/addon-import-alexa/dist/addon.mjs"
134
+ ],
135
+ "markers": ["^upgrade-insecure-requests$"],
136
+ "why": [
137
+ "`alexa-cookie2` is inlined into the addon bundle, so the patched login proxy travels",
138
+ "in `addon.js` / `addon.mjs`. The patch drops Amazon's `upgrade-insecure-requests` CSP",
139
+ "directive from proxied responses (the proxy is plain http). The marker is the regex",
140
+ "source of the directive match, a literal a minifier keeps (checked 2026-11-01)."
141
+ ]
125
142
  }
126
143
  ]
127
144
  }
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.requiresOfVersionDoc = requiresOfVersionDoc;
37
37
  exports.readRunningServerVersion = readRunningServerVersion;
38
38
  exports.unmetAddonRequirements = unmetAddonRequirements;
39
+ exports.readRunningServerAddonMinimums = readRunningServerAddonMinimums;
39
40
  /**
40
41
  * What an addon version declares it needs (`camstack.requires`, D989), judged
41
42
  * against what this node runs. The declaration is read from the registry's
@@ -79,3 +80,22 @@ function unmetAddonRequirements(requires, context) {
79
80
  wrapper: null,
80
81
  });
81
82
  }
83
+ /** What the running `@camstack/server` requires of addon packages; empty when it declares none or cannot be read. */
84
+ function readRunningServerAddonMinimums() {
85
+ const dir = (0, package_dir_utils_js_1.resolveHubClosurePackageDir)('@camstack/server');
86
+ if (dir === null)
87
+ return {};
88
+ try {
89
+ const raw = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
90
+ if (typeof raw !== 'object' || raw === null)
91
+ return {};
92
+ const camstack = Reflect.get(raw, 'camstack');
93
+ if (typeof camstack !== 'object' || camstack === null)
94
+ return {};
95
+ const parsed = types_1.PackageRequiresSchema.safeParse(Reflect.get(camstack, 'requires'));
96
+ return parsed.success ? (parsed.data.addons ?? {}) : {};
97
+ }
98
+ catch {
99
+ return {};
100
+ }
101
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.722",
3
+ "version": "1.2.723",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -66,18 +66,16 @@
66
66
  ],
67
67
  "requires": {
68
68
  "addons": {
69
- "@camstack/addon-admin-ui": ">=1.2.543",
70
- "@camstack/addon-pipeline-orchestrator": ">=1.2.649",
71
- "@camstack/addon-provider-dreame": ">=0.2.163",
72
- "@camstack/addon-provider-dreo": ">=0.2.153",
73
- "@camstack/addon-provider-ecowitt": ">=0.2.154",
74
- "@camstack/addon-provider-enpal": ">=0.1.7",
75
- "@camstack/addon-provider-homematic": ">=1.2.175",
76
- "@camstack/addon-provider-petkit": ">=0.2.158",
77
- "@camstack/addon-provider-rademacher": ">=0.2.156",
78
- "@camstack/addon-provider-unifi": ">=0.2.153",
79
- "@camstack/addon-provider-unraid": ">=0.2.154",
80
- "@camstack/addon-provider-velux": ">=0.2.153"
69
+ "@camstack/addon-admin-ui": ">=1.2.544",
70
+ "@camstack/addon-agent-ui": ">=1.2.308",
71
+ "@camstack/addon-benchmark": ">=1.2.306",
72
+ "@camstack/addon-import-alexa": ">=0.2.175",
73
+ "@camstack/addon-model-studio": ">=1.1.337",
74
+ "@camstack/addon-osd-manager": ">=0.1.310",
75
+ "@camstack/addon-post-analysis": ">=1.2.658",
76
+ "@camstack/addon-provider-homematic": ">=1.2.176",
77
+ "@camstack/addon-provider-velux": ">=0.2.154",
78
+ "@camstack/addon-training": ">=0.1.123"
81
79
  },
82
80
  "wrapper": {
83
81
  "desktop": ">=0.0.1",
@@ -86,19 +84,19 @@
86
84
  }
87
85
  },
88
86
  "dependencies": {
89
- "@camstack/addon-admin-ui": "1.2.543",
90
- "@camstack/addon-agent-ui": "1.2.307",
87
+ "@camstack/addon-admin-ui": "1.2.544",
88
+ "@camstack/addon-agent-ui": "1.2.308",
91
89
  "@camstack/addon-auth": "1.2.175",
92
- "@camstack/addon-benchmark": "1.2.305",
90
+ "@camstack/addon-benchmark": "1.2.306",
93
91
  "@camstack/addon-decoder-nodeav": "1.2.145",
94
92
  "@camstack/addon-notifiers": "1.2.626",
95
93
  "@camstack/addon-pipeline": "1.2.637",
96
94
  "@camstack/addon-pipeline-orchestrator": "1.2.649",
97
- "@camstack/addon-post-analysis": "1.2.657",
95
+ "@camstack/addon-post-analysis": "1.2.658",
98
96
  "@camstack/develop": "0.1.43",
99
97
  "@camstack/sdk": "1.2.155",
100
98
  "@camstack/types": "1.2.464",
101
- "@camstack/ui-library": "1.2.365",
99
+ "@camstack/ui-library": "1.2.366",
102
100
  "@fastify/compress": "^9.0.0",
103
101
  "@fastify/cookie": "^11.0.2",
104
102
  "@fastify/cors": "^11.2.0",
@@ -1,6 +1,6 @@
1
1
  import { Cs as toNodeId, Ms as EventCategory, Qa as BaseAddon, Wr as mayWriteToLocation, an as backupCapability, ls as nodePin, na as storageOccupancyCapability } from "../../dist-DcMqHB_N.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
- import { _ as backupRecordStoresOf, a as BackupSnapshotRefusedError, d as ENCRYPTED_BACKUP_SUFFIX, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, i as BackupCancelledError, l as BackupKeyFormatError, m as parseBackupSecretKey, n as precheckRestoreKey, o as DEFAULT_BACKUP_DATABASES, p as parseBackupPublicKey, r as prepareRestoreArchive, s as SystemBackupService } from "../../restore-archive-DS4nvQ43.mjs";
3
+ import { _ as backupRecordStoresOf, a as BackupSnapshotRefusedError, d as ENCRYPTED_BACKUP_SUFFIX, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, i as BackupCancelledError, l as BackupKeyFormatError, m as parseBackupSecretKey, n as precheckRestoreKey, o as DEFAULT_BACKUP_DATABASES, p as parseBackupPublicKey, r as prepareRestoreArchive, s as SystemBackupService } from "../../restore-archive-B-SaKSVW.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import * as fsp from "node:fs/promises";
6
6
  import * as path$1 from "node:path";