@camstack/system 1.1.23 → 1.1.25

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.
@@ -1,5 +1,5 @@
1
1
  import * as fs from "node:fs";
2
- import { BaseAddon, EventCategory, errMsg, platformProbeCapability, scoreRuntimes } from "@camstack/types";
2
+ import { BaseAddon, EventCategory, emitReadiness, errMsg, platformProbeCapability, scoreRuntimes } from "@camstack/types";
3
3
  import { execFile } from "node:child_process";
4
4
  import { promisify } from "node:util";
5
5
  import * as os from "node:os";
@@ -587,15 +587,86 @@ var HardwareDecodeAccelProber = class {
587
587
  };
588
588
  //#endregion
589
589
  //#region src/builtins/platform-probe/index.ts
590
+ /**
591
+ * The decode-hwaccel backends `ctx.kernel.hwaccel.resolve` accepts. The cap
592
+ * input enum is WIDER (it also carries EP-only names — coreml/openvino/… —
593
+ * shared with other probe surfaces), so the provider param must stay
594
+ * `string`-typed to satisfy the `InferProvider` contract. We narrow it here
595
+ * with a type guard instead of a cast: any value that is not a known decode
596
+ * backend (or the `'none'` sentinel) resolves to `null` → auto-probe.
597
+ */
598
+ var HWACCEL_DECODE_BACKENDS = [
599
+ "videotoolbox",
600
+ "cuda",
601
+ "nvdec",
602
+ "vaapi",
603
+ "qsv",
604
+ "d3d11va",
605
+ "dxva2",
606
+ "amf",
607
+ "vdpau",
608
+ "drm"
609
+ ];
610
+ function isHwAccelBackend(value) {
611
+ return HWACCEL_DECODE_BACKENDS.includes(value);
612
+ }
613
+ function narrowHwAccelPrefer(value) {
614
+ if (value === "none") return "none";
615
+ if (typeof value === "string" && isHwAccelBackend(value)) return value;
616
+ return null;
617
+ }
590
618
  var PlatformProbeNativeAddon = class extends BaseAddon {
591
619
  scorer = null;
592
620
  encoderProber = null;
593
621
  decodeAccelProber = null;
594
622
  cachedCaps = null;
623
+ /**
624
+ * Per-boot generation stamp for the manual readiness emissions below.
625
+ * Constant for the lifetime of this addon instance (== one process boot);
626
+ * consumer-side registries derive a monotonic epoch from generation
627
+ * transitions. Mirrors `BaseAddon._readinessGeneration` (private there).
628
+ */
629
+ readinessGeneration = typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).slice(2, 14);
595
630
  constructor() {
596
631
  super({});
597
632
  }
