@camstack/server 1.2.731 → 1.2.733

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 (104) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/api/core/cap-providers.js +1 -0
  3. package/dist/api/core/logging-settings.js +88 -1
  4. package/dist/api/trpc/generated-cap-routers.js +49 -0
  5. package/dist/core/addon/addon-registry.service.js +61 -59
  6. package/package.json +11 -19
  7. package/system/dist/addon-runner.js +1 -0
  8. package/system/dist/addon-runner.mjs +2 -1
  9. package/system/dist/addon-utils.mjs +1 -1
  10. package/system/dist/{agent-https-AJPmB73W.mjs → agent-https-D3dptveB.mjs} +1 -1
  11. package/system/dist/{agent-https-CLJhq0GZ.js → agent-https-v5uyVgpk.js} +1 -1
  12. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  13. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
  14. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  15. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
  16. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  17. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  18. package/system/dist/builtins/autotrack/index.js +1 -1
  19. package/system/dist/builtins/autotrack/index.mjs +1 -1
  20. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  21. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
  22. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  23. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  24. package/system/dist/builtins/camera-grid/index.js +1 -1
  25. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  26. package/system/dist/builtins/composer/composer.addon.js +3 -3
  27. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  28. package/system/dist/builtins/console-logging/index.js +1 -1
  29. package/system/dist/builtins/console-logging/index.mjs +1 -1
  30. package/system/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  31. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  32. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  33. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  34. package/system/dist/builtins/device-manager/device-manager.addon.js +220 -16
  35. package/system/dist/builtins/device-manager/device-manager.addon.mjs +220 -16
  36. package/system/dist/builtins/device-manager/discovery-proposal-service.d.ts +38 -0
  37. package/system/dist/builtins/device-manager/discovery-proposal-store.d.ts +28 -0
  38. package/system/dist/builtins/device-manager/record-kinds.d.ts +2 -1
  39. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  40. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  41. package/system/dist/builtins/keychain/index.js +3 -3
  42. package/system/dist/builtins/keychain/index.mjs +3 -3
  43. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  44. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  45. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  46. package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
  47. package/system/dist/builtins/local-network/local-network.addon.d.ts +10 -0
  48. package/system/dist/builtins/local-network/local-network.addon.js +297 -190
  49. package/system/dist/builtins/local-network/local-network.addon.mjs +294 -187
  50. package/system/dist/builtins/local-network/passive/discovery-watcher.d.ts +60 -0
  51. package/system/dist/builtins/local-network/passive/passive-io-node.d.ts +2 -0
  52. package/system/dist/builtins/local-network/passive/passive-packets.d.ts +10 -0
  53. package/system/dist/builtins/local-network/scan/dns-wire.d.ts +6 -2
  54. package/system/dist/builtins/local-network/scan/scan-engine.d.ts +1 -1
  55. package/system/dist/builtins/local-network/scan/scan-io.d.ts +6 -0
  56. package/system/dist/builtins/loki-logging/index.js +1 -1
  57. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  58. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  59. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
  60. package/system/dist/builtins/platform-probe/index.js +1 -1
  61. package/system/dist/builtins/platform-probe/index.mjs +10 -10
  62. package/system/dist/builtins/record-entries/index.js +1 -1
  63. package/system/dist/builtins/record-entries/index.mjs +1 -1
  64. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  65. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  66. package/system/dist/builtins/snapshot/index.js +1 -1
  67. package/system/dist/builtins/snapshot/index.mjs +1 -1
  68. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  69. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
  70. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  71. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  72. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
  73. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
  74. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  75. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  76. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  77. package/system/dist/builtins/system-config/system-config.addon.mjs +115 -115
  78. package/system/dist/builtins/winston-logging/index.js +1 -1
  79. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  80. package/system/dist/{composition-sources-D-S2hhdw.mjs → composition-sources-Dnyu7-1p.mjs} +1 -1
  81. package/system/dist/{composition-sources-BNBlJAgu.js → composition-sources-j_bFq7Tx.js} +1 -1
  82. package/system/dist/{constants-CKwdQTnw.js → constants-C6zJ_38f.js} +1 -1
  83. package/system/dist/{constants-DmithOex.mjs → constants-GDBin8zB.mjs} +1 -1
  84. package/system/dist/{coral-accelerators-BW3OcrLD.mjs → coral-accelerators-DBlgWB8k.mjs} +6 -6
  85. package/system/dist/{custom-action-registry-BIJZBObd.mjs → custom-action-registry-oHl1xltx.mjs} +37 -37
  86. package/system/dist/{device-ca-D-Cvxobt.mjs → device-ca-Bpqrad00.mjs} +1 -1
  87. package/system/dist/{device-ca-TbdQfW4d.js → device-ca-CV9QZvoy.js} +1 -1
  88. package/system/dist/{dist-dQKZfa3-.js → dist-CwYYyGAB.js} +227 -3
  89. package/system/dist/{dist-yrk6fm65.mjs → dist-DcHvuBfD.mjs} +210 -4
  90. package/system/dist/dns-wire-CqgMi_uB.js +202 -0
  91. package/system/dist/dns-wire-DO56tOHL.mjs +173 -0
  92. package/system/dist/file-host-worker.js +1 -1
  93. package/system/dist/file-host-worker.mjs +1 -1
  94. package/system/dist/{hub-mdns-ciao-Cae5VWUc.mjs → hub-mdns-ciao-D2sU6sKd.mjs} +2 -2
  95. package/system/dist/{hub-mdns-ciao-DP3_GNZw.js → hub-mdns-ciao-DNLnbJNG.js} +2 -2
  96. package/system/dist/index.js +24 -7
  97. package/system/dist/index.mjs +236 -219
  98. package/system/dist/{restore-archive-BJ5gxMvf.mjs → restore-archive-BGK6EnYj.mjs} +94 -94
  99. package/system/dist/{restore-archive-X9c_wEBY.js → restore-archive-xTqhDFkW.js} +1 -1
  100. package/system/dist/{retention-DBrdAv12.mjs → retention-CXu8PB2L.mjs} +1 -1
  101. package/system/dist/{retention-DRT2wUyB.js → retention-gQ3GIUA3.js} +1 -1
  102. package/system/dist/{wal-maintenance-Bi4yImEY.mjs → wal-maintenance-D7XmFaUD.mjs} +0 -0
  103. package/system/dist/{wal-maintenance-hsgNGrjh.js → wal-maintenance-Hwzm3DCe.js} +0 -0
  104. package/system/package.json +1 -1
