@camstack/server 1.2.932 → 1.2.934

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/api/trpc/generated-cap-routers.js +20 -0
  3. package/package.json +8 -7
  4. package/system/dist/addon-utils.mjs +1 -1
  5. package/system/dist/{base-device-IuM1AwXZ.mjs → base-device-Bwiblqmn.mjs} +1 -1
  6. package/system/dist/{base-device-2sL1DMm1.js → base-device-C1z4zYGR.js} +1 -1
  7. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +3 -3
  8. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +4 -4
  9. package/system/dist/builtins/alerts/alerts.addon.js +2 -2
  10. package/system/dist/builtins/alerts/alerts.addon.mjs +4 -4
  11. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +4 -4
  12. package/system/dist/builtins/camera-grid/index.js +2 -2
  13. package/system/dist/builtins/camera-grid/index.mjs +2 -2
  14. package/system/dist/builtins/composer/composer.addon.js +5 -5
  15. package/system/dist/builtins/composer/composer.addon.mjs +5 -5
  16. package/system/dist/builtins/core-blocks/cap-links.d.ts +34 -0
  17. package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +4 -0
  18. package/system/dist/builtins/core-blocks/core-blocks.addon.js +282 -8
  19. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +282 -8
  20. package/system/dist/builtins/device-manager/device-manager.addon.js +18 -4
  21. package/system/dist/builtins/device-manager/device-manager.addon.mjs +18 -4
  22. package/system/dist/builtins/local-auth/local-auth.addon.mjs +3 -3
  23. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  24. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +9 -9
  25. package/system/dist/builtins/platform-probe/index.mjs +9 -9
  26. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +19 -19
  27. package/system/dist/builtins/system-config/system-config.addon.mjs +113 -113
  28. package/system/dist/{composition-sources-BEUWn2s_.mjs → composition-sources-B0QW4g86.mjs} +2 -2
  29. package/system/dist/{composition-sources-acfR4hDq.js → composition-sources-BtUx1MfU.js} +2 -2
  30. package/system/dist/{coral-accelerators-zTMTEd-8.mjs → coral-accelerators-BKcXP59c.mjs} +6 -6
  31. package/system/dist/{core-blocks.cap-BRPsLAij.mjs → core-blocks.cap-CnwBuf7E.mjs} +1524 -1267
  32. package/system/dist/{core-blocks.cap-BMeMCBrx.js → core-blocks.cap-DlEuHq-S.js} +1555 -1268
  33. package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
  34. package/system/dist/{error.cap-CSM_SRfR.mjs → error.cap-5zNPAgU2.mjs} +19 -2
  35. package/system/dist/{error.cap-DBhgPeWK.js → error.cap-BCqzFlo2.js} +24 -1
  36. package/system/dist/{hub-identity-_IOgPJ00.mjs → hub-identity-DjMN9Ac2.mjs} +9 -9
  37. package/system/dist/{hub-mdns-ciao-Dk7ts_Uk.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +1 -1
  38. package/system/dist/index.js +2 -2
  39. package/system/dist/index.mjs +214 -214
  40. package/system/dist/{prefix-walk-ifwg_ukx.mjs → prefix-walk-CRnbYJcC.mjs} +2 -2
  41. package/system/dist/{prefix-walk-BkMxoXpL.js → prefix-walk-DD1BM923.js} +2 -2
  42. package/system/dist/{rename-composition-block-BJsL58Ih.js → rename-composition-block-BRgyBO25.js} +20 -2
  43. package/system/dist/{rename-composition-block-OAtErZgq.mjs → rename-composition-block-BYRBlx-V.mjs} +20 -2
  44. package/system/dist/{restore-archive-kSFNjkWY.mjs → restore-archive-CjAyKpgX.mjs} +93 -93
  45. package/system/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { r as MotionStatusSchema } from "../../stream-catalog.cap-Bp7SkgIf.mjs";
2
2
  import { _ as hydrateSchema, a as isSecretRefOwnedBy, b as EventCategory$1, f as defineAddonMigrations, i as collectSecretMarkerRefs, l as RecordIntegrationInstances, o as resolveSecretMarkers, r as secretTreeFromSchema, s as transformSecretWrite, t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
3
3
  import { W as isSecretMarker, Z as errMsg$1 } from "../../scoped-settings-DVWUIP7Z.mjs";
4
- import { $ as RemoteLayoutPayloadSchema, $n as unitsForQuantity, $t as FanPresetSchema, A as TemplateKindSchema, At as measurementFitsRole, B as SmokeStatusSchema, Bn as AutomationControlStatusSchema, Bt as timedRunRemaining, C as WaterHeaterStatusSchema, Cn as ContactStatusSchema, Ct as projectDeviceRow, D as VacuumControlStatusSchema, Dn as COMPOSER_RUNNER_ID, Dt as contactMeasurement, Et as resolveHeroSceneId, F as TamperStatusSchema, Fn as CarbonMonoxideStatusSchema, Ft as TimedRunStatusSchema, G as hasOwnRunningPowerDefaults, Gt as GroupStatusSchema, H as schedulersCapability, Hn as AirQualitySensorStatusSchema, Ht as HeatingValveStatusSchema, I as tagsCapability, In as BrightnessStatusSchema, It as timedRunCapability, J as REMOTE_MEDIA_COMMANDS, K as runningPowerDefaultsFor, Kn as actionWaitTotalMs, L as SWITCH_DEFAULT_OPTIONS, Lt as timedRunLimitOf, M as AutomationTemplatePayloadSchema, Mn as ClimateControlStatusSchema, Mt as temperatureMeasurement, N as reexpandAutomationInstance, Nt as textMeasurement, O as UpdateStatusSchema, Ot as emptyMeasurement, P as TemperatureSensorStatusSchema, Pt as NOT_REPORTED, Q as RemoteAssumedStateSchema, Qn as baseUnitForQuantity, Qt as FAN_CAPTURE_FIELDS, R as SwitchStatusSchema, Rn as BinaryStatusSchema, Rt as timedRunMaxIn, S as WeatherStatusSchema, Sn as ControlStatusSchema, St as ROW_READING_FACT_IDS, T as ValveStatusSchema, Tn as ConsumablesStatusSchema, Tt as REMOTE_OPEN_ACTION_ID, Ut as HeatPumpStatusSchema, V as ScriptRunnerStatusSchema, Vn as AmbientLightSensorStatusSchema, Vt as timedRunSeconds, W as RunningStateStatusSchema, Wn as actionsCapability, Wt as heatPumpInstantCop, X as EMPTY_REMOTE_ASSUMED_STATE, Xn as normalizeActionUnits, Xt as GasStatusSchema, Y as remoteCapability, Yn as capUnitResolver, Yt as GroupActiveSchema, Z as EMPTY_REMOTE_CONFIG, Zn as normalizeRecipeUnits, Zt as FloodStatusSchema, _ as WorkloadStatusSchema, _t as LawnMowerControlStatusSchema, an as SetOscillationAxisInputSchema, ar as addonIdOfActionId, bn as CoverStatusSchema, bt as HumidifierStatusSchema, c as kebabToCamel, cn as EnumSensorStatusSchema, cr as resolveActionVariables, dn as DishwasherStatusSchema, dt as NumericSensorStatusSchema, en as fanPresetsCapability, er as ActionError, et as readStoredRemoteConfig, ft as NetworkLinkStatusSchema, ht as LockControlStatusSchema, ir as INTERNAL_ACTION_PREFIX, it as PowerMeterStatusSchema, j as checkTemplatePayload, jt as powerMeasurement, k as templateCapability, kn as ColorStatusSchema, kt as humidityMeasurement, ln as DoorbellStatusSchema, lr as EventEmitterStatusSchema, lt as PetFeederStatusSchema, m as ALL_CAPABILITY_DEFINITIONS, mt as MeterStatusSchema, nn as FAN_OSCILLATION_AXIS_SETTABLE, nr as ActionVariableSchema, nt as PressureSensorStatusSchema, on as fanAxisPath, or as internalActionId, ot as PetFountainStatusSchema, pt as MotionTriggerStatusSchema, q as remoteLayoutComponentsCapability, qn as actionSourceCapability, qt as GroupCommandsSchema, rn as FanControlStatusSchema, rr as IDLE_ACTION_STATUS, rt as PresenceStatusSchema, sr as isInternalActionId, t as composedBlockIdOf, tn as FAN_OSCILLATION_AXES, tr as ActionMinDelaySecSchema, tt as PumpCycleStatusSchema, un as DoNotDisturbStatusSchema, vt as ImageStatusSchema, w as VibrationStatusSchema, wt as HERO_SCENE_ROW_IDS, x as WeatherStationStatusSchema, xt as heroLayoutCapability, yt as HumiditySensorStatusSchema, zn as BatteryStatusSchema, zt as timedRunQuickRun } from "../../rename-composition-block-OAtErZgq.mjs";
4
+ import { $ as RemoteLayoutPayloadSchema, $n as unitsForQuantity, $t as FanPresetSchema, A as TemplateKindSchema, At as measurementFitsRole, B as SmokeStatusSchema, Bn as AutomationControlStatusSchema, Bt as timedRunRemaining, C as WaterHeaterStatusSchema, Cn as ContactStatusSchema, Ct as projectDeviceRow, D as VacuumControlStatusSchema, Dn as COMPOSER_RUNNER_ID, Dt as contactMeasurement, Et as resolveHeroSceneId, F as TamperStatusSchema, Fn as CarbonMonoxideStatusSchema, Ft as TimedRunStatusSchema, G as hasOwnRunningPowerDefaults, Gt as GroupStatusSchema, H as schedulersCapability, Hn as AirQualitySensorStatusSchema, Ht as HeatingValveStatusSchema, I as tagsCapability, In as BrightnessStatusSchema, It as timedRunCapability, J as REMOTE_MEDIA_COMMANDS, K as runningPowerDefaultsFor, Kn as actionWaitTotalMs, L as SWITCH_DEFAULT_OPTIONS, Lt as timedRunLimitOf, M as AutomationTemplatePayloadSchema, Mn as ClimateControlStatusSchema, Mt as temperatureMeasurement, N as reexpandAutomationInstance, Nt as textMeasurement, O as UpdateStatusSchema, Ot as emptyMeasurement, P as TemperatureSensorStatusSchema, Pt as NOT_REPORTED, Q as RemoteAssumedStateSchema, Qn as baseUnitForQuantity, Qt as FAN_CAPTURE_FIELDS, R as SwitchStatusSchema, Rn as BinaryStatusSchema, Rt as timedRunMaxIn, S as WeatherStatusSchema, Sn as ControlStatusSchema, St as ROW_READING_FACT_IDS, T as ValveStatusSchema, Tn as ConsumablesStatusSchema, Tt as REMOTE_OPEN_ACTION_ID, Ut as HeatPumpStatusSchema, V as ScriptRunnerStatusSchema, Vn as AmbientLightSensorStatusSchema, Vt as timedRunSeconds, W as RunningStateStatusSchema, Wn as actionsCapability, Wt as heatPumpInstantCop, X as EMPTY_REMOTE_ASSUMED_STATE, Xn as normalizeActionUnits, Xt as GasStatusSchema, Y as remoteCapability, Yn as capUnitResolver, Yt as GroupActiveSchema, Z as EMPTY_REMOTE_CONFIG, Zn as normalizeRecipeUnits, Zt as FloodStatusSchema, _ as WorkloadStatusSchema, _t as LawnMowerControlStatusSchema, an as SetOscillationAxisInputSchema, ar as addonIdOfActionId, bn as CoverStatusSchema, bt as HumidifierStatusSchema, c as kebabToCamel, cn as EnumSensorStatusSchema, cr as resolveActionVariables, dn as DishwasherStatusSchema, dt as NumericSensorStatusSchema, en as fanPresetsCapability, er as ActionError, et as readStoredRemoteConfig, ft as NetworkLinkStatusSchema, ht as LockControlStatusSchema, ir as INTERNAL_ACTION_PREFIX, it as PowerMeterStatusSchema, j as checkTemplatePayload, jt as powerMeasurement, k as templateCapability, kn as ColorStatusSchema, kt as humidityMeasurement, ln as DoorbellStatusSchema, lr as EventEmitterStatusSchema, lt as PetFeederStatusSchema, m as ALL_CAPABILITY_DEFINITIONS, mt as MeterStatusSchema, nn as FAN_OSCILLATION_AXIS_SETTABLE, nr as ActionVariableSchema, nt as PressureSensorStatusSchema, on as fanAxisPath, or as internalActionId, ot as PetFountainStatusSchema, pt as MotionTriggerStatusSchema, q as remoteLayoutComponentsCapability, qn as actionSourceCapability, qt as GroupCommandsSchema, rn as FanControlStatusSchema, rr as IDLE_ACTION_STATUS, rt as PresenceStatusSchema, sr as isInternalActionId, t as composedBlockIdOf, tn as FAN_OSCILLATION_AXES, tr as ActionMinDelaySecSchema, tt as PumpCycleStatusSchema, un as DoNotDisturbStatusSchema, vt as ImageStatusSchema, w as VibrationStatusSchema, wt as HERO_SCENE_ROW_IDS, x as WeatherStationStatusSchema, xt as heroLayoutCapability, yt as HumiditySensorStatusSchema, zn as BatteryStatusSchema, zt as timedRunQuickRun } from "../../rename-composition-block-BYRBlx-V.mjs";
5
5
  import { r as listNotificationTargets } from "../../notification-targets-DaNE-pIt.mjs";
6
6
  import { i as NcTaggedRuleKindSchema, o as AlarmPanelStatusSchema, u as NotificationSchema } from "../../notification-rules.cap-DUmiMBQB.mjs";
7
7
  import { s as defineRecordKinds } from "../../record-kind-ub6NXqfh.mjs";
@@ -12,13 +12,13 @@ import { n as baseUnitOf } from "../../quantity-D3g5SxsZ.mjs";
12
12
  import { a as defaultTagColorId, c as renameInTags, i as TagsFieldSchema, l as tagKey, n as TagNameSchema, o as normalizeTags, r as TagStyleSchema, s as removeFromTags } from "../../tag-uZBAq6ox.mjs";
13
13
  import { n as DeviceRole, r as DeviceType$1, t as DeviceFeature } from "../../device-type-DgEvK3ch.mjs";
14
14
  import { r as isAirConditioner, t as canonicalStoredDeviceType } from "../../device-kind-BJ2pfsjw.mjs";
15
- import { $t as siteFor, B as customKeyOfRole, C as powerSourceCapability, Ct as validateRecipeBounds, F as findChannelSource, It as holdOf, L as remoteSourceSteps, Mt as hasEventLeaves, Nt as isEventLeaf, Pt as compareValues, Qt as occurrenceOn, R as resolveRemoteSource, S as PowerSourceStateSchema, St as stepGuardOf, Vt as QuantityUnitError, W as toTimings, Xt as localDateOf, Zt as nextOccurrence, _ as replacedFieldKeys, _t as AutomationRecipeSchema, a as coreBlockComposition, an as canonicalStoredStepTargets, at as buildStepArgsTrace, b as powerSourceLinkOfComposition, bt as nestedStepsOf, c as coreBlocksCapability, d as resolveCoreBlockFiles, dn as vocabActionIdFor, en as weekdayOfLocalDate, f as describeComposableCaps, fn as vocabCall, ft as SchedulerSchema, g as planComposition, h as compositionUnionReads, ht as ActionStepSchema, i as coreBlockAddonId, in as ActionTargetResolver, it as appendTrace, j as MediaPlayerStatusSchema, jt as forEachLeaf, k as CAP_CUSTOMIZE_CATALOG, l as normalizeCoreBlockWrite, ln as assertDeviceOffers, lt as SchedulerError, m as compositionSourceRefs, mt as validateSchedulerInput, n as CORE_BLOCK_ADDON_PREFIX, nt as AutomationStateDocSchema, o as coreBlockIdFromAddonId, on as VocabActionError, ot as DEFAULT_HOLD_OVERRIDE, p as buildCapabilityLookup, r as CoreBlockSchema, rn as ACTION_TARGET_INVALIDATION_EVENTS, rt as EMPTY_AUTOMATION_STATE, s as coreBlockSourceKind, sn as actionEffect, t as CORE_BLOCKS_ADDON_ID, tn as zoneOnlySite, u as resolveCoreBlockEntry, un as findVocabAction, v as validateComposition, vt as HTTP_TEXT_CAP, x as PowerSourceInfoSchema, xt as stepConditionsOf, y as powerSourceActuatorConflicts, yt as REPEAT_ITEM_VAR } from "../../core-blocks.cap-BRPsLAij.mjs";
16
- import { B as helperMembers, D as composedDeviceRef, E as canonicalStoredBlockTarget, N as compositionSourceKey, O as composedDeviceStableId, T as CompositionSchema, U as DAY_MS, Y as historyRetentionFromSettings, _t as evaluateDwell, k as compositionFeatureEnabled, x as COMPOSER_ADDON_ID, z as HelperMemberSchema } from "../../error.cap-CSM_SRfR.mjs";
17
- import { a as evaluateWhenTree, c as nextTimeBoundaryInMs, i as collectWhenMirrorSources, l as stableIdMapOf, n as unwrapStoredValue, o as hasHoldLeaves, r as ConditionMirror, s as hasTimeLeaves, t as loadPrefixed } from "../../prefix-walk-ifwg_ukx.mjs";
15
+ import { A as MediaPlayerStatusSchema, C as PowerSourceStateSchema, Ct as HTTP_TEXT_CAP, Dt as stepGuardOf, Et as stepConditionsOf, I as remoteSourceSteps, It as forEachLeaf, J as capLinkServedFields, Kt as QuantityUnitError, L as resolveRemoteSource, Lt as hasEventLeaves, Ot as validateRecipeBounds, P as findChannelSource, Q as CAP_CUSTOMIZE_CATALOG, Rt as isEventLeaf, S as PowerSourceInfoSchema, St as AutomationRecipeSchema, Tt as nestedStepsOf, U as toTimings, Vt as holdOf, X as expandCapLinks, Y as declaredCapLink, Z as projectCapLinkOf, _ as replacedFieldKeys, _n as vocabCall, _t as SchedulerSchema, a as coreBlockComposition, an as weekdayOfLocalDate, b as powerSourceActuatorConflicts, bt as ActionStepSchema, c as coreBlocksCapability, cn as ACTION_TARGET_INVALIDATION_EVENTS, ct as EMPTY_AUTOMATION_STATE, d as resolveCoreBlockFiles, dn as VocabActionError, dt as DEFAULT_HOLD_OVERRIDE, f as describeComposableCaps, fn as actionEffect, g as planComposition, gn as vocabActionIdFor, h as compositionUnionReads, hn as findVocabAction, i as coreBlockAddonId, in as siteFor, l as normalizeCoreBlockWrite, ln as ActionTargetResolver, lt as appendTrace, m as compositionSourceRefs, mn as assertDeviceOffers, mt as SchedulerError, n as CORE_BLOCK_ADDON_PREFIX, nn as nextOccurrence, o as coreBlockIdFromAddonId, on as zoneOnlySite, p as buildCapabilityLookup, r as CoreBlockSchema, rn as occurrenceOn, s as coreBlockSourceKind, st as AutomationStateDocSchema, t as CORE_BLOCKS_ADDON_ID, tn as localDateOf, u as resolveCoreBlockEntry, un as canonicalStoredStepTargets, ut as buildStepArgsTrace, v as topLevelFieldsOf, w as powerSourceCapability, wt as REPEAT_ITEM_VAR, x as powerSourceLinkOfComposition, y as validateComposition, yt as validateSchedulerInput, z as customKeyOfRole, zt as compareValues } from "../../core-blocks.cap-CnwBuf7E.mjs";
16
+ import { B as helperMembers, D as composedDeviceRef, E as canonicalStoredBlockTarget, N as compositionSourceKey, O as composedDeviceStableId, T as CompositionSchema, W as DAY_MS, X as historyRetentionFromSettings, k as compositionFeatureEnabled, vt as evaluateDwell, x as COMPOSER_ADDON_ID, z as HelperMemberSchema } from "../../error.cap-5zNPAgU2.mjs";
17
+ import { a as evaluateWhenTree, c as nextTimeBoundaryInMs, i as collectWhenMirrorSources, l as stableIdMapOf, n as unwrapStoredValue, o as hasHoldLeaves, r as ConditionMirror, s as hasTimeLeaves, t as loadPrefixed } from "../../prefix-walk-CRnbYJcC.mjs";
18
18
  import { t } from "../../l10n-Bu6aUvSY.mjs";
19
19
  import { t as integrationInstancesCapability } from "../../integration-instances.cap-Cl9O-k4h.mjs";
20
20
  import { t as commandOrigin$1 } from "../../cap-call-context-DNwdgGSQ.mjs";
21
- import { r as compileScalarOverride, t as describeCompositionSources } from "../../composition-sources-BEUWn2s_.mjs";
21
+ import { r as compileScalarOverride, t as describeCompositionSources } from "../../composition-sources-B0QW4g86.mjs";
22
22
  import { r as seedInstanceOnce, t as DeclaredDevices } from "../../declared-device-CKERA1Hi.mjs";
23
23
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
24
24
  import { i as capSeriesKey, m as parseConfirmedStateChanged, p as isRecord$1 } from "../../capture-engine-DiwbjoWp.mjs";
@@ -14745,6 +14745,233 @@ var RemoteComponentsService = class {
14745
14745
  }
14746
14746
  };
14747
14747
  //#endregion
14748
+ //#region src/builtins/core-blocks/cap-links.ts
14749
+ /**
14750
+ * Whole-capability links at runtime (D1076): the read behind `getCapLinks` and
14751
+ * the one-off conversion behind `migrateCapLinks`.
14752
+ *
14753
+ * The compile path is not here: a `capLink` is expanded by `planComposition`
14754
+ * into the field claims the composer already runs. This file only READS the
14755
+ * stored links (state per link, `not-loaded` until the compositions were read,
14756
+ * D315) and REWRITES plain per-field links into one link (bounded, idempotent,
14757
+ * D345).
14758
+ */
14759
+ function hostBlock(blocks, host) {
14760
+ const key = compositionSourceKey(host);
14761
+ return blocks.find((block) => {
14762
+ const target = coreBlockComposition(block)?.target;
14763
+ return target?.kind === "existing" && compositionSourceKey(target.device) === key;
14764
+ }) ?? null;
14765
+ }
14766
+ function capLinkFeatures(composition) {
14767
+ return (composition?.features ?? []).flatMap((feature) => feature.kind === "capLink" ? [feature] : []);
14768
+ }
14769
+ var CapLinksService = class {
14770
+ ports;
14771
+ /** `host:cap:link` keys whose source-gone was already logged: one line per loss, not per read. */
14772
+ goneLogged = /* @__PURE__ */ new Set();
14773
+ constructor(ports) {
14774
+ this.ports = ports;
14775
+ }
14776
+ async read(deviceId) {
14777
+ const blocks = this.ports.blocks();
14778
+ if (blocks === null) return { status: "not-loaded" };
14779
+ const host = await this.ports.refOfDevice(deviceId);
14780
+ if (host === null) return {
14781
+ status: "ok",
14782
+ links: []
14783
+ };
14784
+ const block = hostBlock(blocks, host);
14785
+ const features = capLinkFeatures(block === null ? null : coreBlockComposition(block));
14786
+ const links = [];
14787
+ for (const feature of features) {
14788
+ const declared = declaredCapLink(feature.cap, feature.linkId);
14789
+ if (declared === void 0) continue;
14790
+ const sourceId = await this.ports.deviceIdOf(feature.source);
14791
+ const gone = sourceId === null;
14792
+ const state = !compositionFeatureEnabled(feature) ? "disabled" : gone ? "source-gone" : "linked";
14793
+ if (state === "source-gone") this.logGone(deviceId, feature);
14794
+ else this.goneLogged.delete(goneKey(deviceId, feature));
14795
+ links.push({
14796
+ linkId: feature.linkId,
14797
+ cap: feature.cap,
14798
+ slot: declared.slot ?? null,
14799
+ mode: declared.mode,
14800
+ source: {
14801
+ deviceId: sourceId,
14802
+ cap: declared.sourceCap
14803
+ },
14804
+ state
14805
+ });
14806
+ }
14807
+ return {
14808
+ status: "ok",
14809
+ links
14810
+ };
14811
+ }
14812
+ logGone(deviceId, feature) {
14813
+ const key = goneKey(deviceId, feature);
14814
+ if (this.goneLogged.has(key)) return;
14815
+ this.goneLogged.add(key);
14816
+ this.ports.logger.warn("cap link: the source device is gone — the linked cap reads unknown", {
14817
+ tags: { deviceId },
14818
+ meta: {
14819
+ cap: feature.cap,
14820
+ linkId: feature.linkId,
14821
+ source: feature.source
14822
+ }
14823
+ });
14824
+ }
14825
+ async migrate(dryRun) {
14826
+ const blocks = this.ports.blocks();
14827
+ if (blocks === null) throw new Error("core-blocks: the compositions have not loaded yet — migrateCapLinks refused");
14828
+ const report = {
14829
+ dryRun,
14830
+ converted: [],
14831
+ mixed: [],
14832
+ skipped: 0,
14833
+ alreadyLinked: 0
14834
+ };
14835
+ for (const block of blocks) {
14836
+ const composition = coreBlockComposition(block);
14837
+ if (composition === null || composition.target.kind !== "existing") continue;
14838
+ const deviceId = await this.ports.deviceIdOf(composition.target.device);
14839
+ if (deviceId === null) {
14840
+ this.ports.logger.warn("cap link migration: host device not found — customization left as is", { meta: { blockId: block.id } });
14841
+ continue;
14842
+ }
14843
+ await this.migrateBlock(block, composition, deviceId, dryRun, report);
14844
+ }
14845
+ return report;
14846
+ }
14847
+ async migrateBlock(stored, composition, deviceId, dryRun, report) {
14848
+ const caps = [...new Set(composition.features.flatMap((f) => f.kind === "fields" || f.kind === "capLink" ? [f.cap] : []))];
14849
+ let block = stored;
14850
+ let next = composition;
14851
+ for (const cap of caps) {
14852
+ const link = projectCapLinkOf(cap);
14853
+ if (link === void 0) continue;
14854
+ if (capLinkFeatures(next).some((f) => f.cap === cap)) {
14855
+ report.alreadyLinked += 1;
14856
+ continue;
14857
+ }
14858
+ const plain = next.features.filter((f) => f.kind === "fields" && f.cap === cap);
14859
+ const candidates = plain.filter((f) => f.contributedBy === void 0 && compositionFeatureEnabled(f));
14860
+ report.skipped += plain.length - candidates.length;
14861
+ if (candidates.length === 0) continue;
14862
+ const verdict = identityGroup(candidates, link.sourceCap, link.map);
14863
+ const hostFields = this.ports.hostFieldsOf(cap);
14864
+ const reasons = "reasons" in verdict ? verdict.reasons : hostFields === null ? [`the capability ${cap} is unknown here`] : widening(capLinkServedFields(link, hostFields), verdict.fields, next, candidates);
14865
+ if ("reasons" in verdict || reasons.length > 0) {
14866
+ report.mixed.push({
14867
+ deviceId,
14868
+ cap,
14869
+ reasons
14870
+ });
14871
+ continue;
14872
+ }
14873
+ if ("reasons" in verdict) continue;
14874
+ const feature = {
14875
+ kind: "capLink",
14876
+ cap,
14877
+ linkId: link.id,
14878
+ source: verdict.source
14879
+ };
14880
+ const replaced = new Set(candidates);
14881
+ const kept = next.features.filter((f) => !replaced.has(f));
14882
+ const candidate = {
14883
+ ...next,
14884
+ features: kept.concat(feature)
14885
+ };
14886
+ const converted = {
14887
+ deviceId,
14888
+ cap,
14889
+ linkId: link.id,
14890
+ source: verdict.source,
14891
+ fields: verdict.fields
14892
+ };
14893
+ if (!dryRun) try {
14894
+ block = await this.ports.rewrite(block, candidate);
14895
+ } catch (err) {
14896
+ report.mixed.push({
14897
+ deviceId,
14898
+ cap,
14899
+ reasons: [`the link was refused: ${errMsg$1(err)}`]
14900
+ });
14901
+ this.ports.logger.warn("cap link migration: conversion refused — left as it was", {
14902
+ tags: { deviceId },
14903
+ meta: {
14904
+ cap,
14905
+ error: errMsg$1(err)
14906
+ }
14907
+ });
14908
+ continue;
14909
+ }
14910
+ next = candidate;
14911
+ report.converted.push(converted);
14912
+ }
14913
+ }
14914
+ };
14915
+ /**
14916
+ * Why converting would change what the device claims. The link serves EVERY host
14917
+ * field of the cap (and the clock as `now`): a set that covers fewer would newly
14918
+ * take the rest from the source, and an enabled feature another writer left on
14919
+ * the cap would overlap the link. The operator decides per device.
14920
+ */
14921
+ function widening(served, carried, next, candidates) {
14922
+ const reasons = [];
14923
+ const missing = served.filter((path) => !carried.includes(path));
14924
+ if (missing.length > 0) reasons.push(`partial-set: would also take ${missing.join(", ")}`);
14925
+ const taken = new Set(candidates);
14926
+ for (const other of next.features) {
14927
+ if (other.kind !== "fields" || taken.has(other) || !compositionFeatureEnabled(other)) continue;
14928
+ const clash = Object.keys(other.fields).filter((path) => served.includes(path));
14929
+ if (clash.length > 0) {
14930
+ const by = other.contributedBy === void 0 ? "another feature" : `the device link ${other.contributedBy.linkId}`;
14931
+ reasons.push(`overlap: ${by} also writes ${clash.join(", ")}, which the link would serve`);
14932
+ }
14933
+ }
14934
+ return reasons;
14935
+ }
14936
+ function goneKey(deviceId, feature) {
14937
+ return `${deviceId}:${feature.cap}:${feature.linkId}`;
14938
+ }
14939
+ /**
14940
+ * The features are ONE link when every field is a plain read of the SAME source
14941
+ * device's `sourceCap`, at the path the link maps it to (the same path without a
14942
+ * map), plus the `now` clock. Anything else is named, per field.
14943
+ */
14944
+ function identityGroup(features, sourceCap, map) {
14945
+ const reasons = [];
14946
+ const sources = /* @__PURE__ */ new Map();
14947
+ const fields = [];
14948
+ for (const feature of features) {
14949
+ for (const [path, value] of Object.entries(feature.fields)) {
14950
+ fields.push(path);
14951
+ if (value.kind === "expression" && value.expr === "now" && path === "lastFetchedAt") continue;
14952
+ if (path === "lastFetchedAt") {
14953
+ reasons.push("lastFetchedAt: reads the source clock, the link writes now");
14954
+ continue;
14955
+ }
14956
+ if (value.kind !== "from") {
14957
+ reasons.push(`${path}: a ${value.kind} source`);
14958
+ continue;
14959
+ }
14960
+ if (value.cap !== sourceCap) reasons.push(`${path}: reads ${value.cap}, not ${sourceCap}`);
14961
+ else if (value.fieldPath !== (map?.[path] ?? path)) reasons.push(`${path}: reads ${value.fieldPath}, not the same path`);
14962
+ sources.set(compositionSourceKey(value.source), value.source);
14963
+ }
14964
+ for (const extra of ["items", "commands"]) if (feature[extra] !== void 0) reasons.push(`the feature carries ${extra}`);
14965
+ }
14966
+ const [first] = [...sources.values()];
14967
+ if (sources.size > 1) reasons.push(`${sources.size} different source devices`);
14968
+ if (first === void 0 && reasons.length === 0) reasons.push("no source device");
14969
+ return reasons.length > 0 || first === void 0 ? { reasons } : {
14970
+ source: first,
14971
+ fields
14972
+ };
14973
+ }
14974
+ //#endregion
14748
14975
  //#region src/builtins/core-blocks/hero-layout-service.ts
14749
14976
  /**
14750
14977
  * The `hero-layout` provider of core-blocks (D1023): serves the FIXED layouts
@@ -17275,7 +17502,8 @@ function replacedOf(stored, description, lookupCap) {
17275
17502
  return replacedFieldKeys(planComposition(stored.composition, lookupCap, description));
17276
17503
  }
17277
17504
  function peerOf(stored, targets, lookupCap, candidateBlockId) {
17278
- const { blockId, composition } = stored;
17505
+ const { blockId } = stored;
17506
+ const composition = expandCapLinks(stored.composition, (cap) => topLevelFieldsOf(cap, lookupCap));
17279
17507
  if (composition.target.kind === "new") return {
17280
17508
  peer: {
17281
17509
  blockId,
@@ -17286,7 +17514,10 @@ function peerOf(stored, targets, lookupCap, candidateBlockId) {
17286
17514
  };
17287
17515
  const device = composition.target.device;
17288
17516
  const key = compositionSourceKey(device);
17289
- const replaced = replacedOf(stored, targets.get(key), lookupCap);
17517
+ const replaced = replacedOf({
17518
+ blockId,
17519
+ composition
17520
+ }, targets.get(key), lookupCap);
17290
17521
  if (!("error" in replaced)) return {
17291
17522
  peer: {
17292
17523
  blockId,
@@ -19521,8 +19752,51 @@ var CoreBlocksAddon = class extends BaseAddon {
19521
19752
  })) };
19522
19753
  },
19523
19754
  ...this.requireActions().runsApi,
19524
- ...this.sharedCompositionApi()
19755
+ ...this.sharedCompositionApi(),
19756
+ getCapLinks: async ({ deviceId }) => this.sharedCapLinks().read(deviceId),
19757
+ migrateCapLinks: async ({ dryRun }) => this.sharedCapLinks().migrate(dryRun)
19758
+ };
19759
+ }
19760
+ capLinks = null;
19761
+ /** Whole-capability links (D1076): the read and the one-off migration, over `ctx.api`. */
19762
+ sharedCapLinks() {
19763
+ this.capLinks ??= this.buildCapLinks();
19764
+ return this.capLinks;
19765
+ }
19766
+ buildCapLinks() {
19767
+ const requireApi = () => {
19768
+ const api = this.ctx.api;
19769
+ if (!api) throw new Error("core-blocks: no ctx.api on this node — cap links cannot be read");
19770
+ return api;
19525
19771
  };
19772
+ const store = this.requireStore();
19773
+ const compositions = this.sharedCompositionApi();
19774
+ const lookupCap = buildCapabilityLookup(ALL_CAPABILITY_DEFINITIONS);
19775
+ return new CapLinksService({
19776
+ blocks: () => store.isLoaded() ? store.list() : null,
19777
+ refOfDevice: async (deviceId) => {
19778
+ const found = await requireApi().deviceManager.getDevice.query({ deviceId });
19779
+ return found === null ? null : {
19780
+ addonId: found.addonId,
19781
+ stableId: found.stableId
19782
+ };
19783
+ },
19784
+ deviceIdOf: (ref) => this.deviceIdOfRef(ref),
19785
+ hostFieldsOf: (cap) => topLevelFieldsOf(cap, lookupCap),
19786
+ rewrite: async (block, composition) => {
19787
+ const { block: updated } = await compositions.updateComposition({
19788
+ blockId: block.id,
19789
+ expectedUpdatedAt: block.updatedAt,
19790
+ block: { composition },
19791
+ caller: {
19792
+ userId: "cap-links-migration",
19793
+ isAdmin: true
19794
+ }
19795
+ });
19796
+ return updated;
19797
+ },
19798
+ logger: this.ctx.logger.child("cap-links")
19799
+ });
19526
19800
  }
19527
19801
  sharedCompositionApi() {
19528
19802
  this.compositionApi ??= this.buildCompositionApi();
@@ -6,7 +6,7 @@ const require_chunk = require("../../chunk-Cek0wNdY.js");
6
6
  const require_stream_catalog_cap = require("../../stream-catalog.cap-D3uwePiA.js");
7
7
  const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
8
8
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
9
- const require_rename_composition_block = require("../../rename-composition-block-BJsL58Ih.js");
9
+ const require_rename_composition_block = require("../../rename-composition-block-BRgyBO25.js");
10
10
  const require_camstack_error = require("../../camstack-error-DJ-TUAi1.js");
11
11
  const require_capability_definition = require("../../capability-definition-HCmTem8c.js");
12
12
  const require_zod_secret = require("../../zod-secret-DS7mj1bk.js");
@@ -15,11 +15,11 @@ const require_device_identifiers = require("../../device-identifiers-BQg9EQi1.js
15
15
  const require_tag = require("../../tag-BxLazvVb.js");
16
16
  const require_device_type = require("../../device-type-CbQsnFdC.js");
17
17
  const require_device_kind = require("../../device-kind-CsSiv_YF.js");
18
- const require_core_blocks_cap = require("../../core-blocks.cap-BMeMCBrx.js");
18
+ const require_core_blocks_cap = require("../../core-blocks.cap-DlEuHq-S.js");
19
19
  const require_addon_settings_cap = require("../../addon-settings.cap-DAiE0Nb0.js");
20
- require("../../error.cap-DBhgPeWK.js");
20
+ require("../../error.cap-BCqzFlo2.js");
21
21
  const require_source_info = require("../../source-info-DtWf4k2j.js");
22
- const require_prefix_walk = require("../../prefix-walk-BkMxoXpL.js");
22
+ const require_prefix_walk = require("../../prefix-walk-DD1BM923.js");
23
23
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
24
24
  const require_log_redactor = require("../../log-redactor-BhIEMaG9.js");
25
25
  const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
@@ -2095,6 +2095,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
2095
2095
  access: "view",
2096
2096
  role: "admin"
2097
2097
  },
2098
+ "coreBlocks.getCapLinks": {
2099
+ capName: "core-blocks",
2100
+ capScope: "system",
2101
+ addonId: null,
2102
+ access: "view",
2103
+ role: "admin"
2104
+ },
2098
2105
  "coreBlocks.getComposition": {
2099
2106
  capName: "core-blocks",
2100
2107
  capScope: "system",
@@ -2144,6 +2151,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
2144
2151
  access: "view",
2145
2152
  role: "admin"
2146
2153
  },
2154
+ "coreBlocks.migrateCapLinks": {
2155
+ capName: "core-blocks",
2156
+ capScope: "system",
2157
+ addonId: null,
2158
+ access: "create",
2159
+ role: "admin"
2160
+ },
2147
2161
  "coreBlocks.migrateRawSecrets": {
2148
2162
  capName: "core-blocks",
2149
2163
  capScope: "system",
@@ -1,7 +1,7 @@
1
1
  import { T as deviceStatusCapability, w as DeviceStatusSchema } from "../../stream-catalog.cap-Bp7SkgIf.mjs";
2
2
  import { b as EventCategory$1, g as WELL_KNOWN_TAB_MAP, n as secretTreeFromPaths, o as resolveSecretMarkers, s as transformSecretWrite, t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
3
3
  import { B as SECRET_CLEAR, G as isSecretMarkerLike, H as isSecretClear, W as isSecretMarker, X as isKeychainStoredField, Z as errMsg$1, q as toSecretFieldView } from "../../scoped-settings-DVWUIP7Z.mjs";
4
- import { Jn as ExportNameRefusedError, _n as deviceStateCapability, b as workloadTransition, c as kebabToCamel, fn as PUSH_CONFIRM_WINDOW_MS, g as WorkloadStateSchema, gn as FieldClaimSchema, h as WORKLOAD_TRANSITION_CATEGORY, hn as FieldClaimModeSchema, m as ALL_CAPABILITY_DEFINITIONS, mn as effectiveRefreshIntervalMs, n as renameCompositionBlock, pn as commandBurstOffsets, t as composedBlockIdOf, v as isWorkloadSettled, vn as deviceExtensionCapability, y as workloadCapability, yn as EXTENSION_SLOTS } from "../../rename-composition-block-OAtErZgq.mjs";
4
+ import { Jn as ExportNameRefusedError, _n as deviceStateCapability, b as workloadTransition, c as kebabToCamel, fn as PUSH_CONFIRM_WINDOW_MS, g as WorkloadStateSchema, gn as FieldClaimSchema, h as WORKLOAD_TRANSITION_CATEGORY, hn as FieldClaimModeSchema, m as ALL_CAPABILITY_DEFINITIONS, mn as effectiveRefreshIntervalMs, n as renameCompositionBlock, pn as commandBurstOffsets, t as composedBlockIdOf, v as isWorkloadSettled, vn as deviceExtensionCapability, y as workloadCapability, yn as EXTENSION_SLOTS } from "../../rename-composition-block-BYRBlx-V.mjs";
5
5
  import { t as userError } from "../../camstack-error-viZYfcj9.mjs";
6
6
  import { a as expandCapMethods$1, s as isDeviceConfigCap } from "../../capability-definition-C2rJdVeX.mjs";
7
7
  import { t as collectZodSecretPaths$1 } from "../../zod-secret-zY4nM61M.mjs";
@@ -10,11 +10,11 @@ import { a as isEmptyIdentifiers, c as sameIdentifiers, i as identifierStrength,
10
10
  import { d as canonicalIconKey, o as normalizeTags } from "../../tag-uZBAq6ox.mjs";
11
11
  import { n as DeviceRole, r as DeviceType$1, t as DeviceFeature } from "../../device-type-DgEvK3ch.mjs";
12
12
  import { n as capAppliesToDeviceKind } from "../../device-kind-BJ2pfsjw.mjs";
13
- import { A as CAP_RUNTIME_FIELD_UNITS, Kt as enumerateItemArrayFields, cn as allVocabActions, dn as vocabActionIdFor, pn as CAP_VOCABULARY_BY_NAME, qt as enumerateSchemaFields, sn as actionEffect, un as findVocabAction } from "../../core-blocks.cap-BRPsLAij.mjs";
13
+ import { $ as CAP_RUNTIME_FIELD_UNITS, Qt as enumerateSchemaFields, Zt as enumerateItemArrayFields, fn as actionEffect, gn as vocabActionIdFor, hn as findVocabAction, pn as allVocabActions, vn as CAP_VOCABULARY_BY_NAME } from "../../core-blocks.cap-CnwBuf7E.mjs";
14
14
  import { u as locationIconKey } from "../../addon-settings.cap-3-TIIMq_.mjs";
15
- import "../../error.cap-CSM_SRfR.mjs";
15
+ import "../../error.cap-5zNPAgU2.mjs";
16
16
  import { a as normalizeUnit, r as extractSourceInfoFromMetadata } from "../../source-info-DGB7SdB_.mjs";
17
- import { r as ConditionMirror, t as loadPrefixed } from "../../prefix-walk-ifwg_ukx.mjs";
17
+ import { r as ConditionMirror, t as loadPrefixed } from "../../prefix-walk-CRnbYJcC.mjs";
18
18
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
19
19
  import { a as redactLogText, i as redactLogMeta, n as isSecretArgumentKey } from "../../log-redactor-XLDrPzOi.mjs";
20
20
  import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
@@ -2089,6 +2089,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
2089
2089
  access: "view",
2090
2090
  role: "admin"
2091
2091
  },
2092
+ "coreBlocks.getCapLinks": {
2093
+ capName: "core-blocks",
2094
+ capScope: "system",
2095
+ addonId: null,
2096
+ access: "view",
2097
+ role: "admin"
2098
+ },
2092
2099
  "coreBlocks.getComposition": {
2093
2100
  capName: "core-blocks",
2094
2101
  capScope: "system",
@@ -2138,6 +2145,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
2138
2145
  access: "view",
2139
2146
  role: "admin"
2140
2147
  },
2148
+ "coreBlocks.migrateCapLinks": {
2149
+ capName: "core-blocks",
2150
+ capScope: "system",
2151
+ addonId: null,
2152
+ access: "create",
2153
+ role: "admin"
2154
+ },
2141
2155
  "coreBlocks.migrateRawSecrets": {
2142
2156
  capName: "core-blocks",
2143
2157
  capScope: "system",
@@ -13,7 +13,7 @@ import { z } from "zod";
13
13
  import * as crypto$1 from "node:crypto";
14
14
  import { X509Certificate, createHash, randomUUID, timingSafeEqual } from "node:crypto";
15
15
  import nodeCrypto from "crypto";
16
- import * as fs from "node:fs";
16
+ import * as fs$1 from "node:fs";
17
17
  import * as path$1 from "node:path";
18
18
  //#region ../types/dist/esm/interfaces/addon-data-plane.mjs
19
19
  /**
@@ -12025,8 +12025,8 @@ var LocalAuthAddon = class extends BaseAddon {
12025
12025
  users: this.userManager,
12026
12026
  dataDir: this.ctx.nodeDataDir,
12027
12027
  fs: {
12028
- exists: (filePath) => fs.existsSync(filePath),
12029
- remove: (filePath) => fs.rmSync(filePath, { force: true })
12028
+ exists: (filePath) => fs$1.existsSync(filePath),
12029
+ remove: (filePath) => fs$1.rmSync(filePath, { force: true })
12030
12030
  },
12031
12031
  logger: this.ctx.logger
12032
12032
  });
@@ -4,8 +4,8 @@ import { u as preconditionOf } from "../../migration-DRJAtdy7.mjs";
4
4
  import { c as checkRoleAddress, d as resolveHubAddressRoles, f as resolveNotificationTapAddress, g as pickAppLinkHub, h as isAppLinkBase, l as isDefaultAppConnectionEndpoint, m as CAMSTACK_APP_LINK_ORIGIN, o as HUB_MDNS_SERVICE_TYPE, p as validateCustomAddress, r as localNetworkCapability, s as HUB_MDNS_TXT_KEYS, t as NetworkTunnelStartedDataSchema, u as resolveAppConnections } from "../../network-access.cap-BJnGbE6n.mjs";
5
5
  import { r as shortHostname } from "../../server-name-BIhLuHvX.mjs";
6
6
  import { a as emptyMdnsRecords, c as parseMdnsMessage, i as buildRecordQuery, l as parseMdnsRecords, n as MDNS_PORT, o as mergeMdnsRecords, r as buildPtrQuery, s as normalizeServiceType, t as MDNS_GROUP } from "../../dns-wire-Dm3H_7ST.mjs";
7
- import { i as loadOrCreateHubId, r as isAnnouncedHubId } from "../../hub-identity-_IOgPJ00.mjs";
8
- import { E as ensureTlsCert, I as readLanHttpState, N as applyLanHttp, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, d as servedHttpsLeafFingerprint, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, r as regenerateCertificate, t as createCiaoPublisher, y as writeExtraSans } from "../../hub-mdns-ciao-Dk7ts_Uk.mjs";
7
+ import { i as loadOrCreateHubId, r as isAnnouncedHubId } from "../../hub-identity-DjMN9Ac2.mjs";
8
+ import { E as ensureTlsCert, I as readLanHttpState, N as applyLanHttp, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, d as servedHttpsLeafFingerprint, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, r as regenerateCertificate, t as createCiaoPublisher, y as writeExtraSans } from "../../hub-mdns-ciao-DBrtHOcc.mjs";
9
9
  import { z } from "zod";
10
10
  import { isIP } from "node:net";
11
11
  import { readFileSync } from "node:fs";
@@ -1,7 +1,7 @@
1
1
  import { b as EventCategory, p as createEvent, t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
2
2
  import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
3
3
  import { t as metricsProviderCapability } from "../../metrics-provider.cap-BNmcHDkQ.mjs";
4
- import * as fs from "node:fs";
4
+ import * as fs$1 from "node:fs";
5
5
  import { constants, readFileSync } from "node:fs";
6
6
  import { access, readFile, readdir } from "node:fs/promises";
7
7
  import { promisify } from "node:util";
@@ -1827,7 +1827,7 @@ var NativeMetricsProvider = class {
1827
1827
  let swapUsedBytes = 0;
1828
1828
  let swapTotalBytes = 0;
1829
1829
  if (IS_LINUX) try {
1830
- const meminfo = fs.readFileSync("/proc/meminfo", "utf-8");
1830
+ const meminfo = fs$1.readFileSync("/proc/meminfo", "utf-8");
1831
1831
  const availKb = meminfo.match(/MemAvailable:\s+(\d+)/)?.[1];
1832
1832
  if (availKb !== void 0) available = parseInt(availKb, 10) * 1024;
1833
1833
  const swapTotal = parseInt(meminfo.match(/SwapTotal:\s+(\d+)/)?.[1] ?? "0", 10) * 1024;
@@ -1920,7 +1920,7 @@ async function sampleMacMemory(provider) {
1920
1920
  }
1921
1921
  function getDiskSpaceInternal(dirPath) {
1922
1922
  return new Promise((resolve, reject) => {
1923
- fs.statfs(dirPath, (err, stats) => {
1923
+ fs$1.statfs(dirPath, (err, stats) => {
1924
1924
  if (err) return reject(err);
1925
1925
  const totalBytes = stats.blocks * stats.bsize;
1926
1926
  const availableBytes = stats.bavail * stats.bsize;
@@ -1938,7 +1938,7 @@ function getDiskSpaceInternal(dirPath) {
1938
1938
  async function takeDiskIoSnapshot() {
1939
1939
  const now = Date.now();
1940
1940
  if (IS_LINUX) try {
1941
- const data = fs.readFileSync("/proc/diskstats", "utf-8");
1941
+ const data = fs$1.readFileSync("/proc/diskstats", "utf-8");
1942
1942
  let readOps = 0, readBytes = 0, writeOps = 0, writeBytes = 0;
1943
1943
  for (const line of data.split("\n")) {
1944
1944
  const parts = line.trim().split(/\s+/);
@@ -1969,7 +1969,7 @@ async function takeDiskIoSnapshot() {
1969
1969
  async function takeNetworkIoSnapshot() {
1970
1970
  const now = Date.now();
1971
1971
  if (IS_LINUX) try {
1972
- const data = fs.readFileSync("/proc/net/dev", "utf-8");
1972
+ const data = fs$1.readFileSync("/proc/net/dev", "utf-8");
1973
1973
  let rxBytes = 0, txBytes = 0, rxPackets = 0, txPackets = 0, rxErrors = 0, txErrors = 0;
1974
1974
  for (const line of data.split("\n")) {
1975
1975
  const match = line.match(/^\s*(\w+):\s+(.+)$/);
@@ -2030,7 +2030,7 @@ async function takeNetworkIoSnapshot() {
2030
2030
  }
2031
2031
  async function getCpuTemperatureInternal() {
2032
2032
  if (IS_LINUX) for (const p of ["/sys/class/thermal/thermal_zone0/temp", "/sys/class/hwmon/hwmon0/temp1_input"]) try {
2033
- const raw = fs.readFileSync(p, "utf-8").trim();
2033
+ const raw = fs$1.readFileSync(p, "utf-8").trim();
2034
2034
  const millideg = parseInt(raw, 10);
2035
2035
  if (!isNaN(millideg)) return Math.round(millideg / 100) / 10;
2036
2036
  } catch {
@@ -2081,10 +2081,10 @@ function getProcessResources() {
2081
2081
  let threadCount = 0;
2082
2082
  if (IS_LINUX) {
2083
2083
  try {
2084
- openFds = fs.readdirSync(`/proc/${process.pid}/fd`).length;
2084
+ openFds = fs$1.readdirSync(`/proc/${process.pid}/fd`).length;
2085
2085
  } catch {}
2086
2086
  try {
2087
- const match = fs.readFileSync(`/proc/${process.pid}/status`, "utf-8").match(/Threads:\s+(\d+)/);
2087
+ const match = fs$1.readFileSync(`/proc/${process.pid}/status`, "utf-8").match(/Threads:\s+(\d+)/);
2088
2088
  if (match) threadCount = parseInt(match[1], 10);
2089
2089
  } catch {}
2090
2090
  }
@@ -2099,7 +2099,7 @@ function getProcessResources() {
2099
2099
  function getPressure(resource) {
2100
2100
  if (!IS_LINUX) return null;
2101
2101
  try {
2102
- const data = fs.readFileSync(`/proc/pressure/${resource}`, "utf-8");
2102
+ const data = fs$1.readFileSync(`/proc/pressure/${resource}`, "utf-8");
2103
2103
  const parseLine = (prefix) => {
2104
2104
  const match = data.match(new RegExp(`${prefix} avg10=(\\d+\\.\\d+) avg60=(\\d+\\.\\d+) avg300=(\\d+\\.\\d+)`));
2105
2105
  if (!match) return null;
@@ -2,8 +2,8 @@ import { o as __toESM, r as __exportAll } from "../../chunk-CNf5ZN-e.mjs";
2
2
  import { b as EventCategory, m as emitReadiness, t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
3
3
  import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
4
4
  import { n as parseAcceleratorFactsJson, t as platformProbeCapability } from "../../platform-probe.cap-BFeqFLtQ.mjs";
5
- import { a as enumerateInferenceDevices, i as describeNvidia, n as detectCoralAccelerator, o as scoreRuntimes, r as nodeCoralFs } from "../../coral-accelerators-zTMTEd-8.mjs";
6
- import * as fs from "node:fs";
5
+ import { a as enumerateInferenceDevices, i as describeNvidia, n as detectCoralAccelerator, o as scoreRuntimes, r as nodeCoralFs } from "../../coral-accelerators-BKcXP59c.mjs";
6
+ import * as fs$1 from "node:fs";
7
7
  import * as path$1 from "node:path";
8
8
  import { promisify } from "node:util";
9
9
  import * as os$1 from "node:os";
@@ -503,14 +503,14 @@ var PlatformScorer = class {
503
503
  nvidiaProbe = await this.probeNvidiaSmi();
504
504
  const listRenderNodes = () => {
505
505
  try {
506
- return fs.readdirSync("/dev/dri").filter((n) => n.startsWith("renderD")).map((n) => `/dev/dri/${n}`);
506
+ return fs$1.readdirSync("/dev/dri").filter((n) => n.startsWith("renderD")).map((n) => `/dev/dri/${n}`);
507
507
  } catch {
508
508
  return [];
509
509
  }
510
510
  };
511
511
  const readDrmAttr = (node, attr) => {
512
512
  try {
513
- return fs.readFileSync(`/sys/class/drm/${node.split("/").pop()}/device/${attr}`, "utf8");
513
+ return fs$1.readFileSync(`/sys/class/drm/${node.split("/").pop()}/device/${attr}`, "utf8");
514
514
  } catch {
515
515
  return "";
516
516
  }
@@ -536,12 +536,12 @@ var PlatformScorer = class {
536
536
  }
537
537
  const listDir = (p) => {
538
538
  try {
539
- return fs.readdirSync(p);
539
+ return fs$1.readdirSync(p);
540
540
  } catch {
541
541
  return [];
542
542
  }
543
543
  };
544
- const exists = (p) => fs.existsSync(p);
544
+ const exists = (p) => fs$1.existsSync(p);
545
545
  if (!npu) {
546
546
  const { classifyIntelNpu } = await import("../../intel-npu-C8HKvRQF.mjs");
547
547
  npu = classifyIntelNpu({
@@ -569,7 +569,7 @@ var PlatformScorer = class {
569
569
  exists,
570
570
  readFile: (p) => {
571
571
  try {
572
- return fs.readFileSync(p, "utf8");
572
+ return fs$1.readFileSync(p, "utf8");
573
573
  } catch {
574
574
  return "";
575
575
  }
@@ -873,7 +873,7 @@ function jsonValue(text) {
873
873
  function readPublishedAcceleratorFacts(filePath) {
874
874
  let text;
875
875
  try {
876
- text = fs.readFileSync(filePath, "utf8");
876
+ text = fs$1.readFileSync(filePath, "utf8");
877
877
  } catch {
878
878
  return null;
879
879
  }
@@ -888,7 +888,7 @@ function findAcceleratorFactsScript(dataDir, cwd = process.cwd()) {
888
888
  const candidates = [];
889
889
  if (typeof dataDir === "string" && dataDir !== "") candidates.push(path$1.join(dataDir, "addons", "@camstack", "addon-pipeline", "python", "accelerator_facts.py"));
890
890
  candidates.push(path$1.join(cwd, "packages", "addon-pipeline", "python", "accelerator_facts.py"));
891
- for (const candidate of candidates) if (fs.existsSync(candidate)) return candidate;
891
+ for (const candidate of candidates) if (fs$1.existsSync(candidate)) return candidate;
892
892
  return null;
893
893
  }
894
894
  async function defaultExec(command, args, timeoutMs) {