@camstack/system 1.0.6 → 1.0.7
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/addon-runner.js +38 -21
- package/dist/addon-runner.mjs +18 -2
- package/dist/addon-utils.d.ts +20 -0
- package/dist/addon-utils.js +11 -0
- package/dist/addon-utils.mjs +3 -0
- package/dist/builtins/native-metrics/native-metrics.addon.d.ts +8 -0
- package/dist/builtins/native-metrics/native-metrics.addon.js +50 -3
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +50 -3
- package/dist/custom-action-registry-BEXwC-oo.mjs +38 -0
- package/dist/custom-action-registry-vLYEFTtv.js +43 -0
- package/dist/index.js +48 -706
- package/dist/index.mjs +18 -676
- package/dist/kernel/moleculer/device-cap-proxy.d.ts +2 -1
- package/dist/kernel/moleculer/readiness-context.d.ts +2 -1
- package/dist/{manifest-python-deps-CXbKrOdk.mjs → manifest-python-deps-CoJXeb9u.mjs} +2 -39
- package/dist/{manifest-python-deps-B4BmMoGT.js → manifest-python-deps-eBDj5HEY.js} +29 -72
- package/dist/model-download-service-C7AjBsX9.mjs +668 -0
- package/dist/model-download-service-JtVQtbb6.js +752 -0
- package/dist/process/resource-monitor.d.ts +9 -0
- package/dist/{resource-monitor-ClDGFyf6.mjs → resource-monitor-BkP504Vq.mjs} +20 -1
- package/dist/{resource-monitor-IIEanuJt.js → resource-monitor-DNNomR-i.js} +21 -1
- package/package.json +6 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { deviceOpsCapability
|
|
1
|
+
import { deviceOpsCapability } from '@camstack/types/addon';
|
|
2
|
+
import { AddonApi, CapabilityDefinition, DeviceManagerApi, IDevice, IEventBus, IKernelStreamProbe, IScopedLogger, InferProvider } from '@camstack/types';
|
|
2
3
|
import { ServiceBroker } from 'moleculer';
|
|
3
4
|
import { DeviceRegistry } from '../device-registry.js';
|
|
4
5
|
import { CapabilityRegistry } from '../capability-registry.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ServiceBroker } from 'moleculer';
|
|
2
|
-
import { IEventBus, IScopedLogger
|
|
2
|
+
import { IEventBus, IScopedLogger } from '@camstack/types';
|
|
3
|
+
import { ReadinessRegistry } from '@camstack/types/addon';
|
|
3
4
|
/**
|
|
4
5
|
* Minimal interface for the `LocalChildClient` surface used in UDS-mode
|
|
5
6
|
* readiness hydration. Declared here (rather than importing the concrete
|
|
@@ -4,7 +4,6 @@ import { createServer } from "node:http";
|
|
|
4
4
|
import * as fs from "node:fs";
|
|
5
5
|
import * as path$1 from "node:path";
|
|
6
6
|
import { isAbsolute, join } from "node:path";
|
|
7
|
-
import { DATAPLANE_SECRET_HEADER, DeviceType, DisposerChain, EventCategory, ReadinessRegistry, asJsonObject, asString, createDeviceProxy, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, scopeKey, sleep } from "@camstack/types";
|
|
8
7
|
import * as crypto$1 from "node:crypto";
|
|
9
8
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
10
9
|
import { execFile } from "node:child_process";
|
|
@@ -12,6 +11,7 @@ import { promisify } from "node:util";
|
|
|
12
11
|
import * as os from "node:os";
|
|
13
12
|
import { tmpdir } from "node:os";
|
|
14
13
|
import { unlink } from "node:fs/promises";
|
|
14
|
+
import { DATAPLANE_SECRET_HEADER, DeviceType, DisposerChain, EventCategory, ReadinessRegistry, asJsonObject, asString, createDeviceProxy, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, scopeKey, sleep } from "@camstack/types/addon";
|
|
15
15
|
import { TRPCClientError, createTRPCClient } from "@trpc/client";
|
|
16
16
|
import { connect, createServer as createServer$1 } from "node:net";
|
|
17
17
|
//#region src/kernel/addon-class-resolver.ts
|
|
@@ -381,43 +381,6 @@ var CapabilityHandle = class {
|
|
|
381
381
|
}
|
|
382
382
|
};
|
|
383
383
|
//#endregion
|
|
384
|
-
//#region src/kernel/custom-action-registry.ts
|
|
385
|
-
/**
|
|
386
|
-
* CustomActionRegistry — per-process registry of addon custom actions.
|
|
387
|
-
*
|
|
388
|
-
* Populated at boot from each addon's `AddonInitResult.customActions` +
|
|
389
|
-
* `handleCustomAction` handler. Rejects actions declared with scope other
|
|
390
|
-
* than 'system' (today only 'system' is runtime-supported; the descriptor
|
|
391
|
-
* allows future scopes for forward compat).
|
|
392
|
-
*/
|
|
393
|
-
var CustomActionRegistry = class {
|
|
394
|
-
byAddon = /* @__PURE__ */ new Map();
|
|
395
|
-
registerAddon(addonId, catalog, handler) {
|
|
396
|
-
const actions = /* @__PURE__ */ new Map();
|
|
397
|
-
for (const [name, spec] of Object.entries(catalog)) {
|
|
398
|
-
const scope = spec.scope ?? { kind: "system" };
|
|
399
|
-
if (scope.kind !== "system") throw new Error(`custom action '${addonId}.${name}' declared scope '${scope.kind}' — not yet implemented`);
|
|
400
|
-
actions.set(name, {
|
|
401
|
-
spec,
|
|
402
|
-
handler: (input) => handler(name, input)
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
this.byAddon.set(addonId, actions);
|
|
406
|
-
}
|
|
407
|
-
unregisterAddon(addonId) {
|
|
408
|
-
this.byAddon.delete(addonId);
|
|
409
|
-
}
|
|
410
|
-
resolve(addonId, action) {
|
|
411
|
-
return this.byAddon.get(addonId)?.get(action) ?? null;
|
|
412
|
-
}
|
|
413
|
-
listActions(addonId) {
|
|
414
|
-
return [...this.byAddon.get(addonId)?.keys() ?? []];
|
|
415
|
-
}
|
|
416
|
-
listAddons() {
|
|
417
|
-
return [...this.byAddon.keys()];
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
//#endregion
|
|
421
384
|
//#region src/kernel/device-registry.ts
|
|
422
385
|
var DeviceRegistry = class {
|
|
423
386
|
/** Primary map: every registered device keyed by its progressive
|
|
@@ -6566,4 +6529,4 @@ async function installManifestPythonDeps(declaration, addonDir, deps, logger) {
|
|
|
6566
6529
|
await deps.installPythonRequirements(reqAbs);
|
|
6567
6530
|
}
|
|
6568
6531
|
//#endregion
|
|
6569
|
-
export { setWorkerNativeCapsChangeListener as $, createUdsLoggerWithControl as A, createLocalTransport as B, ipcParentLink as C, createUdsEventBus as D, createUdsEventBridge as E, CapRouteError as F, FrameDecoder as G, UdsLocalTransportServer as H, classifyCapRoute as I, buildUdsNativeCapProxy as J, encodeFrame as K, LocalChildClient as L, AGENT_CAP_FWD_SERVICE as M, CapRouteResolver as N, udsChildLogToWorkerEntry as O, callWithServiceDiscovery as P, mountNativeCapService as Q, LocalChildRegistry as R, ipcChildLink as S, createParentUnownedCallHandler as T, SocketChannel as U, UdsLocalTransportClient as V, localEndpointPath as W, getWorkerNativeCapProvider as X, createBrokerDeviceManagerApi as Y, getWorkerNativeCapSnapshot as Z, __resetCapUsageRegistryForTests as _, getWorkerDeviceRegistry as a, capBareAction as at, brokerTransportLink as b, setHubConnected as c, deserializeTypedArrays as ct, registerEventBusService as d,
|
|
6532
|
+
export { setWorkerNativeCapsChangeListener as $, createUdsLoggerWithControl as A, createLocalTransport as B, ipcParentLink as C, createUdsEventBus as D, createUdsEventBridge as E, CapRouteError as F, FrameDecoder as G, UdsLocalTransportServer as H, classifyCapRoute as I, buildUdsNativeCapProxy as J, encodeFrame as K, LocalChildClient as L, AGENT_CAP_FWD_SERVICE as M, CapRouteResolver as N, udsChildLogToWorkerEntry as O, callWithServiceDiscovery as P, mountNativeCapService as Q, LocalChildRegistry as R, ipcChildLink as S, createParentUnownedCallHandler as T, SocketChannel as U, UdsLocalTransportClient as V, localEndpointPath as W, getWorkerNativeCapProvider as X, createBrokerDeviceManagerApi as Y, getWorkerNativeCapSnapshot as Z, __resetCapUsageRegistryForTests as _, getWorkerDeviceRegistry as a, capBareAction as at, brokerTransportLink as b, setHubConnected as c, deserializeTypedArrays as ct, registerEventBusService as d, CapabilityHandle as dt, createAddonService as et, AddonDepsManager as f, CapabilityUnavailableError as ft, CapUsageRegistry as g, createHwAccelService as h, createUdsAddonContext as i, capActionSuffix as it, AGENT_CAP_FWD_ACTION as j, createUdsLogger as k, EVENT_TOPIC_PREFIX as l, serializeTypedArrays as lt, resolveHwAccel as m, resolveAddonClass as mt, adaptBrokerToCluster as n, NATIVE_PROVIDER_SERVICE_INFIX as nt, getOrInitReadinessRegistry as o, capServiceName as ot, createKernelHwAccel as p, installManifestNativeDeps as pt, buildNativeCapProxy as q, createAddonContext as r, capActionName as rt, getOrInitReadinessRegistryForClient as s, parseCapAction as st, installManifestPythonDeps as t, validateProviderRegistrations as tt, getBrokerEventBus as u, DeviceRegistry as ut, getCapUsageRegistry as v, localProviderLink as w, buildLinkChain as x, brokerCallForCap as y, UDS_NO_ROUTE_PREFIX as z };
|
|
@@ -5,7 +5,6 @@ let node_fs = require("node:fs");
|
|
|
5
5
|
node_fs = require_chunk.__toESM(node_fs);
|
|
6
6
|
let node_path = require("node:path");
|
|
7
7
|
node_path = require_chunk.__toESM(node_path);
|
|
8
|
-
let _camstack_types = require("@camstack/types");
|
|
9
8
|
let node_crypto = require("node:crypto");
|
|
10
9
|
node_crypto = require_chunk.__toESM(node_crypto);
|
|
11
10
|
let node_child_process = require("node:child_process");
|
|
@@ -13,6 +12,7 @@ let node_util = require("node:util");
|
|
|
13
12
|
let node_os = require("node:os");
|
|
14
13
|
node_os = require_chunk.__toESM(node_os);
|
|
15
14
|
let node_fs_promises = require("node:fs/promises");
|
|
15
|
+
let _camstack_types_addon = require("@camstack/types/addon");
|
|
16
16
|
let _trpc_client = require("@trpc/client");
|
|
17
17
|
let node_net = require("node:net");
|
|
18
18
|
//#region src/kernel/addon-class-resolver.ts
|
|
@@ -103,7 +103,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry) {
|
|
|
103
103
|
} catch (err) {
|
|
104
104
|
logger.warn("Failed to write native deps marker", { meta: {
|
|
105
105
|
markerFile,
|
|
106
|
-
error: (0,
|
|
106
|
+
error: (0, _camstack_types_addon.errMsg)(err)
|
|
107
107
|
} });
|
|
108
108
|
}
|
|
109
109
|
return;
|
|
@@ -130,7 +130,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry) {
|
|
|
130
130
|
timeout: 3e5
|
|
131
131
|
});
|
|
132
132
|
} catch (err) {
|
|
133
|
-
throw new Error(`npm install of native deps failed for ${addonDir}: ${(0,
|
|
133
|
+
throw new Error(`npm install of native deps failed for ${addonDir}: ${(0, _camstack_types_addon.errMsg)(err)}`, { cause: err });
|
|
134
134
|
}
|
|
135
135
|
await rebuildNativeDeps(addonDir, pending.map(([name]) => name), logger);
|
|
136
136
|
try {
|
|
@@ -138,7 +138,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry) {
|
|
|
138
138
|
} catch (err) {
|
|
139
139
|
logger.warn("Failed to write native deps marker", { meta: {
|
|
140
140
|
markerFile,
|
|
141
|
-
error: (0,
|
|
141
|
+
error: (0, _camstack_types_addon.errMsg)(err)
|
|
142
142
|
} });
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -175,7 +175,7 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
|
|
|
175
175
|
logger.warn("Prebuilt native dep copy failed — will try npm install", { meta: {
|
|
176
176
|
name,
|
|
177
177
|
source,
|
|
178
|
-
error: (0,
|
|
178
|
+
error: (0, _camstack_types_addon.errMsg)(err)
|
|
179
179
|
} });
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -208,13 +208,13 @@ function candidateHoistedDirs(name, addonDir) {
|
|
|
208
208
|
}
|
|
209
209
|
/** Read & validate `camstack.nativeDependencies`. Returns null when absent. */
|
|
210
210
|
function readNativeDeps(pkgRaw) {
|
|
211
|
-
const camstack = (0,
|
|
211
|
+
const camstack = (0, _camstack_types_addon.asJsonObject)(pkgRaw["camstack"]);
|
|
212
212
|
if (!camstack) return null;
|
|
213
|
-
const native = (0,
|
|
213
|
+
const native = (0, _camstack_types_addon.asJsonObject)(camstack["nativeDependencies"]);
|
|
214
214
|
if (!native) return null;
|
|
215
215
|
const out = {};
|
|
216
216
|
for (const [k, v] of Object.entries(native)) {
|
|
217
|
-
const range = (0,
|
|
217
|
+
const range = (0, _camstack_types_addon.asString)(v);
|
|
218
218
|
if (range) out[k] = range;
|
|
219
219
|
}
|
|
220
220
|
return Object.keys(out).length > 0 ? out : null;
|
|
@@ -281,7 +281,7 @@ async function rebuildNativeDeps(addonDir, packageNames, logger) {
|
|
|
281
281
|
} catch (err) {
|
|
282
282
|
logger.warn("Electron rebuild failed (continuing — prebuilt binary may be present)", { meta: {
|
|
283
283
|
addonDir,
|
|
284
|
-
error: (0,
|
|
284
|
+
error: (0, _camstack_types_addon.errMsg)(err)
|
|
285
285
|
} });
|
|
286
286
|
}
|
|
287
287
|
return;
|
|
@@ -299,7 +299,7 @@ async function rebuildNativeDeps(addonDir, packageNames, logger) {
|
|
|
299
299
|
} catch (err) {
|
|
300
300
|
logger.warn("npm rebuild failed (continuing — prebuilt binary may be present)", { meta: {
|
|
301
301
|
addonDir,
|
|
302
|
-
error: (0,
|
|
302
|
+
error: (0, _camstack_types_addon.errMsg)(err)
|
|
303
303
|
} });
|
|
304
304
|
}
|
|
305
305
|
}
|
|
@@ -382,43 +382,6 @@ var CapabilityHandle = class {
|
|
|
382
382
|
}
|
|
383
383
|
};
|
|
384
384
|
//#endregion
|
|
385
|
-
//#region src/kernel/custom-action-registry.ts
|
|
386
|
-
/**
|
|
387
|
-
* CustomActionRegistry — per-process registry of addon custom actions.
|
|
388
|
-
*
|
|
389
|
-
* Populated at boot from each addon's `AddonInitResult.customActions` +
|
|
390
|
-
* `handleCustomAction` handler. Rejects actions declared with scope other
|
|
391
|
-
* than 'system' (today only 'system' is runtime-supported; the descriptor
|
|
392
|
-
* allows future scopes for forward compat).
|
|
393
|
-
*/
|
|
394
|
-
var CustomActionRegistry = class {
|
|
395
|
-
byAddon = /* @__PURE__ */ new Map();
|
|
396
|
-
registerAddon(addonId, catalog, handler) {
|
|
397
|
-
const actions = /* @__PURE__ */ new Map();
|
|
398
|
-
for (const [name, spec] of Object.entries(catalog)) {
|
|
399
|
-
const scope = spec.scope ?? { kind: "system" };
|
|
400
|
-
if (scope.kind !== "system") throw new Error(`custom action '${addonId}.${name}' declared scope '${scope.kind}' — not yet implemented`);
|
|
401
|
-
actions.set(name, {
|
|
402
|
-
spec,
|
|
403
|
-
handler: (input) => handler(name, input)
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
this.byAddon.set(addonId, actions);
|
|
407
|
-
}
|
|
408
|
-
unregisterAddon(addonId) {
|
|
409
|
-
this.byAddon.delete(addonId);
|
|
410
|
-
}
|
|
411
|
-
resolve(addonId, action) {
|
|
412
|
-
return this.byAddon.get(addonId)?.get(action) ?? null;
|
|
413
|
-
}
|
|
414
|
-
listActions(addonId) {
|
|
415
|
-
return [...this.byAddon.get(addonId)?.keys() ?? []];
|
|
416
|
-
}
|
|
417
|
-
listAddons() {
|
|
418
|
-
return [...this.byAddon.keys()];
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
//#endregion
|
|
422
385
|
//#region src/kernel/device-registry.ts
|
|
423
386
|
var DeviceRegistry = class {
|
|
424
387
|
/** Primary map: every registered device keyed by its progressive
|
|
@@ -963,7 +926,7 @@ var nativeCapReadinessGeneration = typeof crypto !== "undefined" && crypto.rando
|
|
|
963
926
|
function mountNativeCapService(broker, addonId, cap) {
|
|
964
927
|
const serviceName = capServiceName(addonId, cap.name, true);
|
|
965
928
|
if (mountedNativeCapServices.has(serviceName)) return;
|
|
966
|
-
const expandedMethods = (0,
|
|
929
|
+
const expandedMethods = (0, _camstack_types_addon.expandCapMethods)(cap);
|
|
967
930
|
if (expandedMethods === void 0 || Object.keys(expandedMethods).length === 0 || typeof broker.createService !== "function") {
|
|
968
931
|
mountedNativeCapServices.add(serviceName);
|
|
969
932
|
return;
|
|
@@ -1069,7 +1032,7 @@ async function callWithServiceDiscoveryRetry(broker, actionName, input) {
|
|
|
1069
1032
|
if (!(err instanceof Error ? err.message : String(err)).includes("is not found")) throw err;
|
|
1070
1033
|
attempt++;
|
|
1071
1034
|
if (attempt === 1) broker.logger.warn(`native-cap-bridge: service not found for "${actionName}", retrying with exponential backoff…`);
|
|
1072
|
-
await (0,
|
|
1035
|
+
await (0, _camstack_types_addon.sleep)(delay);
|
|
1073
1036
|
delay = Math.min(delay * 2, BACKOFF_MAX_MS);
|
|
1074
1037
|
}
|
|
1075
1038
|
}
|
|
@@ -1174,7 +1137,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
1174
1137
|
parentDeviceId,
|
|
1175
1138
|
logger: (() => {
|
|
1176
1139
|
const base = opts.logger.child(stableId);
|
|
1177
|
-
const containerDeviceId = parentDeviceId ?? (deviceMeta?.type ===
|
|
1140
|
+
const containerDeviceId = parentDeviceId ?? (deviceMeta?.type === _camstack_types_addon.DeviceType.Container ? id : null);
|
|
1178
1141
|
return base.withTags(containerDeviceId !== null ? {
|
|
1179
1142
|
deviceId: id,
|
|
1180
1143
|
containerDeviceId
|
|
@@ -1200,7 +1163,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
1200
1163
|
id,
|
|
1201
1164
|
stableId,
|
|
1202
1165
|
addonId,
|
|
1203
|
-
type:
|
|
1166
|
+
type: _camstack_types_addon.DeviceType.Camera,
|
|
1204
1167
|
name: stableId,
|
|
1205
1168
|
location: null,
|
|
1206
1169
|
disabled: false,
|
|
@@ -1208,7 +1171,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
1208
1171
|
metadata: null
|
|
1209
1172
|
},
|
|
1210
1173
|
fetchDevice: async (deviceId) => {
|
|
1211
|
-
return (0,
|
|
1174
|
+
return (0, _camstack_types_addon.createDeviceProxy)(api, await api.deviceManager.getBindings.query({ deviceId }));
|
|
1212
1175
|
},
|
|
1213
1176
|
get devices() {
|
|
1214
1177
|
return selfApi;
|
|
@@ -1266,7 +1229,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
1266
1229
|
type: "device",
|
|
1267
1230
|
id
|
|
1268
1231
|
},
|
|
1269
|
-
category:
|
|
1232
|
+
category: _camstack_types_addon.EventCategory.DeviceBindingsChanged,
|
|
1270
1233
|
data: {
|
|
1271
1234
|
deviceId: id,
|
|
1272
1235
|
capName: cap.name,
|
|
@@ -1275,7 +1238,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
1275
1238
|
nodeId
|
|
1276
1239
|
}
|
|
1277
1240
|
});
|
|
1278
|
-
(0,
|
|
1241
|
+
(0, _camstack_types_addon.emitReadiness)(eventBus, {
|
|
1279
1242
|
capName: cap.name,
|
|
1280
1243
|
scope: {
|
|
1281
1244
|
type: "device",
|
|
@@ -1513,7 +1476,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
1513
1476
|
},
|
|
1514
1477
|
register: async (device) => {
|
|
1515
1478
|
registry.register(addonId, device);
|
|
1516
|
-
buildContext(device.stableId, device.id, device.parentDeviceId).registerNativeCap(
|
|
1479
|
+
buildContext(device.stableId, device.id, device.parentDeviceId).registerNativeCap(_camstack_types_addon.deviceOpsCapability, buildDeviceOpsProvider(device));
|
|
1517
1480
|
try {
|
|
1518
1481
|
await callDeviceManager(api, "registerDevice", {
|
|
1519
1482
|
addonId,
|
|
@@ -1650,7 +1613,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
1650
1613
|
type: "device",
|
|
1651
1614
|
id: device.id
|
|
1652
1615
|
},
|
|
1653
|
-
category:
|
|
1616
|
+
category: _camstack_types_addon.EventCategory.DeviceReady,
|
|
1654
1617
|
data: { deviceId: device.id }
|
|
1655
1618
|
});
|
|
1656
1619
|
};
|
|
@@ -1789,7 +1752,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
1789
1752
|
type: "device",
|
|
1790
1753
|
id: deviceId
|
|
1791
1754
|
},
|
|
1792
|
-
category:
|
|
1755
|
+
category: _camstack_types_addon.EventCategory.DeviceBindingsChanged,
|
|
1793
1756
|
data: {
|
|
1794
1757
|
deviceId,
|
|
1795
1758
|
capName,
|
|
@@ -1798,7 +1761,7 @@ function createBrokerDeviceManagerApi(opts) {
|
|
|
1798
1761
|
nodeId
|
|
1799
1762
|
}
|
|
1800
1763
|
});
|
|
1801
|
-
(0,
|
|
1764
|
+
(0, _camstack_types_addon.emitReadiness)(eventBus, {
|
|
1802
1765
|
capName,
|
|
1803
1766
|
scope: {
|
|
1804
1767
|
type: "device",
|
|
@@ -5357,7 +5320,7 @@ function createAddonDataPlaneFacility(args) {
|
|
|
5357
5320
|
let server = null;
|
|
5358
5321
|
let baseUrl = "";
|
|
5359
5322
|
const route = (req, res) => {
|
|
5360
|
-
if (req.headers[
|
|
5323
|
+
if (req.headers[_camstack_types_addon.DATAPLANE_SECRET_HEADER] !== secret) {
|
|
5361
5324
|
res.writeHead(403).end();
|
|
5362
5325
|
return;
|
|
5363
5326
|
}
|
|
@@ -5902,7 +5865,7 @@ function getOrInitReadinessRegistry(broker, eventBus, logger) {
|
|
|
5902
5865
|
const bkr = broker;
|
|
5903
5866
|
const existing = brokerReadinessRegistries.get(broker);
|
|
5904
5867
|
if (existing) return existing;
|
|
5905
|
-
const registry = new
|
|
5868
|
+
const registry = new _camstack_types_addon.ReadinessRegistry({
|
|
5906
5869
|
eventBus,
|
|
5907
5870
|
sourceNodeId: bkr.nodeID,
|
|
5908
5871
|
logger
|
|
@@ -5969,7 +5932,7 @@ function getOrInitReadinessRegistry(broker, eventBus, logger) {
|
|
|
5969
5932
|
function getOrInitReadinessRegistryForClient(client, eventBus, logger, nodeId) {
|
|
5970
5933
|
const existing = clientReadinessRegistries.get(nodeId);
|
|
5971
5934
|
if (existing) return existing;
|
|
5972
|
-
const registry = new
|
|
5935
|
+
const registry = new _camstack_types_addon.ReadinessRegistry({
|
|
5973
5936
|
eventBus,
|
|
5974
5937
|
sourceNodeId: nodeId,
|
|
5975
5938
|
logger
|
|
@@ -6282,12 +6245,12 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
6282
6245
|
const api = (0, _trpc_client.createTRPCClient)({ links });
|
|
6283
6246
|
const scopedLogger = options?.createLogger?.(addonId) ?? (runtime.mode === "broker" ? createRemoteLogger(runtime.broker, addonId) : createUdsLogger(runtime.client, addonId, nodeId));
|
|
6284
6247
|
const scopedEventBus = runtime.mode === "broker" ? createBrokerEventBus(runtime.broker, addonId) : createUdsEventBus(runtime.client, addonId);
|
|
6285
|
-
const workerDisposerChain = new
|
|
6248
|
+
const workerDisposerChain = new _camstack_types_addon.DisposerChain({ onError: (err, index) => {
|
|
6286
6249
|
scopedLogger.error(`Disposer #${index} threw during teardown`, { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
6287
6250
|
} });
|
|
6288
6251
|
registerWorkerDisposerChain(nodeId, addonId, workerDisposerChain);
|
|
6289
6252
|
const bindingCache = /* @__PURE__ */ new Map();
|
|
6290
|
-
scopedEventBus.subscribe({ category:
|
|
6253
|
+
scopedEventBus.subscribe({ category: _camstack_types_addon.EventCategory.DeviceBindingsChanged }, (e) => {
|
|
6291
6254
|
const data = e.data ?? {};
|
|
6292
6255
|
if (typeof data.deviceId === "number") {
|
|
6293
6256
|
bindingCache.delete(data.deviceId);
|
|
@@ -6386,7 +6349,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
6386
6349
|
const readinessRegistry = () => runtime.mode === "broker" ? getOrInitReadinessRegistry(runtime.broker, scopedEventBus, scopedLogger) : getOrInitReadinessRegistryForClient(runtime.client, scopedEventBus, scopedLogger, nodeId);
|
|
6387
6350
|
const capHandleCache = /* @__PURE__ */ new Map();
|
|
6388
6351
|
function getOrCreateHandle(capName, scope, timeoutMs) {
|
|
6389
|
-
const key = `${capName}::${(0,
|
|
6352
|
+
const key = `${capName}::${(0, _camstack_types_addon.scopeKey)(scope)}`;
|
|
6390
6353
|
const existing = capHandleCache.get(key);
|
|
6391
6354
|
if (existing) return existing;
|
|
6392
6355
|
const handle = new CapabilityHandle(capName, scope, readinessRegistry(), timeoutMs);
|
|
@@ -6482,10 +6445,10 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
|
|
|
6482
6445
|
},
|
|
6483
6446
|
fetchDevice: async (deviceId) => {
|
|
6484
6447
|
const cached = bindingCache.get(deviceId);
|
|
6485
|
-
if (cached) return (0,
|
|
6448
|
+
if (cached) return (0, _camstack_types_addon.createDeviceProxy)(api, cached);
|
|
6486
6449
|
const binding = await api.deviceManager.getBindings.query({ deviceId });
|
|
6487
6450
|
bindingCache.set(deviceId, binding);
|
|
6488
|
-
return (0,
|
|
6451
|
+
return (0, _camstack_types_addon.createDeviceProxy)(api, binding);
|
|
6489
6452
|
},
|
|
6490
6453
|
useCapability(capName, scope = { type: "global" }) {
|
|
6491
6454
|
return getOrCreateHandle(capName, scope, Number.POSITIVE_INFINITY);
|
|
@@ -6615,12 +6578,6 @@ Object.defineProperty(exports, "CapabilityUnavailableError", {
|
|
|
6615
6578
|
return CapabilityUnavailableError;
|
|
6616
6579
|
}
|
|
6617
6580
|
});
|
|
6618
|
-
Object.defineProperty(exports, "CustomActionRegistry", {
|
|
6619
|
-
enumerable: true,
|
|
6620
|
-
get: function() {
|
|
6621
|
-
return CustomActionRegistry;
|
|
6622
|
-
}
|
|
6623
|
-
});
|
|
6624
6581
|
Object.defineProperty(exports, "DeviceRegistry", {
|
|
6625
6582
|
enumerable: true,
|
|
6626
6583
|
get: function() {
|