@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
@@ -3,7 +3,7 @@ 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_formatter = require("../../formatter-xbxeV4GD.js");
8
8
  const require_log_file_read_protocol = require("../../log-file-read-protocol-D0WcLbIV.js");
9
9
  let node_path = require("node:path");
@@ -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
  import { a as LogFileIndexStore, i as serveRead, n as isFromReader, t as CancelBook } from "../../log-file-read-protocol-B7M3X3bT.mjs";
4
4
  import { createRequire } from "node:module";
@@ -1,4 +1,4 @@
1
- import { Us as errMsg, qa as compositionSourceKey } from "./dist-yrk6fm65.mjs";
1
+ import { Ja as compositionSourceKey, Ks as errMsg } from "./dist-DcHvuBfD.mjs";
2
2
  //#region src/builtins/shared/device-state-changed.ts
3
3
  /** Structural narrowing helper for untrusted bus payloads. */
4
4
  function isRecord(value) {
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-dQKZfa3-.js");
1
+ const require_dist = require("./dist-CwYYyGAB.js");
2
2
  //#region src/builtins/shared/device-state-changed.ts
3
3
  /** Structural narrowing helper for untrusted bus payloads. */
4
4
  function isRecord(value) {
@@ -1,5 +1,5 @@
1
1
  /** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
2
- var MESH_CA_KEY_REF = require("./dist-dQKZfa3-.js").buildSecretRef({
2
+ var MESH_CA_KEY_REF = require("./dist-CwYYyGAB.js").buildSecretRef({
3
3
  owner: "system",
4
4
  scope: { kind: "global" },
5
5
  fieldPath: "meshCaKey"
@@ -1,4 +1,4 @@
1
- import { Yo as buildSecretRef } from "./dist-yrk6fm65.mjs";
1
+ import { Xo as buildSecretRef } from "./dist-DcHvuBfD.mjs";
2
2
  /** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
3
3
  var MESH_CA_KEY_REF = buildSecretRef({
4
4
  owner: "system",
@@ -1,5 +1,5 @@
1
1
  import { EDGETPU_LIB_ENV, chooseEdgetpuDelegate, nodeDataRootFromEnv } from "@camstack/types/node";
2
- import Kt from "node:fs";
2
+ import fs from "node:fs";
3
3
  //#region src/builtins/platform-probe/coral-accelerators.ts
4
4
  /**
5
5
  * Coral USB Edge TPU USB identifiers.
@@ -185,21 +185,21 @@ function detectCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
185
185
  }
186
186
  function safeListOrNull(dir) {
187
187
  try {
188
- return Kt.readdirSync(dir);
188
+ return fs.readdirSync(dir);
189
189
  } catch {
190
190
  return null;
191
191
  }
192
192
  }
193
193
  function safeList(dir) {
194
194
  try {
195
- return Kt.readdirSync(dir);
195
+ return fs.readdirSync(dir);
196
196
  } catch {
197
197
  return [];
198
198
  }
199
199
  }
200
200
  function safeRead(path) {
201
201
  try {
202
- return Kt.readFileSync(path, "utf8").trim();
202
+ return fs.readFileSync(path, "utf8").trim();
203
203
  } catch {
204
204
  return "";
205
205
  }
@@ -213,7 +213,7 @@ var nodeCoralFs = {
213
213
  listApexClass: () => safeList("/sys/class/apex"),
214
214
  canOpen: (path) => {
215
215
  try {
216
- Kt.accessSync(path, Kt.constants.R_OK | Kt.constants.W_OK);
216
+ fs.accessSync(path, fs.constants.R_OK | fs.constants.W_OK);
217
217
  return true;
218
218
  } catch {
219
219
  return false;
@@ -221,7 +221,7 @@ var nodeCoralFs = {
221
221
  },
222
222
  exists: (path) => {
223
223
  try {
224
- return Kt.existsSync(path);
224
+ return fs.existsSync(path);
225
225
  } catch {
226
226
  return false;
227
227
  }
@@ -3,7 +3,7 @@ import * as path$1 from "node:path";
3
3
  import path from "node:path";
4
4
  import { promisify } from "node:util";
5
5
  import { HF_REPO, MODEL_FORMATS, describeCustomActions, hfModelUrl } from "@camstack/types/addon";
6
- import * as fs from "node:fs";
6
+ import * as fs$1 from "node:fs";
7
7
  import { createReadStream, promises } from "node:fs";
8
8
  import { createServer } from "node:http";
9
9
  import { brotliCompress, constants as constants$1, gzip } from "node:zlib";
@@ -159,7 +159,7 @@ var HOSTED_MODEL_REVISIONS = {
159
159
  //#endregion
160
160
  //#region src/download/model-downloader.ts
161
161
  function isNonEmptyFile(filePath) {
162
- return fs.existsSync(filePath) && fs.statSync(filePath).size > 0;
162
+ return fs$1.existsSync(filePath) && fs$1.statSync(filePath).size > 0;
163
163
  }
164
164
  /**
165
165
  * Sibling files of a single-file (non-directory) format — extra files the
@@ -269,11 +269,11 @@ function resolveRedirectUrl(current, location) {
269
269
  return new URL(location, current);
270
270
  }
271
271
  async function downloadFile(url, destPath, onProgressOrOptions) {
272
- if (fs.existsSync(destPath)) return destPath;
272
+ if (fs$1.existsSync(destPath)) return destPath;
273
273
  const opts = normalizeDownloadOptions(onProgressOrOptions);
274
274
  const fetchImpl = opts.fetchImpl ?? fetch;
275
275
  const maxRedirects = opts.maxRedirects ?? DEFAULT_MAX_REDIRECTS;
276
- fs.mkdirSync(path$1.dirname(destPath), { recursive: true });
276
+ fs$1.mkdirSync(path$1.dirname(destPath), { recursive: true });
277
277
  const tmpPath = destPath + ".downloading";
278
278
  try {
279
279
  let current = url;
@@ -315,7 +315,7 @@ async function downloadFile(url, destPath, onProgressOrOptions) {
315
315
  if (!response.body) throw new Error(`No response body from ${url}`);
316
316
  const total = parseInt(response.headers.get("content-length") ?? "0", 10);
317
317
  let downloaded = 0;
318
- const fileStream = fs.createWriteStream(tmpPath);
318
+ const fileStream = fs$1.createWriteStream(tmpPath);
319
319
  const reader = response.body.getReader();
320
320
  try {
321
321
  for (;;) {
@@ -333,11 +333,11 @@ async function downloadFile(url, destPath, onProgressOrOptions) {
333
333
  fileStream.on("error", reject);
334
334
  });
335
335
  }
336
- fs.renameSync(tmpPath, destPath);
336
+ fs$1.renameSync(tmpPath, destPath);
337
337
  return destPath;
338
338
  } catch (err) {
339
339
  try {
340
- fs.unlinkSync(tmpPath);
340
+ fs$1.unlinkSync(tmpPath);
341
341
  } catch {}
342
342
  throw err;
343
343
  }
@@ -368,12 +368,12 @@ async function downloadModel(options) {
368
368
  const { url, fallbackUrls = [], destDir, filename, expectedSha256, onProgress } = options;
369
369
  const fname = filename ?? url.split("/").pop() ?? "model.bin";
370
370
  const destPath = path$1.join(destDir, fname);
371
- if (fs.existsSync(destPath)) return {
371
+ if (fs$1.existsSync(destPath)) return {
372
372
  filePath: destPath,
373
373
  downloadedBytes: 0,
374
374
  fromCache: true
375
375
  };
376
- fs.mkdirSync(destDir, { recursive: true });
376
+ fs$1.mkdirSync(destDir, { recursive: true });
377
377
  const urls = [url, ...fallbackUrls];
378
378
  let lastError = null;
379
379
  for (const tryUrl of urls) try {
@@ -381,25 +381,25 @@ async function downloadModel(options) {
381
381
  if (expectedSha256) {
382
382
  const hash = await computeSha256(destPath);
383
383
  if (hash !== expectedSha256) {
384
- fs.unlinkSync(destPath);
384
+ fs$1.unlinkSync(destPath);
385
385
  throw new Error(`SHA256 mismatch: expected ${expectedSha256}, got ${hash}`);
386
386
  }
387
387
  }
388
388
  return {
389
389
  filePath: destPath,
390
- downloadedBytes: fs.statSync(destPath).size,
390
+ downloadedBytes: fs$1.statSync(destPath).size,
391
391
  fromCache: false
392
392
  };
393
393
  } catch (e) {
394
394
  lastError = e;
395
- if (fs.existsSync(destPath)) fs.unlinkSync(destPath);
395
+ if (fs$1.existsSync(destPath)) fs$1.unlinkSync(destPath);
396
396
  }
397
397
  throw lastError ?? /* @__PURE__ */ new Error(`Failed to download model from ${url}`);
398
398
  }
399
399
  async function computeSha256(filePath) {
400
400
  return new Promise((resolve, reject) => {
401
401
  const hash = createHash("sha256");
402
- const stream = fs.createReadStream(filePath);
402
+ const stream = fs$1.createReadStream(filePath);
403
403
  stream.on("data", (chunk) => hash.update(chunk));
404
404
  stream.on("end", () => resolve(hash.digest("hex")));
405
405
  stream.on("error", reject);
@@ -424,28 +424,28 @@ async function downloadDirectory(url, destDir, knownFiles, onProgress) {
424
424
  fileUrl: `https://huggingface.co/${repo}/resolve/main/${dirPath}/${f}`
425
425
  }));
426
426
  const tmpDir = destDir + ".downloading";
427
- fs.rmSync(tmpDir, {
427
+ fs$1.rmSync(tmpDir, {
428
428
  recursive: true,
429
429
  force: true
430
430
  });
431
- fs.mkdirSync(tmpDir, { recursive: true });
431
+ fs$1.mkdirSync(tmpDir, { recursive: true });
432
432
  let totalDownloaded = 0;
433
433
  try {
434
434
  for (const file of files) {
435
435
  const destPath = path$1.join(tmpDir, file.relativePath);
436
- fs.mkdirSync(path$1.dirname(destPath), { recursive: true });
436
+ fs$1.mkdirSync(path$1.dirname(destPath), { recursive: true });
437
437
  await downloadFile(file.fileUrl, destPath, (downloaded, _total) => {
438
438
  onProgress?.(totalDownloaded + downloaded, void 0);
439
439
  });
440
- totalDownloaded += fs.statSync(destPath).size;
440
+ totalDownloaded += fs$1.statSync(destPath).size;
441
441
  }
442
- fs.rmSync(destDir, {
442
+ fs$1.rmSync(destDir, {
443
443
  recursive: true,
444
444
  force: true
445
445
  });
446
- fs.renameSync(tmpDir, destDir);
446
+ fs$1.renameSync(tmpDir, destDir);
447
447
  } catch (err) {
448
- fs.rmSync(tmpDir, {
448
+ fs$1.rmSync(tmpDir, {
449
449
  recursive: true,
450
450
  force: true
451
451
  });
@@ -477,7 +477,7 @@ function revisionRecordPath(modelPath) {
477
477
  }
478
478
  function readRevisionRecord(modelPath) {
479
479
  try {
480
- return fs.readFileSync(revisionRecordPath(modelPath), "utf8").trim();
480
+ return fs$1.readFileSync(revisionRecordPath(modelPath), "utf8").trim();
481
481
  } catch {
482
482
  return null;
483
483
  }
@@ -541,8 +541,8 @@ function writeRevisionRecord(modelPath, revision) {
541
541
  if (revision === void 0) return;
542
542
  const record = revisionRecordPath(modelPath);
543
543
  const tmp = `${record}.tmp`;
544
- fs.writeFileSync(tmp, `${revision}\n`);
545
- fs.renameSync(tmp, record);
544
+ fs$1.writeFileSync(tmp, `${revision}\n`);
545
+ fs$1.renameSync(tmp, record);
546
546
  }
547
547
  /**
548
548
  * Prove an unrecorded (or differently recorded) copy current by hashing its
@@ -562,9 +562,9 @@ async function adoptByHash(modelsDir, modelPath, formatEntry) {
562
562
  }
563
563
  /** True when every file of the format is on disk, whatever revision it holds. */
564
564
  function isCompleteCopy(modelsDir, modelPath, formatEntry) {
565
- if (!fs.existsSync(modelPath)) return false;
566
- if (formatEntry.isDirectory) return fs.existsSync(path$1.join(modelPath, "Manifest.json"));
567
- if (fs.statSync(modelPath).size <= 0) return false;
565
+ if (!fs$1.existsSync(modelPath)) return false;
566
+ if (formatEntry.isDirectory) return fs$1.existsSync(path$1.join(modelPath, "Manifest.json"));
567
+ if (fs$1.statSync(modelPath).size <= 0) return false;
568
568
  return siblingFilesFor(formatEntry).every((f) => isNonEmptyFile(path$1.join(modelsDir, f)));
569
569
  }
570
570
  /**
@@ -586,14 +586,14 @@ async function replaceSingleFileFormat(url, modelPath, modelsDir, siblings, onPr
586
586
  }));
587
587
  try {
588
588
  for (const [i, part] of parts.entries()) {
589
- fs.rmSync(part.staged, { force: true });
589
+ fs$1.rmSync(part.staged, { force: true });
590
590
  await downloadFile(part.url, part.staged, i === 0 ? (downloaded, total) => onProgress?.(downloaded, total === 0 ? void 0 : total) : void 0);
591
591
  }
592
592
  } catch (err) {
593
- for (const part of parts) fs.rmSync(part.staged, { force: true });
593
+ for (const part of parts) fs$1.rmSync(part.staged, { force: true });
594
594
  throw err;
595
595
  }
596
- for (const part of parts) fs.renameSync(part.staged, part.dest);
596
+ for (const part of parts) fs$1.renameSync(part.staged, part.dest);
597
597
  }
598
598
  /**
599
599
  * Resolve a `ModelCatalogEntry` against `modelsDir`: download model file
@@ -608,14 +608,14 @@ async function ensureModel(modelsDir, entry, format, onProgress) {
608
608
  const modelPath = path$1.join(modelsDir, filename);
609
609
  const siblings = siblingFilesFor(formatEntry);
610
610
  let outdated = false;
611
- if (fs.existsSync(modelPath)) if (formatEntry.isDirectory && !fs.existsSync(path$1.join(modelPath, "Manifest.json"))) fs.rmSync(modelPath, {
611
+ if (fs$1.existsSync(modelPath)) if (formatEntry.isDirectory && !fs$1.existsSync(path$1.join(modelPath, "Manifest.json"))) fs$1.rmSync(modelPath, {
612
612
  recursive: true,
613
613
  force: true
614
614
  });
615
615
  else if (siblings.some((f) => !isNonEmptyFile(path$1.join(modelsDir, f)))) outdated = !isCurrentRevision(modelPath, formatEntry) && !await adoptByHash(modelsDir, modelPath, formatEntry);
616
616
  else if (isCurrentRevision(modelPath, formatEntry) || await adoptByHash(modelsDir, modelPath, formatEntry)) return modelPath;
617
617
  else outdated = true;
618
- fs.mkdirSync(modelsDir, { recursive: true });
618
+ fs$1.mkdirSync(modelsDir, { recursive: true });
619
619
  if (formatEntry.isDirectory) await downloadDirectory(formatEntry.url, modelPath, formatEntry.files, onProgress);
620
620
  else if (outdated) await replaceSingleFileFormat(formatEntry.url, modelPath, modelsDir, siblings, onProgress);
621
621
  else {
@@ -673,25 +673,25 @@ function isModelDownloaded(modelsDir, entry, format) {
673
673
  const formatEntry = entry.formats[format];
674
674
  if (!formatEntry) return false;
675
675
  const modelPath = getModelFilePath(modelsDir, entry, format);
676
- if (!modelPath || !fs.existsSync(modelPath)) return false;
676
+ if (!modelPath || !fs$1.existsSync(modelPath)) return false;
677
677
  if (!isCurrentRevision(modelPath, formatEntry)) return false;
678
678
  return isCompleteCopy(modelsDir, modelPath, formatEntry);
679
679
  }
680
680
  /** Remove the on-disk model file/directory. Returns true if something was deleted. */
681
681
  function deleteModelFromDisk(modelsDir, entry, format) {
682
682
  const modelPath = getModelFilePath(modelsDir, entry, format);
683
- if (!modelPath || !fs.existsSync(modelPath)) return false;
684
- fs.rmSync(revisionRecordPath(modelPath), { force: true });
683
+ if (!modelPath || !fs$1.existsSync(modelPath)) return false;
684
+ fs$1.rmSync(revisionRecordPath(modelPath), { force: true });
685
685
  const formatEntry = entry.formats[format];
686
- if (formatEntry?.isDirectory) fs.rmSync(modelPath, {
686
+ if (formatEntry?.isDirectory) fs$1.rmSync(modelPath, {
687
687
  recursive: true,
688
688
  force: true
689
689
  });
690
690
  else {
691
- fs.unlinkSync(modelPath);
691
+ fs$1.unlinkSync(modelPath);
692
692
  if (formatEntry) for (const sibling of siblingFilesFor(formatEntry)) {
693
693
  const sibPath = path$1.join(modelsDir, sibling);
694
- if (fs.existsSync(sibPath)) fs.unlinkSync(sibPath);
694
+ if (fs$1.existsSync(sibPath)) fs$1.unlinkSync(sibPath);
695
695
  }
696
696
  }
697
697
  return true;
@@ -1,4 +1,4 @@
1
- import { H as DEVICE_SAN_CREDENTIAL_PREFIX, U as DEVICE_SAN_USER_PREFIX, Yo as buildSecretRef } from "./dist-yrk6fm65.mjs";
1
+ import { H as DEVICE_SAN_CREDENTIAL_PREFIX, U as DEVICE_SAN_USER_PREFIX, Xo as buildSecretRef } from "./dist-DcHvuBfD.mjs";
2
2
  import { C as backdatedNotBefore, S as withUtcTimeEncoding, a as KeyUsageFlags, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension } from "./x509.es-BRiJgOvu.mjs";
3
3
  import { X509Certificate, createPublicKey, randomBytes, verify, webcrypto } from "node:crypto";
4
4
  //#region src/auth/jwt-signing-key.ts
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-dQKZfa3-.js");
1
+ const require_dist = require("./dist-CwYYyGAB.js");
2
2
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
3
3
  let node_crypto = require("node:crypto");
4
4
  //#region src/auth/jwt-signing-key.ts
@@ -1162,7 +1162,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1162
1162
  return DeviceRole;
1163
1163
  }({});
1164
1164
  //#endregion
1165
- //#region ../types/dist/sleep-B-vp7x15.mjs
1165
+ //#region ../types/dist/sleep-Bei295Bz.mjs
1166
1166
  /**
1167
1167
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1168
1168
  * window to float samples (D455).
@@ -5015,6 +5015,60 @@ var ProfileRtspEntrySchema = zod.z.object({
5015
5015
  codec: zod.z.string().optional(),
5016
5016
  resolution: CamStreamResolutionSchema.optional()
5017
5017
  });
5018
+ /** Every debug channel's name starts with this; the ring denies it by default. */
5019
+ var DEBUG_CHANNEL_PREFIX = "debug.";
5020
+ function isDebugChannelName(name) {
5021
+ return name.startsWith(DEBUG_CHANNEL_PREFIX);
5022
+ }
5023
+ /**
5024
+ * Who is watching what, in THIS process. In-memory, moved off the log path.
5025
+ *
5026
+ * `active` is a plain boolean FIELD, read first: with no watch anywhere, a
5027
+ * `ctx.debug` call is one load and one branch.
5028
+ */
5029
+ var DebugInterest = class {
5030
+ active = false;
5031
+ windows = /* @__PURE__ */ new Map();
5032
+ /**
5033
+ * Replace the interest with the FULL set of windows. Non-debug windows are
5034
+ * ignored and an absent one is dropped, so a lost disarm cannot leave a
5035
+ * channel running.
5036
+ */
5037
+ apply(windows, nowMs) {
5038
+ this.windows.clear();
5039
+ for (const window of windows) {
5040
+ if (!isDebugChannelName(window.channel) || window.armedUntilMs <= nowMs) continue;
5041
+ const ids = window.deviceIds;
5042
+ this.windows.set(window.channel, {
5043
+ untilMs: window.armedUntilMs,
5044
+ devices: ids === null || ids.length === 0 ? null : new Set(ids)
5045
+ });
5046
+ }
5047
+ this.active = this.windows.size > 0;
5048
+ }
5049
+ /** Drop what has lapsed. Called on a timer, never from a log path. */
5050
+ tick(nowMs) {
5051
+ const closed = [];
5052
+ for (const [name, window] of this.windows) if (window.untilMs <= nowMs) {
5053
+ this.windows.delete(name);
5054
+ closed.push(name);
5055
+ }
5056
+ this.active = this.windows.size > 0;
5057
+ return closed;
5058
+ }
5059
+ /** `channel` is the full name, `debug.<channel>`. */
5060
+ wants(channel, deviceId) {
5061
+ if (!this.active) return false;
5062
+ const window = this.windows.get(channel);
5063
+ if (window === void 0) return false;
5064
+ return window.devices === null || window.devices.has(deviceId);
5065
+ }
5066
+ };
5067
+ var interestInstance = null;
5068
+ function getDebugInterest() {
5069
+ interestInstance ??= new DebugInterest();
5070
+ return interestInstance;
5071
+ }
5018
5072
  var ReadinessTimeoutError = class extends Error {
5019
5073
  capName;
5020
5074
  scope;
@@ -14250,8 +14304,18 @@ var LogChannelDescriptorSchema = zod.z.object({
14250
14304
  * the operator narrows to one camera, sees nothing, and concludes the code
14251
14305
  * path was never taken.
14252
14306
  */
14253
- perDevice: zod.z.boolean()
14254
- });
14307
+ perDevice: zod.z.boolean(),
14308
+ /**
14309
+ * What the channel is FOR, so the UI can list the channels an addon offers.
14310
+ *
14311
+ * - `diagnostic` (the default): a per-component diagnostic armed from the
14312
+ * Levels page, emitted at its declared level.
14313
+ * - `debug`: a `debug.<channel>` dump watched live for a short window
14314
+ * (`ctx.debug`). Always per-device, and its lines are denied by the log
14315
+ * ring unless somebody is watching that device.
14316
+ */
14317
+ kind: zod.z.enum(["diagnostic", "debug"]).default("diagnostic")
14318
+ }).refine((d) => d.kind !== "debug" || d.name.startsWith("debug.") && d.perDevice, { message: "a debug channel is named debug.<channel> and is per-device" });
14255
14319
  /**
14256
14320
  * An armed window over one channel, as the document hands it to a mirror.
14257
14321
  *
@@ -56153,6 +56217,45 @@ var deviceProviderCapability = {
56153
56217
  }
56154
56218
  };
56155
56219
  /**
56220
+ * What the passive listener of `local-network` saw on the wire, before any
56221
+ * provider classified it. Device-manager turns an observation into the hits
56222
+ * of the providers whose declared discovery modes it matches.
56223
+ */
56224
+ var DiscoveryObservationSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
56225
+ kind: zod.z.literal("mdns"),
56226
+ /** Normalised DNS-SD service type, e.g. `_esphomelib._tcp`. */
56227
+ serviceType: zod.z.string(),
56228
+ instance: zod.z.string(),
56229
+ host: zod.z.string(),
56230
+ /** The A record address when the announcement carried one. */
56231
+ address: zod.z.string().nullable(),
56232
+ port: zod.z.number().int(),
56233
+ txt: zod.z.record(zod.z.string(), zod.z.string())
56234
+ }), zod.z.object({
56235
+ kind: zod.z.literal("ssdp"),
56236
+ /** Sender address of the datagram. */
56237
+ host: zod.z.string(),
56238
+ port: zod.z.number().int(),
56239
+ /** `NT` of a NOTIFY, `ST` of a search response. */
56240
+ target: zod.z.string(),
56241
+ headers: zod.z.record(zod.z.string(), zod.z.string())
56242
+ })]);
56243
+ var DiscoveryProposalBodySchema = zod.z.object({
56244
+ addonId: zod.z.string(),
56245
+ candidate: DiscoveryCandidateSchema,
56246
+ firstSeenAt: zod.z.number(),
56247
+ lastSeenAt: zod.z.number(),
56248
+ dismissed: zod.z.boolean()
56249
+ });
56250
+ var DiscoveryProposalSchema = zod.z.object({
56251
+ id: zod.z.string(),
56252
+ addonId: zod.z.string(),
56253
+ candidate: DiscoveryCandidateSchema,
56254
+ firstSeenAt: zod.z.number(),
56255
+ lastSeenAt: zod.z.number(),
56256
+ dismissed: zod.z.boolean()
56257
+ });
56258
+ /**
56156
56259
  * Device Manager capability — hub-side singleton that unifies device persistence,
56157
56260
  * live registry access, and all management operations into a single tRPC surface.
56158
56261
  *
@@ -57476,6 +57579,27 @@ var deviceManagerCapability = {
57476
57579
  kind: "mutation",
57477
57580
  auth: "admin"
57478
57581
  }),
57582
+ /** Proposals still worth showing: not dismissed, not adopted, not an integration we own. */
57583
+ listDiscoveryProposals: method(zod.z.object({}), zod.z.object({ proposals: zod.z.array(DiscoveryProposalSchema).readonly() }), { auth: "admin" }),
57584
+ /** Hide a proposal for good; seeing the device again does not bring it back. */
57585
+ dismissDiscoveryProposal: method(zod.z.object({ id: zod.z.string() }), zod.z.object({ dismissed: zod.z.boolean() }), {
57586
+ kind: "mutation",
57587
+ auth: "admin"
57588
+ }),
57589
+ /** Raw passive sightings from `local-network`; classified by the matching providers. */
57590
+ reportDiscoveryObservations: method(zod.z.object({ observations: zod.z.array(DiscoveryObservationSchema).max(512) }), zod.z.object({ proposed: zod.z.number().int() }), {
57591
+ kind: "mutation",
57592
+ auth: "admin"
57593
+ }),
57594
+ /** Run the providers' discovery once and record what it found as proposals. */
57595
+ runDiscoverySweep: method(zod.z.object({}), zod.z.object({
57596
+ providers: zod.z.number().int(),
57597
+ proposed: zod.z.number().int()
57598
+ }), {
57599
+ kind: "mutation",
57600
+ auth: "admin",
57601
+ timeoutMs: 12e4
57602
+ }),
57479
57603
  /** The device type a provider creates via manual add (Camera/Container/Hub),
57480
57604
  * so the Add-Device dialog uses the right type instead of assuming Camera. */
57481
57605
  providerCreationType: method(zod.z.object({ addonId: zod.z.string() }), zod.z.object({ deviceType: zod.z.enum(DeviceType).nullable() }), { auth: "admin" }),
@@ -87028,6 +87152,40 @@ var LoggingSettingsStateSchema = zod.z.object({
87028
87152
  opsLogRetentionDays: zod.z.number().int().min(0),
87029
87153
  persisted: zod.z.boolean()
87030
87154
  });
87155
+ /**
87156
+ * Debug WATCH — a short, per-device window over `debug.<channel>` lines.
87157
+ *
87158
+ * `start` opens (or re-arms) a 10 minute window; `rearm` extends a LIVE one
87159
+ * and never revives a lapsed one; `stop` closes it; `list` only reads. No
87160
+ * chain of re-arms outlives 60 minutes from the first start. The hub holds the
87161
+ * watches in memory and pushes the interest to every node, so a watch lapses
87162
+ * by itself and survives nothing — a restart is a stop.
87163
+ */
87164
+ var DebugWatchInputSchema = zod.z.object({
87165
+ action: zod.z.enum([
87166
+ "list",
87167
+ "start",
87168
+ "rearm",
87169
+ "stop"
87170
+ ]),
87171
+ /** Full channel names, `debug.<channel>`, each declared with `kind: 'debug'`. */
87172
+ channels: zod.z.array(zod.z.string().min(1)).readonly().default([]),
87173
+ /** Numeric device ids. Required (non-empty) for `start`. */
87174
+ deviceIds: zod.z.array(zod.z.number().int()).readonly().default([])
87175
+ });
87176
+ var DebugWatchStateSchema = zod.z.object({
87177
+ channel: zod.z.string(),
87178
+ deviceIds: zod.z.array(zod.z.number().int()).readonly(),
87179
+ startedAtMs: zod.z.number(),
87180
+ untilMs: zod.z.number(),
87181
+ capAtMs: zod.z.number()
87182
+ });
87183
+ var DebugWatchResultSchema = zod.z.object({
87184
+ nowMs: zod.z.number(),
87185
+ watches: zod.z.array(DebugWatchStateSchema).readonly(),
87186
+ /** Channels a `rearm` found already lapsed: nothing was revived. */
87187
+ lapsed: zod.z.array(zod.z.string()).readonly()
87188
+ });
87031
87189
  var systemCapability = {
87032
87190
  name: "system",
87033
87191
  scope: "system",
@@ -87141,6 +87299,14 @@ var systemCapability = {
87141
87299
  setLoggingSettings: method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
87142
87300
  kind: "mutation",
87143
87301
  auth: "admin"
87302
+ }),
87303
+ /**
87304
+ * Start, re-arm, stop or list the live debug watches. See
87305
+ * {@link DebugWatchInputSchema}.
87306
+ */
87307
+ debugWatch: method(DebugWatchInputSchema, DebugWatchResultSchema, {
87308
+ kind: "mutation",
87309
+ auth: "admin"
87144
87310
  })
87145
87311
  },
87146
87312
  /** BIG PLAN 2: declarative mount hint — read by `@camstack/server/system` `buildCapRouters`. */
@@ -95700,6 +95866,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
95700
95866
  access: "view",
95701
95867
  role: "admin"
95702
95868
  },
95869
+ "deviceManager.dismissDiscoveryProposal": {
95870
+ capName: "device-manager",
95871
+ capScope: "system",
95872
+ addonId: null,
95873
+ access: "create",
95874
+ role: "admin"
95875
+ },
95703
95876
  "deviceManager.enable": {
95704
95877
  capName: "device-manager",
95705
95878
  capScope: "system",
@@ -95882,6 +96055,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
95882
96055
  access: "view",
95883
96056
  role: "viewer"
95884
96057
  },
96058
+ "deviceManager.listDiscoveryProposals": {
96059
+ capName: "device-manager",
96060
+ capScope: "system",
96061
+ addonId: null,
96062
+ access: "view",
96063
+ role: "admin"
96064
+ },
95885
96065
  "deviceManager.listLocationDescriptions": {
95886
96066
  capName: "device-manager",
95887
96067
  capScope: "system",
@@ -96036,6 +96216,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
96036
96216
  access: "create",
96037
96217
  role: "admin"
96038
96218
  },
96219
+ "deviceManager.reportDiscoveryObservations": {
96220
+ capName: "device-manager",
96221
+ capScope: "system",
96222
+ addonId: null,
96223
+ access: "create",
96224
+ role: "admin"
96225
+ },
96039
96226
  "deviceManager.runDeviceAction": {
96040
96227
  capName: "device-manager",
96041
96228
  capScope: "system",
@@ -96043,6 +96230,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
96043
96230
  access: "create",
96044
96231
  role: "admin"
96045
96232
  },
96233
+ "deviceManager.runDiscoverySweep": {
96234
+ capName: "device-manager",
96235
+ capScope: "system",
96236
+ addonId: null,
96237
+ access: "create",
96238
+ role: "admin"
96239
+ },
96046
96240
  "deviceManager.setChildLayout": {
96047
96241
  capName: "device-manager",
96048
96242
  capScope: "system",
@@ -102630,6 +102824,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
102630
102824
  access: "create",
102631
102825
  role: "viewer"
102632
102826
  },
102827
+ "system.debugWatch": {
102828
+ capName: "system",
102829
+ capScope: "system",
102830
+ addonId: null,
102831
+ access: "create",
102832
+ role: "admin"
102833
+ },
102633
102834
  "system.detectSiteLocation": {
102634
102835
  capName: "system",
102635
102836
  capScope: "system",
@@ -106637,6 +106838,11 @@ Object.freeze({
106637
106838
  form: "single",
106638
106839
  optional: false
106639
106840
  }],
106841
+ "system.debugWatch": [{
106842
+ name: "deviceIds",
106843
+ form: "array",
106844
+ optional: true
106845
+ }],
106640
106846
  "tamper.getStatus": [{
106641
106847
  name: "deviceId",
106642
106848
  form: "single",
@@ -109495,6 +109701,12 @@ Object.defineProperty(exports, "DeviceType", {
109495
109701
  return DeviceType;
109496
109702
  }
109497
109703
  });
109704
+ Object.defineProperty(exports, "DiscoveryProposalBodySchema", {
109705
+ enumerable: true,
109706
+ get: function() {
109707
+ return DiscoveryProposalBodySchema;
109708
+ }
109709
+ });
109498
109710
  Object.defineProperty(exports, "EMPTY_AUTOMATION_STATE", {
109499
109711
  enumerable: true,
109500
109712
  get: function() {
@@ -110683,6 +110895,12 @@ Object.defineProperty(exports, "gbToBytes", {
110683
110895
  return gbToBytes;
110684
110896
  }
110685
110897
  });
110898
+ Object.defineProperty(exports, "getDebugInterest", {
110899
+ enumerable: true,
110900
+ get: function() {
110901
+ return getDebugInterest;
110902
+ }
110903
+ });
110686
110904
  Object.defineProperty(exports, "groupCommandsCapability", {
110687
110905
  enumerable: true,
110688
110906
  get: function() {
@@ -110773,6 +110991,12 @@ Object.defineProperty(exports, "isCredentialTokenPayload", {
110773
110991
  return isCredentialTokenPayload;
110774
110992
  }
110775
110993
  });
110994
+ Object.defineProperty(exports, "isDebugChannelName", {
110995
+ enumerable: true,
110996
+ get: function() {
110997
+ return isDebugChannelName;
110998
+ }
110999
+ });
110776
111000
  Object.defineProperty(exports, "isDefaultAppConnectionEndpoint", {
110777
111001
  enumerable: true,
110778
111002
  get: function() {