@@ -1,8 +1,9 @@
1
- import { $o as collectZodSecretPaths, As as resolveSecretMarkers, Bn as createDeviceExtensionProvider, Bs as DeviceFeature, Cn as canonicalIconKey, F as DAY_NAMES, Hs as DeviceType, Is as toSecretFieldView, J as DeviceStatusSchema, Ji as runtimeStatePolicyFor, Jn as defineExtensionSlotProvider, Kr as locationIconKey, Ls as transformSecretWrite, Ms as secretTreeFromPaths, Ps as sleep$1, Qn as deviceExtensionCapability, Ro as SECRET_CLEAR, Rs as userError, Rt as STREAM_PROFILE_META, Uo as WELL_KNOWN_TAB_MAP, Us as errMsg, Vr as legacyAutoLinkIds, Vs as DeviceRole, Ws as EventCategory, Y as DeviceTombstoneSchema, _s as isSecretMarkerLike, aa as siteZoneKey, at as FieldClaimSchema, bn as buildStreamParamsConfigSchema, bt as MINUTES_PER_DAY, dr as expandContainer, ds as isDeviceConfigCap, er as deviceManagerCapability, fi as normalizeUnit, g as CAMERA_SWITCH_ORDER, gs as isSecretMarker, hs as isSecretClear, ir as deviceStatusCapability, it as FieldClaimModeSchema, o as ALL_CAPABILITY_DEFINITIONS, or as enumerateItemArrayFields, ps as isKeychainStoredField, rr as deviceStateCapability, rs as defineRecordKinds, sr as enumerateSchemaFields, uo as BaseAddon, v as CAP_NAMES_WITH_STATUS, xr as formatMinutes, yi as parseStreamParamsFormPatch } from "../../dist-yrk6fm65.mjs";
1
+ import { $n as deviceExtensionCapability, Bs as transformSecretWrite, F as DAY_NAMES, Fs as secretTreeFromPaths, Gs as DeviceType, Hr as legacyAutoLinkIds, J as DeviceStatusSchema, Ks as errMsg, Ls as sleep$1, Ns as resolveSecretMarkers, Sr as formatMinutes, Us as DeviceFeature, Vn as createDeviceExtensionProvider, Vs as userError, Wo as WELL_KNOWN_TAB_MAP, Ws as DeviceRole, X as DiscoveryProposalBodySchema, Y as DeviceTombstoneSchema, Yi as runtimeStatePolicyFor, Yn as defineExtensionSlotProvider, ar as deviceStatusCapability, at as FieldClaimModeSchema, bi as parseStreamParamsFormPatch, bs as isSecretMarkerLike, cr as enumerateSchemaFields, do as BaseAddon, es as collectZodSecretPaths, fr as expandContainer, g as CAMERA_SWITCH_ORDER, gs as isKeychainStoredField, ir as deviceStateCapability, is as defineRecordKinds, ms as isDeviceConfigCap, o as ALL_CAPABILITY_DEFINITIONS, oa as siteZoneKey, ot as FieldClaimSchema, pi as normalizeUnit, qr as locationIconKey, qs as EventCategory, sr as enumerateItemArrayFields, tr as deviceManagerCapability, v as CAP_NAMES_WITH_STATUS, vs as isSecretClear, wn as canonicalIconKey, xn as buildStreamParamsConfigSchema, xt as MINUTES_PER_DAY, ys as isSecretMarker, zo as SECRET_CLEAR, zs as toSecretFieldView, zt as STREAM_PROFILE_META } from "../../dist-DcHvuBfD.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
3
  import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
