camstack 1.2.74 → 1.2.76
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/cli.js
CHANGED
|
@@ -38,7 +38,7 @@ async function runServe(args) {
|
|
|
38
38
|
...typeof values.data === "string" ? { data: values.data } : {}
|
|
39
39
|
};
|
|
40
40
|
Object.assign(process.env, buildServeEnv(opts));
|
|
41
|
-
await import("./launcher-
|
|
41
|
+
await import("./launcher-WOTGVQN3.js");
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
// src/commands/agent.ts
|
|
@@ -83,7 +83,7 @@ async function runAgent(args) {
|
|
|
83
83
|
...typeof values.port === "string" ? { port: values.port } : {}
|
|
84
84
|
};
|
|
85
85
|
Object.assign(process.env, buildAgentEnv(opts));
|
|
86
|
-
await import("./launcher-
|
|
86
|
+
await import("./launcher-WOTGVQN3.js");
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// src/commands/setup.ts
|
|
@@ -133677,7 +133677,6 @@ var require_dist3 = __commonJS({
|
|
|
133677
133677
|
routerFactory = null;
|
|
133678
133678
|
configReader = null;
|
|
133679
133679
|
collectionConfigReader = null;
|
|
133680
|
-
configManager = null;
|
|
133681
133680
|
_ready = false;
|
|
133682
133681
|
/** Boot-time dependency graph: capability → dependsOn names (from CapabilityDeclaration) */
|
|
133683
133682
|
capabilityDeps = /* @__PURE__ */ new Map();
|
|
@@ -133762,10 +133761,6 @@ var require_dist3 = __commonJS({
|
|
|
133762
133761
|
setCollectionConfigReader(reader) {
|
|
133763
133762
|
this.collectionConfigReader = reader;
|
|
133764
133763
|
}
|
|
133765
|
-
/** Set the config manager for persisted device activation state. */
|
|
133766
|
-
setConfigManager(manager) {
|
|
133767
|
-
this.configManager = manager;
|
|
133768
|
-
}
|
|
133769
133764
|
/** Register boot-time dependency edges (from CapabilityDeclaration.dependsOn). */
|
|
133770
133765
|
setDependencies(capabilityName, dependsOn) {
|
|
133771
133766
|
this.capabilityDeps.set(capabilityName, dependsOn);
|
|
@@ -134501,88 +134496,18 @@ var require_dist3 = __commonJS({
|
|
|
134501
134496
|
});
|
|
134502
134497
|
}
|
|
134503
134498
|
/**
|
|
134504
|
-
* Check if a specific addon's capability is active
|
|
134499
|
+
* Check if a specific addon's capability is active.
|
|
134505
134500
|
*
|
|
134506
|
-
* Resolution:
|
|
134501
|
+
* Resolution: the manifest's `autoActivate` flag, else active. There is no
|
|
134502
|
+
* persisted override layer — see D334: an activation map keyed by
|
|
134503
|
+
* `{capability}/{addonId}` is a second authority over a function some addon
|
|
134504
|
+
* already owns, which is what D62 forbids.
|
|
134507
134505
|
*/
|
|
134508
134506
|
isActiveForSystem(capability, addonId) {
|
|
134509
|
-
if (this.configManager) {
|
|
134510
|
-
const explicit = this.configManager.getSystemActivation()[`${capability}/${addonId}`];
|
|
134511
|
-
if (explicit !== void 0) return explicit;
|
|
134512
|
-
}
|
|
134513
134507
|
const autoActivate = this.autoActivateFlags.get(`${capability}/${addonId}`);
|
|
134514
134508
|
if (autoActivate !== void 0) return autoActivate;
|
|
134515
134509
|
return true;
|
|
134516
134510
|
}
|
|
134517
|
-
/** Set system-wide activation for a capability/addon pair. */
|
|
134518
|
-
setSystemActivation(capability, addonId, active) {
|
|
134519
|
-
if (!this.configManager) {
|
|
134520
|
-
this.logger.warn("Cannot set system activation: ConfigManager not wired");
|
|
134521
|
-
return;
|
|
134522
|
-
}
|
|
134523
|
-
this.configManager.setSystemActivation(capability, addonId, active);
|
|
134524
|
-
this.logger.info("System activation set", {
|
|
134525
|
-
tags: { addonId },
|
|
134526
|
-
meta: {
|
|
134527
|
-
capability,
|
|
134528
|
-
active
|
|
134529
|
-
}
|
|
134530
|
-
});
|
|
134531
|
-
this.emitEvent("capability:system-activation-changed", {
|
|
134532
|
-
capability,
|
|
134533
|
-
addonId,
|
|
134534
|
-
active
|
|
134535
|
-
});
|
|
134536
|
-
}
|
|
134537
|
-
/**
|
|
134538
|
-
* Check if a specific addon's capability is active for a device.
|
|
134539
|
-
*
|
|
134540
|
-
* Resolution: 1. explicit device override → 2. system activation → 3. autoActivate → 4. default true
|
|
134541
|
-
*/
|
|
134542
|
-
isActiveForDevice(capability, addonId, deviceId) {
|
|
134543
|
-
if (this.configManager) {
|
|
134544
|
-
const explicit = this.configManager.getDeviceActivation(deviceId)[`${capability}/${addonId}`];
|
|
134545
|
-
if (explicit !== void 0) return explicit;
|
|
134546
|
-
}
|
|
134547
|
-
return this.isActiveForSystem(capability, addonId);
|
|
134548
|
-
}
|
|
134549
|
-
/** Set device activation for a capability/addon pair. */
|
|
134550
|
-
setDeviceActivation(deviceId, capability, addonId, active) {
|
|
134551
|
-
if (!this.configManager) {
|
|
134552
|
-
this.logger.warn("Cannot set device activation: ConfigManager not wired");
|
|
134553
|
-
return;
|
|
134554
|
-
}
|
|
134555
|
-
this.configManager.setDeviceActivation(deviceId, capability, addonId, active);
|
|
134556
|
-
this.logger.info("Device activation set", {
|
|
134557
|
-
tags: {
|
|
134558
|
-
deviceId: Number(deviceId),
|
|
134559
|
-
addonId
|
|
134560
|
-
},
|
|
134561
|
-
meta: {
|
|
134562
|
-
capability,
|
|
134563
|
-
active
|
|
134564
|
-
}
|
|
134565
|
-
});
|
|
134566
|
-
this.emitEvent("capability:device-activation-changed", {
|
|
134567
|
-
deviceId,
|
|
134568
|
-
capability,
|
|
134569
|
-
addonId,
|
|
134570
|
-
active
|
|
134571
|
-
});
|
|
134572
|
-
}
|
|
134573
|
-
/**
|
|
134574
|
-
* Get all addon/capability activations for a device.
|
|
134575
|
-
* Returns every registered provider with its resolved active status.
|
|
134576
|
-
*/
|
|
134577
|
-
getDeviceActivations(deviceId) {
|
|
134578
|
-
const result = [];
|
|
134579
|
-
for (const [capName, state] of this.capabilities) for (const addonId of state.providers.keys()) result.push({
|
|
134580
|
-
capability: capName,
|
|
134581
|
-
addonId,
|
|
134582
|
-
active: this.isActiveForDevice(capName, addonId, deviceId)
|
|
134583
|
-
});
|
|
134584
|
-
return result;
|
|
134585
|
-
}
|
|
134586
134511
|
/**
|
|
134587
134512
|
* Get all addon/capability activations at system level.
|
|
134588
134513
|
* Returns every registered provider with its resolved active status.
|
|
@@ -134641,7 +134566,8 @@ var require_dist3 = __commonJS({
|
|
|
134641
134566
|
}
|
|
134642
134567
|
/**
|
|
134643
134568
|
* Resolve a singleton provider for a specific device.
|
|
134644
|
-
* Checks activation (
|
|
134569
|
+
* Checks activation (the manifest's autoActivate) then the per-device
|
|
134570
|
+
* singleton override — the in-memory provider pin, not a persisted flag.
|
|
134645
134571
|
*/
|
|
134646
134572
|
resolveForDevice(capability, deviceId) {
|
|
134647
134573
|
const state = this.capabilities.get(capability);
|
|
@@ -134650,7 +134576,7 @@ var require_dist3 = __commonJS({
|
|
|
134650
134576
|
if (deviceMap) {
|
|
134651
134577
|
const overrideAddonId = deviceMap.get(capability);
|
|
134652
134578
|
if (overrideAddonId) {
|
|
134653
|
-
if (this.
|
|
134579
|
+
if (this.isActiveForSystem(capability, overrideAddonId)) {
|
|
134654
134580
|
const provider = state.providers.get(overrideAddonId);
|
|
134655
134581
|
if (provider) return asProvider(provider);
|
|
134656
134582
|
}
|
|
@@ -134663,11 +134589,11 @@ var require_dist3 = __commonJS({
|
|
|
134663
134589
|
});
|
|
134664
134590
|
}
|
|
134665
134591
|
}
|
|
134666
|
-
if (state.activeAddonId && this.
|
|
134592
|
+
if (state.activeAddonId && this.isActiveForSystem(capability, state.activeAddonId)) {
|
|
134667
134593
|
const active = state.providers.get(state.activeAddonId);
|
|
134668
134594
|
return active !== void 0 ? asProvider(active) : null;
|
|
134669
134595
|
}
|
|
134670
|
-
for (const [addonId, provider] of state.providers) if (this.
|
|
134596
|
+
for (const [addonId, provider] of state.providers) if (this.isActiveForSystem(capability, addonId)) return asProvider(provider);
|
|
134671
134597
|
return null;
|
|
134672
134598
|
}
|
|
134673
134599
|
/** Set a per-device collection filter. */
|
|
@@ -134703,12 +134629,12 @@ var require_dist3 = __commonJS({
|
|
|
134703
134629
|
}
|
|
134704
134630
|
/**
|
|
134705
134631
|
* Resolve collection providers for a specific device.
|
|
134706
|
-
* Filters by activation (
|
|
134632
|
+
* Filters by activation (the manifest's autoActivate) and optional collection filter.
|
|
134707
134633
|
*/
|
|
134708
134634
|
resolveCollectionForDevice(capability, deviceId) {
|
|
134709
134635
|
const state = this.capabilities.get(capability);
|
|
134710
134636
|
if (!state || state.definition.mode !== "collection") return [];
|
|
134711
|
-
let entries = [...state.providers.entries()].filter(([addonId]) => !state.disabledProviders.has(addonId)).filter(([addonId]) => this.
|
|
134637
|
+
let entries = [...state.providers.entries()].filter(([addonId]) => !state.disabledProviders.has(addonId)).filter(([addonId]) => this.isActiveForSystem(capability, addonId));
|
|
134712
134638
|
const deviceMap = this.deviceCollectionFilters.get(deviceId);
|
|
134713
134639
|
if (deviceMap) {
|
|
134714
134640
|
const filterAddonIds = deviceMap.get(capability);
|
|
@@ -137661,26 +137587,17 @@ var require_dist3 = __commonJS({
|
|
|
137661
137587
|
CAMSTACK_ADMIN_USER: "auth.adminUsername",
|
|
137662
137588
|
CAMSTACK_ADMIN_PASS: "auth.adminPassword"
|
|
137663
137589
|
};
|
|
137664
|
-
var EMPTY_RUNTIME_STATE = {
|
|
137665
|
-
systemActivation: {},
|
|
137666
|
-
deviceActivation: {}
|
|
137667
|
-
};
|
|
137668
137590
|
var ConfigManager = class ConfigManager2 {
|
|
137669
137591
|
configPath;
|
|
137670
137592
|
bootstrapConfig;
|
|
137671
137593
|
settingsStore = null;
|
|
137672
137594
|
settingsDoor = null;
|
|
137673
|
-
runtimeState;
|
|
137674
|
-
runtimeStatePath;
|
|
137675
137595
|
constructor(configPath) {
|
|
137676
137596
|
this.configPath = configPath;
|
|
137677
137597
|
const rawYaml = this.loadYaml();
|
|
137678
137598
|
const merged = this.applyEnvOverrides((0, _camstack_types_addon.asJsonObject)(rawYaml) ?? {});
|
|
137679
137599
|
this.bootstrapConfig = bootstrapSchema.parse(merged);
|
|
137680
137600
|
this.warnDefaultCredentials();
|
|
137681
|
-
const dataPath = this.bootstrapConfig.server.dataPath ?? "camstack-data";
|
|
137682
|
-
this.runtimeStatePath = node_path.resolve(dataPath, "runtime-state.json");
|
|
137683
|
-
this.runtimeState = this.loadRuntimeState();
|
|
137684
137601
|
}
|
|
137685
137602
|
/**
|
|
137686
137603
|
* Wire the settings-store backend. Called once, after the `settings-store`
|
|
@@ -137965,72 +137882,6 @@ var require_dist3 = __commonJS({
|
|
|
137965
137882
|
}
|
|
137966
137883
|
};
|
|
137967
137884
|
}
|
|
137968
|
-
/** Get all system-wide activation overrides. */
|
|
137969
|
-
getSystemActivation() {
|
|
137970
|
-
return this.runtimeState.systemActivation;
|
|
137971
|
-
}
|
|
137972
|
-
/** Set system-wide activation for a capability/addon pair. */
|
|
137973
|
-
setSystemActivation(capability, addonId, active) {
|
|
137974
|
-
const key = `${capability}/${addonId}`;
|
|
137975
|
-
this.runtimeState = {
|
|
137976
|
-
...this.runtimeState,
|
|
137977
|
-
systemActivation: {
|
|
137978
|
-
...this.runtimeState.systemActivation,
|
|
137979
|
-
[key]: active
|
|
137980
|
-
}
|
|
137981
|
-
};
|
|
137982
|
-
this.saveRuntimeState();
|
|
137983
|
-
}
|
|
137984
|
-
/**
|
|
137985
|
-
* Get activation overrides for a device.
|
|
137986
|
-
* Returns a map of `{capability}/{addonId}` → active boolean.
|
|
137987
|
-
* Missing entries mean "use system activation or autoActivate default".
|
|
137988
|
-
*/
|
|
137989
|
-
getDeviceActivation(deviceId) {
|
|
137990
|
-
return this.runtimeState.deviceActivation[deviceId] ?? {};
|
|
137991
|
-
}
|
|
137992
|
-
/**
|
|
137993
|
-
* Get all device activation overrides.
|
|
137994
|
-
* Returns deviceId → (`{capability}/{addonId}` → active).
|
|
137995
|
-
*/
|
|
137996
|
-
getAllDeviceActivation() {
|
|
137997
|
-
return this.runtimeState.deviceActivation;
|
|
137998
|
-
}
|
|
137999
|
-
/**
|
|
138000
|
-
* Set activation for a specific capability/addon on a device.
|
|
138001
|
-
* Persists immediately to runtime-state.json.
|
|
138002
|
-
*
|
|
138003
|
-
* @param deviceId - The device to configure
|
|
138004
|
-
* @param capability - Capability name (e.g., 'motion-detection')
|
|
138005
|
-
* @param addonId - Addon providing the capability (e.g., 'wasm-motion')
|
|
138006
|
-
* @param active - Whether the capability is active on this device
|
|
138007
|
-
*/
|
|
138008
|
-
setDeviceActivation(deviceId, capability, addonId, active) {
|
|
138009
|
-
const key = `${capability}/${addonId}`;
|
|
138010
|
-
const updated = {
|
|
138011
|
-
...this.runtimeState.deviceActivation[deviceId] ?? {},
|
|
138012
|
-
[key]: active
|
|
138013
|
-
};
|
|
138014
|
-
this.runtimeState = {
|
|
138015
|
-
...this.runtimeState,
|
|
138016
|
-
deviceActivation: {
|
|
138017
|
-
...this.runtimeState.deviceActivation,
|
|
138018
|
-
[deviceId]: updated
|
|
138019
|
-
}
|
|
138020
|
-
};
|
|
138021
|
-
this.saveRuntimeState();
|
|
138022
|
-
}
|
|
138023
|
-
/**
|
|
138024
|
-
* Clear all activation overrides for a device (resets to autoActivate defaults).
|
|
138025
|
-
*/
|
|
138026
|
-
clearDeviceActivation(deviceId) {
|
|
138027
|
-
const { [deviceId]: _removed, ...rest } = this.runtimeState.deviceActivation;
|
|
138028
|
-
this.runtimeState = {
|
|
138029
|
-
...this.runtimeState,
|
|
138030
|
-
deviceActivation: rest
|
|
138031
|
-
};
|
|
138032
|
-
this.saveRuntimeState();
|
|
138033
|
-
}
|
|
138034
137885
|
getBootstrap(configPath) {
|
|
138035
137886
|
return this.getFromBootstrap(configPath);
|
|
138036
137887
|
}
|
|
@@ -138202,39 +138053,6 @@ var require_dist3 = __commonJS({
|
|
|
138202
138053
|
}
|
|
138203
138054
|
return found ? result : null;
|
|
138204
138055
|
}
|
|
138205
|
-
loadRuntimeState() {
|
|
138206
|
-
if (!node_fs.existsSync(this.runtimeStatePath)) return EMPTY_RUNTIME_STATE;
|
|
138207
|
-
try {
|
|
138208
|
-
const parsed = (0, _camstack_types_addon.asJsonObject)((0, _camstack_types_addon.parseJsonUnknown)(node_fs.readFileSync(this.runtimeStatePath, "utf-8")));
|
|
138209
|
-
if (parsed === null) return EMPTY_RUNTIME_STATE;
|
|
138210
|
-
const systemActivation = (0, _camstack_types_addon.asJsonObject)(parsed.systemActivation) ?? {};
|
|
138211
|
-
const deviceActivationRaw = (0, _camstack_types_addon.asJsonObject)(parsed.deviceActivation) ?? {};
|
|
138212
|
-
const deviceActivation = {};
|
|
138213
|
-
for (const [deviceId, entry] of Object.entries(deviceActivationRaw)) {
|
|
138214
|
-
const nested = (0, _camstack_types_addon.asJsonObject)(entry);
|
|
138215
|
-
if (nested === null) continue;
|
|
138216
|
-
const bools = {};
|
|
138217
|
-
for (const [k2, v2] of Object.entries(nested)) if (typeof v2 === "boolean") bools[k2] = v2;
|
|
138218
|
-
deviceActivation[deviceId] = bools;
|
|
138219
|
-
}
|
|
138220
|
-
const systemBools = {};
|
|
138221
|
-
for (const [k2, v2] of Object.entries(systemActivation)) if (typeof v2 === "boolean") systemBools[k2] = v2;
|
|
138222
|
-
return {
|
|
138223
|
-
systemActivation: systemBools,
|
|
138224
|
-
deviceActivation
|
|
138225
|
-
};
|
|
138226
|
-
} catch {
|
|
138227
|
-
console.warn(`[ConfigManager] Failed to parse runtime state at ${this.runtimeStatePath}, using defaults`);
|
|
138228
|
-
return EMPTY_RUNTIME_STATE;
|
|
138229
|
-
}
|
|
138230
|
-
}
|
|
138231
|
-
saveRuntimeState() {
|
|
138232
|
-
const dir = node_path.dirname(this.runtimeStatePath);
|
|
138233
|
-
if (!node_fs.existsSync(dir)) node_fs.mkdirSync(dir, { recursive: true });
|
|
138234
|
-
const tmpPath = `${this.runtimeStatePath}.tmp`;
|
|
138235
|
-
node_fs.writeFileSync(tmpPath, JSON.stringify(this.runtimeState, null, 2), "utf-8");
|
|
138236
|
-
node_fs.renameSync(tmpPath, this.runtimeStatePath);
|
|
138237
|
-
}
|
|
138238
138056
|
};
|
|
138239
138057
|
var require_constants$7 = /* @__PURE__ */ require_chunk.__commonJSMin(((exports2, module2) => {
|
|
138240
138058
|
module2.exports = {
|
|
@@ -426374,7 +426192,6 @@ var require_main4 = __commonJS({
|
|
|
426374
426192
|
addonRegistry.setAddonRouteRegistry(addonRouteRegistry);
|
|
426375
426193
|
addonRegistry.setDataPlaneRegistry(dataPlaneRegistry);
|
|
426376
426194
|
const capabilityRegistry = addonRegistry.getCapabilityRegistry();
|
|
426377
|
-
capabilityRegistry.setConfigManager(config);
|
|
426378
426195
|
for (const capDef of system_1.ALL_CAPABILITY_DEFINITIONS) {
|
|
426379
426196
|
capabilityRegistry.declareCapability(capDef);
|
|
426380
426197
|
}
|