598
633
  /**
634
+ * Manual readiness protocol. The provider registers synchronously from
635
+ * `onInitialize`, but the REAL hardware + EP scoring is the async
636
+ * `probePromise` (embedded-Python install included). The BaseAddon
637
+ * auto-emit would flip `ready` at registration time — BEFORE any
638
+ * accelerator is visible — so probe-gated consumers (detection-pipeline
639
+ * engine auto-pick) would read accelerator-blind results and stick on
640
+ * onnx-CPU. Instead: `starting` at init, the single authoritative
641
+ * `ready` once the probe resolves, `down` on shutdown.
642
+ */
643
+ get autoEmitReadiness() {
644
+ return false;
645
+ }
646
+ /** Bare cluster node id — readiness is scoped `{type:'node', nodeId}`. */
647
+ bareLocalNodeId() {
648
+ const raw = this.ctx.kernel?.localNodeId ?? "hub";
649
+ return raw.includes("/") ? raw.split("/")[0] : raw;
650
+ }
651
+ /** Emit a `system.ready-state` transition for the platform-probe cap. */
652
+ emitProbeReadiness(state) {
653
+ const ctx = this.ctxIfReady;
654
+ if (!ctx) return;
655
+ const nodeId = this.bareLocalNodeId();
656
+ try {
657
+ emitReadiness(ctx.eventBus, {
658
+ capName: platformProbeCapability.name,
659
+ scope: {
660
+ type: "node",
661
+ nodeId
662
+ },
663
+ state,
664
+ generation: this.readinessGeneration,
665
+ sourceNodeId: nodeId
666
+ });
667
+ } catch {}
668
+ }
669
+ /**
599
670
  * Resolve the ffmpeg binary the encoder probe should test, from the cluster
600
671
  * `ffmpeg` config section (`binaryPath`). The probe MUST exercise the same
601
672
  * binary the broker/recorder spawn, or it may report encoders for a different
@@ -610,6 +681,7 @@ var PlatformProbeNativeAddon = class extends BaseAddon {
610
681
  }
611
682
  }
612
683
  async onInitialize() {
684
+ this.emitProbeReadiness("starting");
613
685
  const embeddedPython = await this.ctx.deps.ensurePython().catch((err) => {
614
686
  this.ctx.logger.debug("ensurePython unavailable for platform probe", { meta: { error: errMsg(err) } });
615
687
  return null;
@@ -644,6 +716,7 @@ var PlatformProbeNativeAddon = class extends BaseAddon {
644
716
  bestReason: caps.bestScore.reason,
645
717
  bestScore: caps.bestScore.score
646
718
  } });
719
+ this.emitProbeReadiness("ready");
647
720
  return caps;
648
721
  }).catch((err) => {
649
722
  const msg = errMsg(err);
@@ -669,8 +742,15 @@ var PlatformProbeNativeAddon = class extends BaseAddon {
669
742
  },
670
743
  resolveHwAccel: async (input) => {
671
744
  const hwaccel = this.ctx.kernel.hwaccel;
672
- if (!hwaccel) return { preferred: [] };
673
- return { preferred: (await hwaccel.resolve(input.prefer ?? null)).preferred };
745
+ if (!hwaccel) return {
746
+ preferred: [],
747
+ rationale: "kernel hwaccel unavailable"
748
+ };
749
+ const res = await hwaccel.resolve(narrowHwAccelPrefer(input.prefer));
750
+ return {
751
+ preferred: res.preferred,
752
+ rationale: res.rationale
753
+ };
674
754
  },
675
755
  getHardwareEncoders: async () => {
676
756
  const prober = this.encoderProber;
@@ -700,6 +780,7 @@ var PlatformProbeNativeAddon = class extends BaseAddon {
700
780
  }];
701
781
  }
702
782
  async onShutdown() {
783
+ this.emitProbeReadiness("down");
703
784
  this.scorer = null;
704
785
  this.encoderProber = null;
705
786
  this.decodeAccelProber = null;
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ const require_builtins_local_auth_local_auth_addon = require("./builtins/local-a
20
20
  require("./builtins/local-auth/index.js");
21
21
  const require_builtins_device_manager_device_manager_addon = require("./builtins/device-manager/device-manager.addon.js");
22
22
  require("./builtins/device-manager/index.js");
23
- const require_manifest_python_deps = require("./manifest-python-deps-D7iR07uA.js");
23
+ const require_manifest_python_deps = require("./manifest-python-deps-BqXCckob.js");
24
24
  const require_custom_action_registry = require("./custom-action-registry-vLYEFTtv.js");
25
25
  let _camstack_types_node = require("@camstack/types/node");
26
26
  let node_http = require("node:http");
@@ -93415,7 +93415,6 @@ exports.createCoreCapService = createCoreCapService;
93415
93415
  exports.createFileDataPlaneHandler = require_model_download_service.createFileDataPlaneHandler;
93416
93416
  exports.createHubCapForwardService = require_manifest_python_deps.createHubCapForwardService;
93417
93417
  exports.createHubService = createHubService;
93418
- exports.createHwAccelService = require_manifest_python_deps.createHwAccelService;
93419
93418
  exports.createKernelHwAccel = require_manifest_python_deps.createKernelHwAccel;
93420
93419
  exports.createLocalTransport = require_manifest_python_deps.createLocalTransport;
93421
93420
  exports.createParentUnownedCallHandler = require_manifest_python_deps.createParentUnownedCallHandler;
package/dist/index.mjs CHANGED
@@ -18,7 +18,7 @@ import { LocalAuthAddon, a as require_ms, c as __esmMin, d as __toCommonJS, f as
18
18
  import "./builtins/local-auth/index.mjs";
19
19
  import { DeviceManagerAddon } from "./builtins/device-manager/device-manager.addon.mjs";
20
20
  import "./builtins/device-manager/index.mjs";
21
- import { $ as buildNativeCapProxy, A as createHubCapForwardService, B as AGENT_CAP_FWD_ACTION, C as brokerTransportLink, D as localProviderLink, E as ipcParentLink, F as createUdsLogger, G as callWithServiceDiscovery, H as CapRouteResolver, I as createUdsLoggerWithControl, J as UdsLocalTransportServer, K as createLocalTransport, L as LocalChildClient, M as createUdsEventBridge, N as createUdsEventBus, O as HUB_CAP_FWD_ACTION, P as udsChildLogToWorkerEntry, Q as encodeFrame, R as LocalChildRegistry, S as brokerCallForCap, T as ipcChildLink, U as CapRouteError, V as AGENT_CAP_FWD_SERVICE, W as classifyCapRoute, X as localEndpointPath, Y as SocketChannel, Z as FrameDecoder, _ as resolveHwAccel, _t as CapabilityHandle, a as getWorkerDeviceRegistry, b as __resetCapUsageRegistryForTests, bt as resolveAddonClass, c as setHubConnected, ct as NATIVE_PROVIDER_SERVICE_INFIX, d as getMoleculerEventStats, dt as capBareAction, et as buildUdsNativeCapProxy, f as registerEventBusService, ft as capServiceName, g as createKernelHwAccel, gt as DeviceRegistry, h as AddonDepsManager, ht as serializeTypedArrays, i as createUdsAddonContext, it as mountNativeCapService, j as createParentUnownedCallHandler, k as HUB_CAP_FWD_SERVICE, l as EVENT_TOPIC_PREFIX, lt as capActionName, m as subscribePassthrough, mt as deserializeTypedArrays, n as adaptBrokerToCluster, o as getOrInitReadinessRegistry, ot as createAddonService, p as setNodeEventInterest, pt as parseCapAction, q as UdsLocalTransportClient, r as createAddonContext, s as getOrInitReadinessRegistryForClient, st as validateProviderRegistrations, t as installManifestPythonDeps, tt as createBrokerDeviceManagerApi, u as getBrokerEventBus, ut as capActionSuffix, v as createHwAccelService, vt as CapabilityUnavailableError, w as buildLinkChain, x as getCapUsageRegistry, y as CapUsageRegistry, yt as installManifestNativeDeps, z as UDS_NO_ROUTE_PREFIX } from "./manifest-python-deps-hDWMDe_b.mjs";
21
+ import { $ as buildUdsNativeCapProxy, A as createParentUnownedCallHandler, B as AGENT_CAP_FWD_SERVICE, C as buildLinkChain, D as HUB_CAP_FWD_ACTION, E as localProviderLink, F as createUdsLoggerWithControl, G as createLocalTransport, H as CapRouteError, I as LocalChildClient, J as SocketChannel, K as UdsLocalTransportClient, L as LocalChildRegistry, M as createUdsEventBus, N as udsChildLogToWorkerEntry, O as HUB_CAP_FWD_SERVICE, P as createUdsLogger, Q as buildNativeCapProxy, R as UDS_NO_ROUTE_PREFIX, S as brokerTransportLink, T as ipcParentLink, U as classifyCapRoute, V as CapRouteResolver, W as callWithServiceDiscovery, X as FrameDecoder, Y as localEndpointPath, Z as encodeFrame, _ as resolveHwAccel, _t as CapabilityUnavailableError, a as getWorkerDeviceRegistry, at as createAddonService, b as getCapUsageRegistry, c as setHubConnected, ct as capActionName, d as getMoleculerEventStats, dt as capServiceName, et as createBrokerDeviceManagerApi, f as registerEventBusService, ft as parseCapAction, g as createKernelHwAccel, gt as CapabilityHandle, h as AddonDepsManager, ht as DeviceRegistry, i as createUdsAddonContext, j as createUdsEventBridge, k as createHubCapForwardService, l as EVENT_TOPIC_PREFIX, lt as capActionSuffix, m as subscribePassthrough, mt as serializeTypedArrays, n as adaptBrokerToCluster, o as getOrInitReadinessRegistry, ot as validateProviderRegistrations, p as setNodeEventInterest, pt as deserializeTypedArrays, q as UdsLocalTransportServer, r as createAddonContext, rt as mountNativeCapService, s as getOrInitReadinessRegistryForClient, st as NATIVE_PROVIDER_SERVICE_INFIX, t as installManifestPythonDeps, u as getBrokerEventBus, ut as capBareAction, v as CapUsageRegistry, vt as installManifestNativeDeps, w as ipcChildLink, x as brokerCallForCap, y as __resetCapUsageRegistryForTests, yt as resolveAddonClass, z as AGENT_CAP_FWD_ACTION } from "./manifest-python-deps-Dxl4twM3.mjs";
22
22
  import { t as CustomActionRegistry } from "./custom-action-registry-BEXwC-oo.mjs";
23
23
  import { PYTHON_VERSION, buildBinaryPath, downloadBinary, ensureBinary, ensureFfmpeg, ensurePython, findInPath, getFfmpegDownloadUrl, getPlatformInfo, getPythonDownloadUrl, installPythonPackages, installPythonRequirements } from "@camstack/types/node";
24
24
  import { request } from "node:http";
@@ -93252,4 +93252,4 @@ async function stageFrameworkLockstep(input) {
93252
93252
  return results;
93253
93253
  }
93254
93254
  //#endregion
93255
- export { AGENT_CAP_FWD_ACTION, AGENT_CAP_FWD_SERVICE, AddonApiFactory, AddonDepsManager, AddonEngineManager, AddonHealthMonitor, AddonInstaller, AddonLoader, AddonManifest, AddonRouteRegistry, AlertCenterAddon, ApiKeyManager, AuthManager, CLUSTER_SECRET_MISMATCH_TYPE, CLUSTER_SECRET_REJECTED_EXIT_CODE, CORE_CAP_SERVICE_NAME, CapRouteError, CapRouteResolver, CapUsageRegistry, CapabilityHandle, CapabilityRegistry, CapabilityUnavailableError, ConfigManager, ConfigStore, ConsoleDestination, ConsoleLoggingAddon, CustomActionRegistry, DEFAULT_DATA_PATH, DataPlaneRegistry, DeviceManagerAddon, DeviceRegistry, DeviceStore, EVENT_TOPIC_PREFIX, EngineManagerResolver, EventBus, FRAMEWORK_LOCKSTEP, FeatureManager, FilesystemStorageAddon, FilesystemStorageProvider, FrameDecoder, FsStorageBackend, HEALTH_MONITOR_GRACE_PERIOD_MS, HEALTH_MONITOR_RETRY_INTERVALS_MS, HEALTH_MONITOR_TICK_MS, HUB_CAP_FWD_ACTION, HUB_CAP_FWD_SERVICE, HubForwarderAddon, HubForwarderDestination, HubLogForwarder, HubNodeRegistry, INFRA_CAPABILITIES, IntegrationRegistry, JobJournal, LifecycleJobEngine, LifecycleStateMachine, LocalAuthAddon, LocalChildClient, LocalChildRegistry, LogManager, LogRingBuffer, ModelDownloadService, NATIVE_PROVIDER_SERVICE_INFIX, NativeMetricsAddon, NativeMetricsProvider, NetworkQualityTracker, NotificationService, PYTHON_VERSION, PipelineRunner, PipelineValidator, PythonEnvManager, RESTART_MARKER_FILE, RUNTIME_DEFAULTS, ReadinessRegistry, ReadinessTimeoutError, ReplEngine, RingBuffer, ScopedLogger, ScopedTokenManager, SocketChannel, SqliteSettingsAddon, SqliteSettingsBackend, StagingArea, StorageLocationManager, StorageManager, StorageOrchestratorAddon, StorageOrchestratorService, SystemConfigAddon, SystemEventBus, ToastService, UDS_NO_ROUTE_PREFIX, UdsLocalTransportClient, UdsLocalTransportServer, UserManager, WinstonDestination, WinstonLoggingAddon, __resetCapUsageRegistryForTests, adaptBrokerToCluster, bootstrapSchema, brokerCallForCap, brokerTransportLink, buildBinaryPath, buildCapRouters, buildLinkChain, buildNativeCapProxy, buildNodeManifest, buildStorageLocationRegistry, buildUdsNativeCapProxy, builderMountedCapNames, callRegisterNodeWithRetry, callWithServiceDiscovery, capActionName, capActionSuffix, capBareAction, capServiceName, classifyCapRoute, clearPendingRestart, clusterSecretMatches, collectModelFiles, contentTypeFor, copyDirRecursive, copyExtraFileDirs, createAddonContext, createAddonService, createAuthenticatedFileServer, createBroker, createBrokerDeviceManagerApi, createCoreCapService, createFileDataPlaneHandler, createHubCapForwardService, createHubService, createHwAccelService, createKernelHwAccel, createLocalTransport, createParentUnownedCallHandler, createProcessService, createReadinessService, createReadinessServiceForRegistry, createScopedProcessManager, createStreamProbeBrokerService, createUdsAddonContext, createUdsEventBridge, createUdsEventBus, createUdsLogger, createUdsLoggerWithControl, deleteModelFromDisk, deriveAgentListenPort, describeProviderKindDrift, detectWorkspacePackagesDir, downloadBinary, downloadFile, downloadModel, emitDownForOwnedCaps, encodeFrame, ensureBinary, ensureDir, ensureFfmpeg, ensureLibraryBuilt, ensureModel, ensurePython, ensureTlsCert, fetchJson, findInPath, formatLogLine, getBrokerEventBus, getCapUsageRegistry, getFfmpegDownloadUrl, getModelFilePath, getMoleculerEventStats, getOrInitReadinessRegistry, getOrInitReadinessRegistryForClient, getPidStats, getPlatformInfo, getPythonDownloadUrl, getRestartMarkerPath, getSinglePidStats, getWorkerDeviceRegistry, hashClusterSecret, installManifestNativeDeps, installManifestPythonDeps, installPackageFromNpm, installPythonPackages, installPythonRequirements, ipcChildLink, ipcParentLink, isAddonDeploySource, isClusterSecretMismatchError, isInfraCapability, isModelDownloaded, isSourceNewer, loadTlsCert, localEndpointPath, localProviderLink, mountNativeCapService, parseCapAction, parseRangeHeader, parseTokenizedUrl, proxyToUpstream, readPendingRestart, readinessKey, registerEventBusService, resolveFilePath, resolveHwAccel, scheduleSelfRestart, scopeKey, scopesAllowDeviceCap, serializeTypedArrays, setHubConnected, setNodeEventInterest, stageFrameworkLockstep, stripCamstackDeps, subscribePassthrough, udsChildLogToWorkerEntry, validateProviderRegistrations, writePendingRestart };
93255
+ export { AGENT_CAP_FWD_ACTION, AGENT_CAP_FWD_SERVICE, AddonApiFactory, AddonDepsManager, AddonEngineManager, AddonHealthMonitor, AddonInstaller, AddonLoader, AddonManifest, AddonRouteRegistry, AlertCenterAddon, ApiKeyManager, AuthManager, CLUSTER_SECRET_MISMATCH_TYPE, CLUSTER_SECRET_REJECTED_EXIT_CODE, CORE_CAP_SERVICE_NAME, CapRouteError, CapRouteResolver, CapUsageRegistry, CapabilityHandle, CapabilityRegistry, CapabilityUnavailableError, ConfigManager, ConfigStore, ConsoleDestination, ConsoleLoggingAddon, CustomActionRegistry, DEFAULT_DATA_PATH, DataPlaneRegistry, DeviceManagerAddon, DeviceRegistry, DeviceStore, EVENT_TOPIC_PREFIX, EngineManagerResolver, EventBus, FRAMEWORK_LOCKSTEP, FeatureManager, FilesystemStorageAddon, FilesystemStorageProvider, FrameDecoder, FsStorageBackend, HEALTH_MONITOR_GRACE_PERIOD_MS, HEALTH_MONITOR_RETRY_INTERVALS_MS, HEALTH_MONITOR_TICK_MS, HUB_CAP_FWD_ACTION, HUB_CAP_FWD_SERVICE, HubForwarderAddon, HubForwarderDestination, HubLogForwarder, HubNodeRegistry, INFRA_CAPABILITIES, IntegrationRegistry, JobJournal, LifecycleJobEngine, LifecycleStateMachine, LocalAuthAddon, LocalChildClient, LocalChildRegistry, LogManager, LogRingBuffer, ModelDownloadService, NATIVE_PROVIDER_SERVICE_INFIX, NativeMetricsAddon, NativeMetricsProvider, NetworkQualityTracker, NotificationService, PYTHON_VERSION, PipelineRunner, PipelineValidator, PythonEnvManager, RESTART_MARKER_FILE, RUNTIME_DEFAULTS, ReadinessRegistry, ReadinessTimeoutError, ReplEngine, RingBuffer, ScopedLogger, ScopedTokenManager, SocketChannel, SqliteSettingsAddon, SqliteSettingsBackend, StagingArea, StorageLocationManager, StorageManager, StorageOrchestratorAddon, StorageOrchestratorService, SystemConfigAddon, SystemEventBus, ToastService, UDS_NO_ROUTE_PREFIX, UdsLocalTransportClient, UdsLocalTransportServer, UserManager, WinstonDestination, WinstonLoggingAddon, __resetCapUsageRegistryForTests, adaptBrokerToCluster, bootstrapSchema, brokerCallForCap, brokerTransportLink, buildBinaryPath, buildCapRouters, buildLinkChain, buildNativeCapProxy, buildNodeManifest, buildStorageLocationRegistry, buildUdsNativeCapProxy, builderMountedCapNames, callRegisterNodeWithRetry, callWithServiceDiscovery, capActionName, capActionSuffix, capBareAction, capServiceName, classifyCapRoute, clearPendingRestart, clusterSecretMatches, collectModelFiles, contentTypeFor, copyDirRecursive, copyExtraFileDirs, createAddonContext, createAddonService, createAuthenticatedFileServer, createBroker, createBrokerDeviceManagerApi, createCoreCapService, createFileDataPlaneHandler, createHubCapForwardService, createHubService, createKernelHwAccel, createLocalTransport, createParentUnownedCallHandler, createProcessService, createReadinessService, createReadinessServiceForRegistry, createScopedProcessManager, createStreamProbeBrokerService, createUdsAddonContext, createUdsEventBridge, createUdsEventBus, createUdsLogger, createUdsLoggerWithControl, deleteModelFromDisk, deriveAgentListenPort, describeProviderKindDrift, detectWorkspacePackagesDir, downloadBinary, downloadFile, downloadModel, emitDownForOwnedCaps, encodeFrame, ensureBinary, ensureDir, ensureFfmpeg, ensureLibraryBuilt, ensureModel, ensurePython, ensureTlsCert, fetchJson, findInPath, formatLogLine, getBrokerEventBus, getCapUsageRegistry, getFfmpegDownloadUrl, getModelFilePath, getMoleculerEventStats, getOrInitReadinessRegistry, getOrInitReadinessRegistryForClient, getPidStats, getPlatformInfo, getPythonDownloadUrl, getRestartMarkerPath, getSinglePidStats, getWorkerDeviceRegistry, hashClusterSecret, installManifestNativeDeps, installManifestPythonDeps, installPackageFromNpm, installPythonPackages, installPythonRequirements, ipcChildLink, ipcParentLink, isAddonDeploySource, isClusterSecretMismatchError, isInfraCapability, isModelDownloaded, isSourceNewer, loadTlsCert, localEndpointPath, localProviderLink, mountNativeCapService, parseCapAction, parseRangeHeader, parseTokenizedUrl, proxyToUpstream, readPendingRestart, readinessKey, registerEventBusService, resolveFilePath, resolveHwAccel, scheduleSelfRestart, scopeKey, scopesAllowDeviceCap, serializeTypedArrays, setHubConnected, setNodeEventInterest, stageFrameworkLockstep, stripCamstackDeps, subscribePassthrough, udsChildLogToWorkerEntry, validateProviderRegistrations, writePendingRestart };
@@ -51,13 +51,11 @@ export type { UdsReadinessClient } from './moleculer/readiness-context.js';
51
51
  export { createStreamProbeBrokerService } from './moleculer/stream-probe-service.js';
52
52
  export type { StreamProbeBrokerDeps } from './moleculer/stream-probe-service.js';
53
53
  export { resolveHwAccel, createKernelHwAccel } from './hwaccel/hwaccel-resolver.js';
54
- export { createHwAccelService } from './hwaccel/hwaccel-service.js';
55
54
  export { AddonDepsManager } from './deps/addon-deps-manager.js';
56
55
  export { installManifestPythonDeps } from './deps/manifest-python-deps.js';
57
56
  export { installManifestNativeDeps } from './deps/manifest-native-deps.js';
58
57
  export { AddonHealthMonitor, HEALTH_MONITOR_TICK_MS, HEALTH_MONITOR_GRACE_PERIOD_MS, HEALTH_MONITOR_RETRY_INTERVALS_MS, } from './addon-health-monitor.js';
59
58
  export type { AddonHealthPhase, AddonHealthState, AddonHealthSnapshot, AddonHealthMonitorOptions, } from './addon-health-monitor.js';
60
- export type { HwAccelServiceDeps } from './hwaccel/hwaccel-service.js';
61
59
  export type { HubServiceDeps } from './moleculer/hub-service.js';
62
60
  export { createBrokerDeviceManagerApi, buildNativeCapProxy, buildUdsNativeCapProxy, mountNativeCapService, NATIVE_PROVIDER_SERVICE_INFIX, } from './moleculer/device-cap-proxy.js';
63
61
  export type { WorkerDeviceManagerOptions } from './moleculer/device-cap-proxy.js';
@@ -58,6 +58,26 @@ export interface ParentUnownedCallDeps {
58
58
  * deviceId-carrying SYSTEM-cap calls (e.g. `system.info({deviceId})`) fast.
59
59
  */