4
4
  import { t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
5
5
  import { n as purgeRetiredSettingsRows } from "../../retired-settings-keys-u6xQA6r7.mjs";
6
+ import { i as normalizeServiceType } from "../../dns-wire-DO56tOHL.mjs";
6
7
  import { z } from "zod";
7
8
  import { randomUUID } from "node:crypto";
8
9
  import { canonicalDeviceFingerprint } from "@camstack/types/node";
@@ -8021,21 +8022,38 @@ var DeviceMetaStore = class {
8021
8022
  //#endregion
8022
8023
  //#region src/builtins/device-manager/record-kinds.ts
8023
8024
  var import_read_all_rows = require_read_all_rows();
8024
- var _deviceManagerRecordKinds = defineRecordKinds({ tombstones: {
8025
- schema: DeviceTombstoneSchema.omit({ deviceId: true }),
8026
- class: "ledger",
8027
- writeTrigger: "`removeDevice` records one row per deleted device after the device row is gone; re-record keeps the earlier `deletedAt`",
8028
- device: "none",
8029
- at: "required",
8030
- indexes: [{
8031
- name: "deleted_at",
8032
- fields: ["deletedAt"]
8033
- }],
8034
- retention: {
8035
- owner: "device-manager",
8036
- reason: "90 days (`DEVICE_TOMBSTONE_RETENTION_MS`), pruned whenever a tombstone is written or the list is read"
8037
- }
8038
- } });
8025
+ var _deviceManagerRecordKinds = defineRecordKinds({
8026
+ tombstones: {
8027
+ schema: DeviceTombstoneSchema.omit({ deviceId: true }),
8028
+ class: "ledger",
8029
+ writeTrigger: "`removeDevice` records one row per deleted device after the device row is gone; re-record keeps the earlier `deletedAt`",
8030
+ device: "none",
8031
+ at: "required",
8032
+ indexes: [{
8033
+ name: "deleted_at",
8034
+ fields: ["deletedAt"]
8035
+ }],
8036
+ retention: {
8037
+ owner: "device-manager",
8038
+ reason: "90 days (`DEVICE_TOMBSTONE_RETENTION_MS`), pruned whenever a tombstone is written or the list is read"
8039
+ }
8040
+ },
8041
+ "discovery-proposals": {
8042
+ schema: DiscoveryProposalBodySchema,
8043
+ class: "config",
8044
+ writeTrigger: "the passive listener and the 30-minute sweep of `local-network` re-see a device (`lastSeenAt` and `at` move); `dismissDiscoveryProposal` sets `dismissed`",
8045
+ device: "none",
8046
+ at: "required",
8047
+ indexes: [{
8048
+ name: "last_seen_at",
8049
+ fields: ["lastSeenAt"]
8050
+ }],
8051
+ retention: {
8052
+ ttlMs: 2160 * 60 * 60 * 1e3,
8053
+ from: "at"
8054
+ }
8055
+ }
8056
+ });
8039
8057
  var deviceManagerRecordKinds = _deviceManagerRecordKinds;
8040
8058
  _deviceManagerRecordKinds.tombstones;
8041
8059
  //#endregion
@@ -8115,6 +8133,177 @@ var DeviceTombstoneStore = class DeviceTombstoneStore {
8115
8133
  }
8116
8134
  };
8117
8135
  //#endregion
8136
+ //#region src/builtins/device-manager/discovery-proposal-service.ts
8137
+ /**
8138
+ * Where the two discovery feeds meet (D994).
8139
+ *
8140
+ * - `runSweep`: the existing provider discovery (`discoverProviders`), run on
8141
+ * the schedule `local-network` keeps; every candidate becomes a proposal.
8142
+ * - `reportObservations`: what the passive listener heard. Each sighting is
8143
+ * matched against the discovery modes the providers DECLARE and handed to the
8144
+ * matching provider's `classifyDiscoveryHits`, exactly like a scan hit.
8145
+ *
8146
+ * Adoption is not here: a proposal is adopted through `adoptDevice` or the
8147
+ * integration setup form, the flows the scan modal already uses.
8148
+ */
8149
+ /** The hit a declared mode would have produced for this sighting, per matching mode. */
8150
+ function hitsForObservation(modes, observation) {
8151
+ const hits = [];
8152
+ modes.forEach((mode, modeIndex) => {
8153
+ if (observation.kind === "mdns" && mode.kind === "mdns") {
8154
+ if (normalizeServiceType(mode.serviceType) !== observation.serviceType) return;
8155
+ if (mode.instancePattern !== void 0 && !instanceMatches(mode.instancePattern, observation.instance)) return;
8156
+ hits.push({
8157
+ modeIndex,
8158
+ host: observation.address ?? observation.host,
8159
+ port: observation.port,
8160
+ mdns: {
8161
+ instance: observation.instance,
8162
+ host: observation.host,
8163
+ port: observation.port,
8164
+ txt: observation.txt
8165
+ }
8166
+ });
8167
+ } else if (observation.kind === "ssdp" && mode.kind === "ssdp") {
8168
+ if (mode.searchTarget.toLowerCase() !== observation.target.toLowerCase()) return;
8169
+ hits.push({
8170
+ modeIndex,
8171
+ host: observation.host,
8172
+ port: observation.port,
8173
+ http: {
8174
+ status: 200,
8175
+ headers: observation.headers,
8176
+ bodyText: ""
8177
+ }
8178
+ });
8179
+ }
8180
+ });
8181
+ return hits;
8182
+ }
8183
+ function instanceMatches(pattern, instance) {
8184
+ try {
8185
+ return new RegExp(pattern, "i").test(instance);
8186
+ } catch {
8187
+ return false;
8188
+ }
8189
+ }
8190
+ var DiscoveryProposalService = class {
8191
+ deps;
8192
+ constructor(deps) {
8193
+ this.deps = deps;
8194
+ }
8195
+ async runSweep() {
8196
+ const addonIds = await this.deps.providerIds();
8197
+ const outcomes = await discoverProviders(this.deps.orchestrator, { addonIds });
8198
+ let proposed = 0;
8199
+ for (const outcome of outcomes) {
8200
+ if (outcome.error !== null) continue;
8201
+ proposed += await this.deps.store.observe(outcome.addonId, outcome.candidates);
8202
+ }
8203
+ this.deps.logger.info("discovery sweep recorded", { meta: {
8204
+ providers: addonIds.length,
8205
+ proposed
8206
+ } });
8207
+ return {
8208
+ providers: addonIds.length,
8209
+ proposed
8210
+ };
8211
+ }
8212
+ async reportObservations(observations) {
8213
+ if (observations.length === 0) return { proposed: 0 };
8214
+ const addonIds = await this.deps.providerIds();
8215
+ let proposed = 0;
8216
+ for (const addonId of addonIds) try {
8217
+ const provider = await this.deps.requireProvider(addonId);
8218
+ const modes = await provider.getDiscoveryModes({});
8219
+ const hits = observations.flatMap((o) => hitsForObservation(modes, o));
8220
+ if (hits.length === 0) continue;
8221
+ const candidates = await provider.classifyDiscoveryHits({ hits });
8222
+ proposed += await this.deps.store.observe(addonId, candidates);
8223
+ } catch (err) {
8224
+ this.deps.logger.warn("passive discovery: provider could not classify", { meta: {
8225
+ addonId,
8226
+ error: errMsg(err)
8227
+ } });
8228
+ }
8229
+ return { proposed };
8230
+ }
8231
+ async list() {
8232
+ return this.deps.store.listVisible(await this.deps.ownership());
8233
+ }
8234
+ dismiss(id) {
8235
+ return this.deps.store.dismiss(id);
8236
+ }
8237
+ };
8238
+ //#endregion
8239
+ //#region src/builtins/device-manager/discovery-proposal-store.ts
8240
+ function proposalId(addonId, stableId) {
8241
+ return `${addonId}::${stableId}`;
8242
+ }
8243
+ var DiscoveryProposalStore = class DiscoveryProposalStore {
8244
+ kind;
8245
+ now;
8246
+ constructor(kind, now = () => Date.now()) {
8247
+ this.kind = kind;
8248
+ this.now = now;
8249
+ }
8250
+ static of(records, now) {
8251
+ return new DiscoveryProposalStore(records.kind(deviceManagerRecordKinds["discovery-proposals"]), now);
8252
+ }
8253
+ /** Record what a provider classified. Returns how many proposals are NEW. */
8254
+ async observe(addonId, candidates) {
8255
+ const at = this.now();
8256
+ let created = 0;
8257
+ for (const candidate of candidates) {
8258
+ if (candidate.alreadyOnboarded === true) continue;
8259
+ const id = proposalId(addonId, candidate.stableId);
8260
+ const existing = await this.kind.get(id);
8261
+ if (existing === null) created += 1;
8262
+ await this.kind.put({
8263
+ id,
8264
+ at,
8265
+ data: {
8266
+ addonId,
8267
+ candidate,
8268
+ firstSeenAt: existing?.data.firstSeenAt ?? at,
8269
+ lastSeenAt: at,
8270
+ dismissed: existing?.data.dismissed ?? false
8271
+ }
8272
+ });
8273
+ }
8274
+ return created;
8275
+ }
8276
+ /** Not dismissed, not already a device, not an integration the operator owns. */
8277
+ async listVisible(owned) {
8278
+ const rows = await (0, import_read_all_rows.readAllRows)(this.kind, { order: "at" });
8279
+ const out = [];
8280
+ for (const row of rows) {
8281
+ const { candidate, dismissed } = row.data;
8282
+ if (dismissed) continue;
8283
+ if (owned.deviceStableIds.has(candidate.stableId)) continue;
8284
+ if (owned.integrationOriginIds.has(candidate.stableId)) continue;
8285
+ out.push({
8286
+ id: row.id,
8287
+ ...row.data
8288
+ });
8289
+ }
8290
+ return out;
8291
+ }
8292
+ async dismiss(id) {
8293
+ const existing = await this.kind.get(id);
8294
+ if (existing === null) return false;
8295
+ await this.kind.put({
8296
+ id,
8297
+ at: existing.data.lastSeenAt,
8298
+ data: {
8299
+ ...existing.data,
8300
+ dismissed: true
8301
+ }
8302
+ });
8303
+ return true;
8304
+ }
8305
+ };
8306
+ //#endregion
8118
8307
  //#region src/builtins/device-manager/fleet-read-census.ts
8119
8308
  /** How many stack frames identify a call site. One frame is a method; three are
8120
8309
  * a cause — `listFleet < listAll < onDeviceRegistered` is the answer, `listAll`
@@ -11028,6 +11217,17 @@ var DeviceManagerAddon = class extends BaseAddon {
11028
11217
  if (records === void 0) throw new Error("[device-manager] ctx.records is required on the hub");
11029
11218
  await records.declare(deviceManagerRecordKinds);
11030
11219
  const tombstones = DeviceTombstoneStore.of(records, this.ctx.logger.child("tombstones"));
11220
+ const discoveryProposals = new DiscoveryProposalService({
11221
+ store: DiscoveryProposalStore.of(records),
11222
+ orchestrator: this.discoveryDeps(),
11223
+ providerIds: () => this.listDiscoveryCapableProviderIds(),
11224
+ requireProvider: (addonId) => this.requireDeviceProvider(addonId),
11225
+ ownership: async () => ({
11226
+ deviceStableIds: new Set((await deviceRows.listAll()).map((r) => r.meta.stableId)),
11227
+ integrationOriginIds: await this.discoveryDeps().originStableIds()
11228
+ }),
11229
+ logger: this.ctx.logger.child("discovery-proposals")
11230
+ });
11031
11231
  this.staleWrapperActivations.checkOnce(() => readBindingsStore(this.bindingsDeps));
11032
11232
  try {
11033
11233
  await purgeRetiredSettingsRows(deviceRows.retiredRowStore(), this.ctx.logger.child("RetiredRows"));
@@ -11207,6 +11407,10 @@ var DeviceManagerAddon = class extends BaseAddon {
11207
11407
  if (outcome?.error) throw new Error(outcome.error);
11208
11408
  return { candidates: outcome?.candidates ?? [] };
11209
11409
  },
11410
+ listDiscoveryProposals: async () => ({ proposals: await discoveryProposals.list() }),
11411
+ dismissDiscoveryProposal: async (input) => ({ dismissed: await discoveryProposals.dismiss(input.id) }),
11412
+ reportDiscoveryObservations: (input) => discoveryProposals.reportObservations(input.observations),
11413
+ runDiscoverySweep: () => discoveryProposals.runSweep(),
11210
11414
  providerCreationType: async (input) => {
11211
11415
  return (await this.requireDeviceProvider(input.addonId)).getManualCreationType({});
11212
11416
  },
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Where the two discovery feeds meet (D994).
3
+ *
4
+ * - `runSweep`: the existing provider discovery (`discoverProviders`), run on
5
+ * the schedule `local-network` keeps; every candidate becomes a proposal.
6
+ * - `reportObservations`: what the passive listener heard. Each sighting is
7
+ * matched against the discovery modes the providers DECLARE and handed to the
8
+ * matching provider's `classifyDiscoveryHits`, exactly like a scan hit.
9
+ *
10
+ * Adoption is not here: a proposal is adopted through `adoptDevice` or the
11
+ * integration setup form, the flows the scan modal already uses.
12
+ */
13
+ import { type DiscoveryHit, type DiscoveryMode, type DiscoveryObservation, type DiscoveryProposal, type IScopedLogger } from "@camstack/types";
14
+ import { type DiscoveryOrchestratorDeps, type DiscoveryProvider } from "./discovery-orchestrator.js";
15
+ import type { DiscoveryProposalStore, ProposalOwnership } from "./discovery-proposal-store.js";
16
+ /** The hit a declared mode would have produced for this sighting, per matching mode. */
17
+ export declare function hitsForObservation(modes: readonly DiscoveryMode[], observation: DiscoveryObservation): readonly DiscoveryHit[];
18
+ export interface DiscoveryProposalServiceDeps {
19
+ readonly store: DiscoveryProposalStore;
20
+ readonly orchestrator: DiscoveryOrchestratorDeps;
21
+ readonly providerIds: () => Promise<readonly string[]>;
22
+ readonly requireProvider: (addonId: string) => Promise<DiscoveryProvider>;
23
+ readonly ownership: () => Promise<ProposalOwnership>;
24
+ readonly logger: IScopedLogger;
25
+ }
26
+ export declare class DiscoveryProposalService {
27
+ private readonly deps;
28
+ constructor(deps: DiscoveryProposalServiceDeps);
29
+ runSweep(): Promise<{
30
+ providers: number;
31
+ proposed: number;
32
+ }>;
33
+ reportObservations(observations: readonly DiscoveryObservation[]): Promise<{
34
+ proposed: number;
35
+ }>;
36
+ list(): Promise<readonly DiscoveryProposal[]>;
37
+ dismiss(id: string): Promise<boolean>;
38
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Persistent discovery proposals (D994) — `discovery-proposals` record kind.
3
+ *
4
+ * One row per (addon, candidate stableId). A device seen again moves
5
+ * `lastSeenAt` and refreshes the candidate, never `dismissed` and never
6
+ * `firstSeenAt`. What the operator already owns is filtered at READ time, so an
7
+ * adoption done by any other path hides the proposal without a write.
8
+ */
9
+ import type { DiscoveryProposal, DiscoveryProposalBody, RecordKindHandle, RecordsAccess } from "@camstack/types";
10
+ type CandidateOf = DiscoveryProposalBody["candidate"];
11
+ /** What a read hides: devices and integrations the operator already has. */
12
+ export interface ProposalOwnership {
13
+ readonly deviceStableIds: ReadonlySet<string>;
14
+ readonly integrationOriginIds: ReadonlySet<string>;
15
+ }
16
+ export declare function proposalId(addonId: string, stableId: string): string;
17
+ export declare class DiscoveryProposalStore {
18
+ private readonly kind;
19
+ private readonly now;
20
+ constructor(kind: RecordKindHandle<DiscoveryProposalBody>, now?: () => number);
21
+ static of(records: Pick<RecordsAccess, "kind">, now?: () => number): DiscoveryProposalStore;
22
+ /** Record what a provider classified. Returns how many proposals are NEW. */
23
+ observe(addonId: string, candidates: readonly CandidateOf[]): Promise<number>;
24
+ /** Not dismissed, not already a device, not an integration the operator owns. */
25
+ listVisible(owned: ProposalOwnership): Promise<readonly DiscoveryProposal[]>;
26
+ dismiss(id: string): Promise<boolean>;
27
+ }
28
+ export {};
@@ -2,12 +2,13 @@
2
2
  * Record kinds owned by device-manager (records plan phase 4).
3
3
  */
4
4
  import { z } from "zod";
5
- import { DeviceTombstoneSchema, type DefinedRecordKind } from "@camstack/types";
5
+ import { DeviceTombstoneSchema, type DefinedRecordKind, type DiscoveryProposalBody } from "@camstack/types";
6
6
  /** Body excludes `deviceId` — the record id is `String(deviceId)`. */
7
7
  export type DeviceTombstoneBody = Omit<z.infer<typeof DeviceTombstoneSchema>, "deviceId">;
8
8
  export declare const DeviceTombstoneBodySchema: z.ZodType<DeviceTombstoneBody>;
9
9
  export type DeviceManagerRecordKindsMap = {
10
10
  readonly tombstones: DefinedRecordKind<z.ZodType<DeviceTombstoneBody>>;
11
+ readonly "discovery-proposals": DefinedRecordKind<z.ZodType<DiscoveryProposalBody>>;
11
12
  };
12
13
  export declare const deviceManagerRecordKinds: DeviceManagerRecordKindsMap;
13
14
  /** Narrow kind for `records.kind()`. */
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-dQKZfa3-.js");
6
+ const require_dist = require("../../dist-CwYYyGAB.js");
7
7
  const require_formatter = require("../../formatter-xbxeV4GD.js");
8
8
  //#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
9
9
  var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
@@ -1,4 +1,4 @@
1
- import { Yr as logDestinationCapability, uo as BaseAddon } from "../../dist-yrk6fm65.mjs";
1
+ import { Xr as logDestinationCapability, do as BaseAddon } from "../../dist-DcHvuBfD.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
3
3
  //#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
4
4
  var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
@@ -3,10 +3,10 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-dQKZfa3-.js");
7
- const require_device_ca = require("../../device-ca-TbdQfW4d.js");
6
+ const require_dist = require("../../dist-CwYYyGAB.js");
7
+ const require_device_ca = require("../../device-ca-CV9QZvoy.js");
8
8
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
9
- const require_constants = require("../../constants-CKwdQTnw.js");
9
+ const require_constants = require("../../constants-C6zJ_38f.js");
10
10
  const require_platform_key_source = require("../../platform-key-source-Di7HrlGR.js");
11
11
  let node_crypto = require("node:crypto");
12
12
  let _camstack_types_node = require("@camstack/types/node");
@@ -1,7 +1,7 @@
1
- import { Br as keychainCapability, Cs as normalizeSecretOwner, Es as parseSecretRef, Ws as EventCategory, gt as KeychainResetRecordSchema, ht as KeychainAuditEntrySchema, mt as KEYCHAIN_RESET_TRIGGER_ACTOR, rs as defineRecordKinds, ss as formatSecretScope, uo as BaseAddon, zr as keychainAdminCapability } from "../../dist-yrk6fm65.mjs";
2
- import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-D-Cvxobt.mjs";
1
+ import { Br as keychainAdminCapability, Es as normalizeSecretOwner, Vr as keychainCapability, _t as KeychainResetRecordSchema, cs as formatSecretScope, do as BaseAddon, gt as KeychainAuditEntrySchema, ht as KEYCHAIN_RESET_TRIGGER_ACTOR, is as defineRecordKinds, ks as parseSecretRef, qs as EventCategory } from "../../dist-DcHvuBfD.mjs";
2
+ import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-Bpqrad00.mjs";
3
3
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
4
- import { a as MESH_CA_KEY_REF } from "../../constants-DmithOex.mjs";
4
+ import { a as MESH_CA_KEY_REF } from "../../constants-GDBin8zB.mjs";
5
5
  import { n as getPlatformKeychainKey } from "../../platform-key-source-BWlq0jjn.mjs";
6
6
  import { createCipheriv, createDecipheriv, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
7
7
  import { restrictDirToOwnerSync, restrictFileToOwnerSync, writeOwnerOnlyFileSync } from "@camstack/types/node";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-dQKZfa3-.js");
3
+ const require_dist = require("../../dist-CwYYyGAB.js");
4
4
  let node_fs_promises = require("node:fs/promises");
5
5
  node_fs_promises = require_chunk.__toESM(node_fs_promises);
6
6
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { $r as mayWriteToLocation, Nt as RecordingStatusSchema, Us as errMsg, Ws as EventCategory, es as createEvent, jt as RECORDING_SOURCE_CAMSTACK_ADDON, uo as BaseAddon } from "../../dist-yrk6fm65.mjs";
1
+ import { Ks as errMsg, Mt as RECORDING_SOURCE_CAMSTACK_ADDON, Pt as RecordingStatusSchema, do as BaseAddon, ei as mayWriteToLocation, qs as EventCategory, ts as createEvent } from "../../dist-DcHvuBfD.mjs";
2
2
  import * as fsp from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { constants } from "node:fs";
@@ -3,10 +3,10 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-dQKZfa3-.js");
6
+ const require_dist = require("../../dist-CwYYyGAB.js");
7
7
  const require_safe_buffer$1 = require("../../safe-buffer-D3aoa-7X.js");
8
8
  const require_ms$1 = require("../../ms-LB3giGoU.js");
9
- const require_device_ca = require("../../device-ca-TbdQfW4d.js");
9
+ const require_device_ca = require("../../device-ca-CV9QZvoy.js");
10
10
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
11
11
  let zod = require("zod");
12
12
  let node_crypto = require("node:crypto");
@@ -1,15 +1,15 @@
1
1
  import { i as __require, o as __toESM, t as __commonJSMin } from "../../chunk-CNf5ZN-e.mjs";
2
- import { A as CredentialTokenClaimsSchema, Dt as PreferenceDeviceIdSchema, Et as PREFERENCES_MAX_VALUE_BYTES, Mr as isCredentialTokenPayload, Ot as PreferenceNamespaceSchema, Qt as UserRecordSchema, R as DEVICE_ENROLLMENT_TTL_MS, Rs as userError, Ut as SsoBridgeClaimsSchema, V as DEVICE_NONCE_TTL_MS, Vt as ScopedTokenSchema, Xt as TokenScopeSchema, Zn as deviceCredentialsCapability, br as formatDeviceRevoker, dn as authProviderCapability, gs as isSecretMarker, kt as PreferenceValueSchema, rs as defineRecordKinds, uo as BaseAddon, vn as buildDeviceEnrollmentLink, w as CREDENTIAL_TOKEN_AUDIENCE, xa as userManagementCapability, yn as buildDeviceSignatureMessage, ys as makeSecretMarker } from "../../dist-yrk6fm65.mjs";
2
+ import { $t as UserRecordSchema, A as CredentialTokenClaimsSchema, At as PreferenceValueSchema, Dt as PREFERENCES_MAX_VALUE_BYTES, Ht as ScopedTokenSchema, Nr as isCredentialTokenPayload, Ot as PreferenceDeviceIdSchema, Qn as deviceCredentialsCapability, R as DEVICE_ENROLLMENT_TTL_MS, Sa as userManagementCapability, Ss as makeSecretMarker, V as DEVICE_NONCE_TTL_MS, Vs as userError, Wt as SsoBridgeClaimsSchema, Zt as TokenScopeSchema, bn as buildDeviceSignatureMessage, do as BaseAddon, fn as authProviderCapability, is as defineRecordKinds, kt as PreferenceNamespaceSchema, w as CREDENTIAL_TOKEN_AUDIENCE, xr as formatDeviceRevoker, yn as buildDeviceEnrollmentLink, ys as isSecretMarker } from "../../dist-DcHvuBfD.mjs";
3
3
  import { t as require_safe_buffer } from "../../safe-buffer-B1OjL1I9.mjs";
4
4
  import { t as require_ms } from "../../ms-CgH2OFlD.mjs";
5
- import { _ as setProcessJwtSigningKey, a as importDevicePublicKey, c as rebuildDeviceCaCertificate, d as JWT_SIGNING_KEY_REF, g as processJwtSigningKey, h as loadJwtSigningKey, i as generateDeviceCa, l as verifyDeviceLeaf, m as getProcessJwtSigningKeyState, n as DEVICE_CA_KEY_REF, o as issueDeviceLeaf, r as DEVICE_CA_SETTINGS_SECTION, s as loadDeviceCa, t as DEVICE_CA_FIELD, u as verifyDeviceSignature } from "../../device-ca-D-Cvxobt.mjs";
5
+ import { _ as setProcessJwtSigningKey, a as importDevicePublicKey, c as rebuildDeviceCaCertificate, d as JWT_SIGNING_KEY_REF, g as processJwtSigningKey, h as loadJwtSigningKey, i as generateDeviceCa, l as verifyDeviceLeaf, m as getProcessJwtSigningKeyState, n as DEVICE_CA_KEY_REF, o as issueDeviceLeaf, r as DEVICE_CA_SETTINGS_SECTION, s as loadDeviceCa, t as DEVICE_CA_FIELD, u as verifyDeviceSignature } from "../../device-ca-Bpqrad00.mjs";
6
6
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
7
7
  import { z } from "zod";
8
8
  import * as crypto$1 from "node:crypto";
9
9
  import { X509Certificate, createHash, randomUUID, timingSafeEqual } from "node:crypto";
10
10
  import nodeCrypto from "crypto";
11
11
  import * as path$1 from "node:path";
12
- import * as fs from "node:fs";
12
+ import * as fs$1 from "node:fs";
13
13
  //#region ../../node_modules/bcryptjs/index.js
14
14
  /**
15
15
  * The random implementation to use as a fallback.
@@ -11912,8 +11912,8 @@ var LocalAuthAddon = class extends BaseAddon {
11912
11912
  users: this.userManager,
11913
11913
  dataDir: this.ctx.nodeDataDir,
11914
11914
  fs: {
11915
- exists: (filePath) => fs.existsSync(filePath),
11916
- remove: (filePath) => fs.rmSync(filePath, { force: true })
11915
+ exists: (filePath) => fs$1.existsSync(filePath),
11916
+ remove: (filePath) => fs$1.rmSync(filePath, { force: true })
11917
11917
  },
11918
11918
  logger: this.ctx.logger
11919
11919
  });
@@ -72,6 +72,8 @@ interface LocalNetworkConfig {
72
72
  * finds it. On by default; needs UDP 5353 multicast to reach the LAN.
73
73
  */
74
74
  readonly mdnsAdvertise: boolean;
75
+ /** Listen passively for mDNS and SSDP announcements and propose what is found (D994). */
76
+ readonly passiveDiscovery: boolean;
75
77
  /**
76
78
  * Extra subnets the discovery engine scans besides the hub's own links, as
77
79
  * canonical CIDR strings. A cluster setting: every scan uses it.
@@ -96,6 +98,8 @@ export declare class LocalNetworkAddon extends BaseAddon<LocalNetworkConfig> {
96
98
  */
97
99
  private meshEndpoint;
98
100
  private mdns;
101
+ private discoveryWatcher;
102
+ private watcherPassive;
99
103
  constructor();
100
104
  /**
101
105
  * The detected palettes, with the mesh reconciled once: `https` (what
@@ -144,6 +148,12 @@ export declare class LocalNetworkAddon extends BaseAddon<LocalNetworkConfig> {
144
148
  protected override globalSettingsSchema(): ConfigUISchema;
145
149
  protected override onConfigChanged(): Promise<void>;
146
150
  /**
151
+ * (Re)start the passive listener and the 30-minute sweep, both feeding the
152
+ * proposal stream of device-manager. Never throws: a socket that cannot open
153
+ * is logged by the watcher and the sweep still runs.
154
+ */
155
+ private applyDiscoveryWatcher;
156
+ /**
147
157
  * Start, re-announce or stop the hub's mDNS service (D838). Never throws:
148
158
  * the advertiser logs its own failures and boot goes on.
149
159
  */