60
60
  readonly isDeviceNativeCap?: (capName: string) => boolean;
61
+ /**
62
+ * Optional predicate — returns `true` when `capName` declares
63
+ * `nodeIdMode: 'data'` in its `CapabilityDefinition` (`addon-settings`,
64
+ * `addons`, `nodes`, `pipeline-orchestrator`): an inline `nodeId` in the
65
+ * call args is DATA for the (hub-singleton) provider, which dispatches
66
+ * internally — NOT a routing hint. For such caps the handler must NOT lift
67
+ * `args.nodeId` into a routing pin: pinning routes the call to a node with
68
+ * no provider for the cap (e.g. a forked addon on an agent calling
69
+ * `addon-settings.getGlobalSettings({addonId, nodeId})` gets pinned to
70
+ * `nodeId` → dead broker fallback → ServiceNotFoundError). Suppressing the
71
+ * pin forwards the call unpinned → singleton resolution on the hub — exactly
72
+ * how `settings-store` (no `nodeId` arg) already behaves. `args` pass
73
+ * through UNTOUCHED: the provider still reads `nodeId` as data.
74
+ *
75
+ * The kernel layer has no cap registry, so the wiring side (which does)
76
+ * injects this. Omitted (or returning `false`) ⇒ legacy behaviour exactly:
77
+ * an inline `args.nodeId` keeps pinning (benchmark, platform-probe,
78
+ * pipeline-runner node-pinned execution is unaffected).
79
+ */
80
+ readonly isDataNodeIdCap?: (capName: string) => boolean;
61
81
  /**
62
82
  * Optional forward-to-hub dispatcher (the AGENT path). When present, a cap
63
83
  * that no agent-LOCAL child owns is forwarded to the hub's `$hub-cap-fwd`
@@ -1425,6 +1425,18 @@ function createBrokerDeviceManagerApi(opts) {
1425
1425
  meta: { error: err instanceof Error ? err.message : String(err) }
1426
1426
  });
1427
1427
  });
1428
+ if (initialMeta.display !== void 0) await callDeviceManager(api, "setDisplay", {
1429
+ deviceId: id,
1430
+ display: initialMeta.display
1431
+ }).catch((err) => {
1432
+ opts.logger.warn("create: setDisplay pre-seed failed", {
1433
+ tags: {
1434
+ stableId,
1435
+ deviceId: id
1436
+ },
1437
+ meta: { error: err instanceof Error ? err.message : String(err) }
1438
+ });
1439
+ });
1428
1440
  }
1429
1441
  if (Object.keys(config).length > 0) await callDeviceManager(api, "persistConfig", {
1430
1442
  deviceId: id,
@@ -4868,7 +4880,7 @@ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
4868
4880
  function createParentUnownedCallHandler(deps) {
4869
4881
  return async (input) => {
4870
4882
  const deviceId = input.deviceId ?? extractDeviceId(input.args);
4871
- const nodeId = input.nodeId ?? extractNodeId(input.args);
4883
+ const nodeId = deps.isDataNodeIdCap?.(input.capName) === true ? void 0 : input.nodeId ?? extractNodeId(input.args);
4872
4884
  if (nodeId === void 0) {
4873
4885
  const empty = deps.resolveEmptyCollection?.(input.capName, input.method);
4874
4886
  if (empty != null) return empty;
@@ -5514,16 +5526,6 @@ function __resetCapUsageRegistryForTests() {
5514
5526
  singleton = null;
5515
5527
  }
5516
5528
  //#endregion
5517
- //#region src/kernel/hwaccel/hwaccel-service.ts
5518
- function createHwAccelService(deps) {
5519
- return {
5520
- name: "$hwaccel",
5521
- actions: { resolve: { async handler(ctx) {
5522
- return deps.resolve(ctx.params.prefer ?? null);
5523
- } } }
5524
- };
5525
- }
5526
- //#endregion
5527
5529
  //#region src/kernel/hwaccel/hwaccel-resolver.ts
5528
5530
  /**
5529
5531
  * Platform-probe for hardware video decode acceleration.
@@ -6617,24 +6619,6 @@ function createRemoteProviderProxy(broker, serviceName, capName, nodeId, methods
6617
6619
  function runtimeNodeId(runtime) {
6618
6620
  return runtime.mode === "broker" ? runtime.broker.nodeID : runtime.nodeId;
6619
6621
  }
6620
- var hwaccelRegistered = /* @__PURE__ */ new WeakSet();
6621
- /**
6622
- * Idempotently register the per-node `$hwaccel` Moleculer service on
6623
- * `broker`. Safe to call multiple times. The service exposes the
6624
- * local platform probe as `$hwaccel.resolve` so cross-node queries
6625
- * (`broker.call('$hwaccel.resolve', p, { nodeID })`) work.
6626
- */
6627
- function ensureHwAccelService(broker) {
6628
- if (hwaccelRegistered.has(broker)) return;
6629
- const bkr = broker;
6630
- try {
6631
- bkr.createService(createHwAccelService(createKernelHwAccel()));
6632
- hwaccelRegistered.add(broker);
6633
- } catch (err) {
6634
- if (!(err instanceof Error ? err.message : String(err)).includes("already registered")) throw err;
6635
- hwaccelRegistered.add(broker);
6636
- }
6637
- }
6638
6622
  /**
6639
6623
  * Adapt a Moleculer ServiceBroker to the camstack-types `IClusterBroker`
6640
6624
  * structural interface so addons can consume cluster-level RPC without
@@ -6941,7 +6925,6 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
6941
6925
  value
6942
6926
  })
6943
6927
  };
6944
- if (runtime.mode === "broker") ensureHwAccelService(runtime.broker);
6945
6928
  const hwaccel = createKernelHwAccel();
6946
6929
  return {
6947
6930
  localNodeId: nodeId,
@@ -7301,12 +7284,6 @@ Object.defineProperty(exports, "createHubCapForwardService", {
7301
7284
  return createHubCapForwardService;
7302
7285
  }
7303
7286
  });
7304
- Object.defineProperty(exports, "createHwAccelService", {
7305
- enumerable: true,
7306
- get: function() {
7307
- return createHwAccelService;
7308
- }
7309
- });
7310
7287
  Object.defineProperty(exports, "createKernelHwAccel", {
7311
7288
  enumerable: true,
7312
7289
  get: function() {
@@ -11,7 +11,7 @@ import { promisify } from "node:util";
11
11
  import * as os from "node:os";
12
12
  import { tmpdir } from "node:os";
13
13
  import { unlink } from "node:fs/promises";
14
- import { DATAPLANE_SECRET_HEADER as DATAPLANE_SECRET_HEADER$1, DeviceType as DeviceType$1, DisposerChain, EventCategory as EventCategory$1, ReadinessRegistry, asJsonObject as asJsonObject$1, asString as asString$1, createDeviceProxy, deviceOpsCapability, emitReadiness, errMsg as errMsg$1, expandCapMethods as expandCapMethods$1, scopeKey, sleep as sleep$1 } from "@camstack/types/addon";
14
+ import { DATAPLANE_SECRET_HEADER as DATAPLANE_SECRET_HEADER$1, DeviceType as DeviceType$1, DisposerChain, EventCategory as EventCategory$1, ReadinessRegistry, asJsonObject as asJsonObject$1, asString as asString$1, createDeviceProxy, deviceOpsCapability, emitReadiness as emitReadiness$1, errMsg as errMsg$1, expandCapMethods as expandCapMethods$1, scopeKey, sleep as sleep$1 } 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
@@ -1237,7 +1237,7 @@ function createBrokerDeviceManagerApi(opts) {
1237
1237
  nodeId
1238
1238
  }
1239
1239
  });
1240
- emitReadiness(eventBus, {
1240
+ emitReadiness$1(eventBus, {
1241
1241
  capName: cap.name,
1242
1242
  scope: {
1243
1243
  type: "device",
@@ -1423,6 +1423,18 @@ function createBrokerDeviceManagerApi(opts) {
1423
1423
  meta: { error: err instanceof Error ? err.message : String(err) }
1424
1424
  });
1425
1425
  });
1426
+ if (initialMeta.display !== void 0) await callDeviceManager(api, "setDisplay", {
1427
+ deviceId: id,
1428
+ display: initialMeta.display
1429
+ }).catch((err) => {
1430
+ opts.logger.warn("create: setDisplay pre-seed failed", {
1431
+ tags: {
1432
+ stableId,
1433
+ deviceId: id
1434
+ },
1435
+ meta: { error: err instanceof Error ? err.message : String(err) }
1436
+ });
1437
+ });
1426
1438
  }
1427
1439
  if (Object.keys(config).length > 0) await callDeviceManager(api, "persistConfig", {
1428
1440
  deviceId: id,
@@ -1768,7 +1780,7 @@ function createBrokerDeviceManagerApi(opts) {
1768
1780
  nodeId
1769
1781
  }
1770
1782
  });
1771
- emitReadiness(eventBus, {
1783
+ emitReadiness$1(eventBus, {
1772
1784
  capName,
1773
1785
  scope: {
1774
1786
  type: "device",
@@ -4866,7 +4878,7 @@ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
4866
4878
  function createParentUnownedCallHandler(deps) {
4867
4879
  return async (input) => {
4868
4880
  const deviceId = input.deviceId ?? extractDeviceId(input.args);
4869
- const nodeId = input.nodeId ?? extractNodeId(input.args);
4881
+ const nodeId = deps.isDataNodeIdCap?.(input.capName) === true ? void 0 : input.nodeId ?? extractNodeId(input.args);
4870
4882
  if (nodeId === void 0) {
4871
4883
  const empty = deps.resolveEmptyCollection?.(input.capName, input.method);
4872
4884
  if (empty != null) return empty;
@@ -5512,16 +5524,6 @@ function __resetCapUsageRegistryForTests() {
5512
5524
  singleton = null;
5513
5525
  }
5514
5526
  //#endregion
5515
- //#region src/kernel/hwaccel/hwaccel-service.ts
5516
- function createHwAccelService(deps) {
5517
- return {
5518
- name: "$hwaccel",
5519
- actions: { resolve: { async handler(ctx) {
5520
- return deps.resolve(ctx.params.prefer ?? null);
5521
- } } }
5522
- };
5523
- }
5524
- //#endregion
5525
5527
  //#region src/kernel/hwaccel/hwaccel-resolver.ts
5526
5528
  /**
5527
5529
  * Platform-probe for hardware video decode acceleration.
@@ -6615,24 +6617,6 @@ function createRemoteProviderProxy(broker, serviceName, capName, nodeId, methods
6615
6617
  function runtimeNodeId(runtime) {
6616
6618
  return runtime.mode === "broker" ? runtime.broker.nodeID : runtime.nodeId;
6617
6619
  }
6618
- var hwaccelRegistered = /* @__PURE__ */ new WeakSet();
6619
- /**
6620
- * Idempotently register the per-node `$hwaccel` Moleculer service on
6621
- * `broker`. Safe to call multiple times. The service exposes the
6622
- * local platform probe as `$hwaccel.resolve` so cross-node queries
6623
- * (`broker.call('$hwaccel.resolve', p, { nodeID })`) work.
6624
- */
6625
- function ensureHwAccelService(broker) {
6626
- if (hwaccelRegistered.has(broker)) return;
6627
- const bkr = broker;
6628
- try {
6629
- bkr.createService(createHwAccelService(createKernelHwAccel()));
6630
- hwaccelRegistered.add(broker);
6631
- } catch (err) {
6632
- if (!(err instanceof Error ? err.message : String(err)).includes("already registered")) throw err;
6633
- hwaccelRegistered.add(broker);
6634
- }
6635
- }
6636
6620
  /**
6637
6621
  * Adapt a Moleculer ServiceBroker to the camstack-types `IClusterBroker`
6638
6622
  * structural interface so addons can consume cluster-level RPC without
@@ -6939,7 +6923,6 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
6939
6923
  value
6940
6924
  })
6941
6925
  };
6942
- if (runtime.mode === "broker") ensureHwAccelService(runtime.broker);
6943
6926
  const hwaccel = createKernelHwAccel();
6944
6927
  return {
6945
6928
  localNodeId: nodeId,
@@ -7077,4 +7060,4 @@ async function installManifestPythonDeps(declaration, addonDir, deps, logger) {
7077
7060
  await deps.installPythonRequirements(reqAbs);
7078
7061
  }
7079
7062
  //#endregion
7080
- export { buildNativeCapProxy as $, createHubCapForwardService as A, AGENT_CAP_FWD_ACTION as B, brokerTransportLink as C, localProviderLink as D, ipcParentLink as E, createUdsLogger as F, callWithServiceDiscovery as G, CapRouteResolver as H, createUdsLoggerWithControl as I, UdsLocalTransportServer as J, createLocalTransport as K, LocalChildClient as L, createUdsEventBridge as M, createUdsEventBus as N, HUB_CAP_FWD_ACTION as O, udsChildLogToWorkerEntry as P, encodeFrame as Q, LocalChildRegistry as R, brokerCallForCap as S, ipcChildLink as T, CapRouteError as U, AGENT_CAP_FWD_SERVICE as V, classifyCapRoute as W, localEndpointPath as X, SocketChannel as Y, FrameDecoder as Z, resolveHwAccel as _, CapabilityHandle as _t, getWorkerDeviceRegistry as a, setWorkerNativeCapsChangeListener as at, __resetCapUsageRegistryForTests as b, resolveAddonClass as bt, setHubConnected as c, NATIVE_PROVIDER_SERVICE_INFIX as ct, getMoleculerEventStats as d, capBareAction as dt, buildUdsNativeCapProxy as et, registerEventBusService as f, capServiceName as ft, createKernelHwAccel as g, DeviceRegistry as gt, AddonDepsManager as h, serializeTypedArrays as ht, createUdsAddonContext as i, mountNativeCapService as it, createParentUnownedCallHandler as j, HUB_CAP_FWD_SERVICE as k, EVENT_TOPIC_PREFIX as l, capActionName as lt, subscribePassthrough as m, deserializeTypedArrays as mt, adaptBrokerToCluster as n, getWorkerNativeCapProvider as nt, getOrInitReadinessRegistry as o, createAddonService as ot, setNodeEventInterest as p, parseCapAction as pt, UdsLocalTransportClient as q, createAddonContext as r, getWorkerNativeCapSnapshot as rt, getOrInitReadinessRegistryForClient as s, validateProviderRegistrations as st, installManifestPythonDeps as t, createBrokerDeviceManagerApi as tt, getBrokerEventBus as u, capActionSuffix as ut, createHwAccelService as v, CapabilityUnavailableError as vt, buildLinkChain as w, getCapUsageRegistry as x, CapUsageRegistry as y, installManifestNativeDeps as yt, UDS_NO_ROUTE_PREFIX as z };
7063
+ export { buildUdsNativeCapProxy as $, createParentUnownedCallHandler as A, AGENT_CAP_FWD_SERVICE as B, buildLinkChain as C, HUB_CAP_FWD_ACTION as D, localProviderLink as E, createUdsLoggerWithControl as F, createLocalTransport as G, CapRouteError as H, LocalChildClient as I, SocketChannel as J, UdsLocalTransportClient as K, LocalChildRegistry as L, createUdsEventBus as M, udsChildLogToWorkerEntry as N, HUB_CAP_FWD_SERVICE as O, createUdsLogger as P, buildNativeCapProxy as Q, UDS_NO_ROUTE_PREFIX as R, brokerTransportLink as S, ipcParentLink as T, classifyCapRoute as U, CapRouteResolver as V, callWithServiceDiscovery as W, FrameDecoder as X, localEndpointPath as Y, encodeFrame as Z, resolveHwAccel as _, CapabilityUnavailableError as _t, getWorkerDeviceRegistry as a, createAddonService as at, getCapUsageRegistry as b, setHubConnected as c, capActionName as ct, getMoleculerEventStats as d, capServiceName as dt, createBrokerDeviceManagerApi as et, registerEventBusService as f, parseCapAction as ft, createKernelHwAccel as g, CapabilityHandle as gt, AddonDepsManager as h, DeviceRegistry as ht, createUdsAddonContext as i, setWorkerNativeCapsChangeListener as it, createUdsEventBridge as j, createHubCapForwardService as k, EVENT_TOPIC_PREFIX as l, capActionSuffix as lt, subscribePassthrough as m, serializeTypedArrays as mt, adaptBrokerToCluster as n, getWorkerNativeCapSnapshot as nt, getOrInitReadinessRegistry as o, validateProviderRegistrations as ot, setNodeEventInterest as p, deserializeTypedArrays as pt, UdsLocalTransportServer as q, createAddonContext as r, mountNativeCapService as rt, getOrInitReadinessRegistryForClient as s, NATIVE_PROVIDER_SERVICE_INFIX as st, installManifestPythonDeps as t, getWorkerNativeCapProvider as tt, getBrokerEventBus as u, capBareAction as ut, CapUsageRegistry as v, installManifestNativeDeps as vt, ipcChildLink as w, brokerCallForCap as x, __resetCapUsageRegistryForTests as y, resolveAddonClass as yt, AGENT_CAP_FWD_ACTION as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/system",
3
- "version": "1.1.23",
3
+ "version": "1.1.25",
4
4
  "description": "Core addon for CamStack — builtins, pipeline, process management, auth, logging, events",
5
5
  "keywords": [
6
6
  "camstack",
@@ -1,4 +0,0 @@
1
- import { ServiceSchema } from 'moleculer';
2
- import { IKernelHwAccel } from '@camstack/types';
3
- export type HwAccelServiceDeps = IKernelHwAccel;
4
- export declare function createHwAccelService(deps: HwAccelServiceDeps): ServiceSchema;