@camstack/server 1.2.767 → 1.2.769

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 (90) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +14 -8
  3. package/system/dist/addon-runner.js +7 -1
  4. package/system/dist/addon-runner.mjs +7 -1
  5. package/system/dist/addon-utils.mjs +1 -1
  6. package/system/dist/{agent-https-D03iyjJk.mjs → agent-https-C_rkCAus.mjs} +1 -1
  7. package/system/dist/{agent-https-D62iihRo.js → agent-https-Cw5Wc_ip.js} +1 -1
  8. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
  10. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
  12. package/system/dist/builtins/alerts/alerts.addon.d.ts +15 -0
  13. package/system/dist/builtins/alerts/alerts.addon.js +104 -4
  14. package/system/dist/builtins/alerts/alerts.addon.mjs +104 -4
  15. package/system/dist/builtins/alerts/cluster-state-alerts.d.ts +32 -0
  16. package/system/dist/builtins/autotrack/index.js +1 -1
  17. package/system/dist/builtins/autotrack/index.mjs +1 -1
  18. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  19. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
  20. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  21. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  22. package/system/dist/builtins/camera-grid/index.js +1 -1
  23. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  24. package/system/dist/builtins/composer/composer.addon.js +5 -4
  25. package/system/dist/builtins/composer/composer.addon.mjs +5 -4
  26. package/system/dist/builtins/console-logging/index.js +1 -1
  27. package/system/dist/builtins/console-logging/index.mjs +1 -1
  28. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  29. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  30. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  31. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  32. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  33. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  34. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  35. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  36. package/system/dist/builtins/keychain/index.js +3 -3
  37. package/system/dist/builtins/keychain/index.mjs +3 -3
  38. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  39. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  40. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  41. package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
  42. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  43. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  44. package/system/dist/builtins/loki-logging/index.js +1 -1
  45. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  46. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  47. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
  48. package/system/dist/builtins/platform-probe/index.js +1 -1
  49. package/system/dist/builtins/platform-probe/index.mjs +10 -10
  50. package/system/dist/builtins/record-entries/index.js +1 -1
  51. package/system/dist/builtins/record-entries/index.mjs +1 -1
  52. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  53. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  54. package/system/dist/builtins/snapshot/index.js +1 -1
  55. package/system/dist/builtins/snapshot/index.mjs +1 -1
  56. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  57. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
  58. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  59. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  60. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
  61. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
  62. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  63. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  64. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  65. package/system/dist/builtins/system-config/system-config.addon.mjs +115 -115
  66. package/system/dist/builtins/winston-logging/index.js +1 -1
  67. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  68. package/system/dist/{capture-engine-BpoL1zQ0.js → capture-engine-DXSWU1PY.js} +1 -1
  69. package/system/dist/{capture-engine-CYmRx0Ce.mjs → capture-engine-Kl46lSBi.mjs} +1 -1
  70. package/system/dist/{composition-sources-CknQxftO.mjs → composition-sources-ClCP809M.mjs} +1 -1
  71. package/system/dist/{composition-sources-B7VyYbEU.js → composition-sources-Cq0IeRv9.js} +1 -1
  72. package/system/dist/{constants-C9Gxs1jW.mjs → constants-CDxTuuXp.mjs} +1 -1
  73. package/system/dist/{constants-DJqUggkW.js → constants-CI5ySMIj.js} +1 -1
  74. package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
  75. package/system/dist/{custom-action-registry-oHl1xltx.mjs → custom-action-registry-BIJZBObd.mjs} +37 -37
  76. package/system/dist/{device-ca-9BTS4o-T.js → device-ca-DPvU-3TE.js} +1 -1
  77. package/system/dist/{device-ca-D76OqRnW.mjs → device-ca-uRLJ8-jZ.mjs} +1 -1
  78. package/system/dist/{dist-DLVfdGSW.js → dist-BDixk7cu.js} +107 -29
  79. package/system/dist/{dist-BhR34kF8.mjs → dist-C_SNsYGY.mjs} +107 -29
  80. package/system/dist/file-host-worker.js +1 -1
  81. package/system/dist/file-host-worker.mjs +1 -1
  82. package/system/dist/{hub-mdns-ciao-DimaT9WQ.js → hub-mdns-ciao-7uRbexmH.js} +2 -2
  83. package/system/dist/{hub-mdns-ciao-i31GIYWP.mjs → hub-mdns-ciao-ea1EwFAF.mjs} +2 -2
  84. package/system/dist/index.js +14 -8
  85. package/system/dist/index.mjs +225 -219
  86. package/system/dist/{restore-archive-BkiXu43U.js → restore-archive-CpTnlXUA.js} +1 -1
  87. package/system/dist/{restore-archive-VoiEuTJN.mjs → restore-archive-D0y_tFM2.mjs} +94 -94
  88. package/system/dist/{wal-maintenance-DG2bwMif.mjs → wal-maintenance-BvxzVfje.mjs} +0 -0
  89. package/system/dist/{wal-maintenance-UQEtPem2.js → wal-maintenance-Dy4gxMdb.js} +0 -0
  90. 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-DLVfdGSW.js");
6
+ const require_dist = require("../../dist-BDixk7cu.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 { ri as logDestinationCapability, wo as BaseAddon } from "../../dist-BhR34kF8.mjs";
1
+ import { ri as logDestinationCapability, wo as BaseAddon } from "../../dist-C_SNsYGY.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
- const require_dist = require("./dist-DLVfdGSW.js");
1
+ const require_dist = require("./dist-BDixk7cu.js");
2
2
  //#region src/builtins/device-history/store/series-registry.ts
3
3
  function subjectIdOf(subject) {
4
4
  return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
@@ -1,4 +1,4 @@
1
- import { No as HISTORY_DEFAULT_MIN_INTERVAL_MS, Ts as historyItemFieldPath, lc as DeviceType } from "./dist-BhR34kF8.mjs";
1
+ import { No as HISTORY_DEFAULT_MIN_INTERVAL_MS, Ts as historyItemFieldPath, lc as DeviceType } from "./dist-C_SNsYGY.mjs";
2
2
  //#region src/builtins/device-history/store/series-registry.ts
3
3
  function subjectIdOf(subject) {
4
4
  return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
@@ -1,4 +1,4 @@
1
- import { oo as compositionSourceKey, uc as errMsg } from "./dist-BhR34kF8.mjs";
1
+ import { oo as compositionSourceKey, uc as errMsg } from "./dist-C_SNsYGY.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-DLVfdGSW.js");
1
+ const require_dist = require("./dist-BDixk7cu.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,4 +1,4 @@
1
- import { ls as buildSecretRef } from "./dist-BhR34kF8.mjs";
1
+ import { ls as buildSecretRef } from "./dist-C_SNsYGY.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
  /** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
2
- var MESH_CA_KEY_REF = require("./dist-DLVfdGSW.js").buildSecretRef({
2
+ var MESH_CA_KEY_REF = require("./dist-BDixk7cu.js").buildSecretRef({
3
3
  owner: "system",
4
4
  scope: { kind: "global" },
5
5
  fieldPath: "meshCaKey"
@@ -1,5 +1,5 @@
1
1
  import { EDGETPU_LIB_ENV, chooseEdgetpuDelegate, nodeDataRootFromEnv } from "@camstack/types/node";
2
- import fs from "node:fs";
2
+ import Kt 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 fs.readdirSync(dir);
188
+ return Kt.readdirSync(dir);
189
189
  } catch {
190
190
  return null;
191
191
  }
192
192
  }
193
193
  function safeList(dir) {
194
194
  try {
195
- return fs.readdirSync(dir);
195
+ return Kt.readdirSync(dir);
196
196
  } catch {
197
197
  return [];
198
198
  }
199
199
  }
200
200
  function safeRead(path) {
201
201
  try {
202
- return fs.readFileSync(path, "utf8").trim();
202
+ return Kt.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
- fs.accessSync(path, fs.constants.R_OK | fs.constants.W_OK);
216
+ Kt.accessSync(path, Kt.constants.R_OK | Kt.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 fs.existsSync(path);
224
+ return Kt.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$1 from "node:fs";
6
+ import * as fs 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$1.existsSync(filePath) && fs$1.statSync(filePath).size > 0;
162
+ return fs.existsSync(filePath) && fs.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$1.existsSync(destPath)) return destPath;
272
+ if (fs.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$1.mkdirSync(path$1.dirname(destPath), { recursive: true });
276
+ fs.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$1.createWriteStream(tmpPath);
318
+ const fileStream = fs.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$1.renameSync(tmpPath, destPath);
336
+ fs.renameSync(tmpPath, destPath);
337
337
  return destPath;
338
338
  } catch (err) {
339
339
  try {
340
- fs$1.unlinkSync(tmpPath);
340
+ fs.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$1.existsSync(destPath)) return {
371
+ if (fs.existsSync(destPath)) return {
372
372
  filePath: destPath,
373
373
  downloadedBytes: 0,
374
374
  fromCache: true
375
375
  };
376
- fs$1.mkdirSync(destDir, { recursive: true });
376
+ fs.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$1.unlinkSync(destPath);
384
+ fs.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$1.statSync(destPath).size,
390
+ downloadedBytes: fs.statSync(destPath).size,
391
391
  fromCache: false
392
392
  };
393
393
  } catch (e) {
394
394
  lastError = e;
395
- if (fs$1.existsSync(destPath)) fs$1.unlinkSync(destPath);
395
+ if (fs.existsSync(destPath)) fs.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$1.createReadStream(filePath);
402
+ const stream = fs.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$1.rmSync(tmpDir, {
427
+ fs.rmSync(tmpDir, {
428
428
  recursive: true,
429
429
  force: true
430
430
  });
431
- fs$1.mkdirSync(tmpDir, { recursive: true });
431
+ fs.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$1.mkdirSync(path$1.dirname(destPath), { recursive: true });
436
+ fs.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$1.statSync(destPath).size;
440
+ totalDownloaded += fs.statSync(destPath).size;
441
441
  }
442
- fs$1.rmSync(destDir, {
442
+ fs.rmSync(destDir, {
443
443
  recursive: true,
444
444
  force: true
445
445
  });
446
- fs$1.renameSync(tmpDir, destDir);
446
+ fs.renameSync(tmpDir, destDir);
447
447
  } catch (err) {
448
- fs$1.rmSync(tmpDir, {
448
+ fs.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$1.readFileSync(revisionRecordPath(modelPath), "utf8").trim();
480
+ return fs.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$1.writeFileSync(tmp, `${revision}\n`);
545
- fs$1.renameSync(tmp, record);
544
+ fs.writeFileSync(tmp, `${revision}\n`);
545
+ fs.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$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;
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;
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$1.rmSync(part.staged, { force: true });
589
+ fs.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$1.rmSync(part.staged, { force: true });
593
+ for (const part of parts) fs.rmSync(part.staged, { force: true });
594
594
  throw err;
595
595
  }
596
- for (const part of parts) fs$1.renameSync(part.staged, part.dest);
596
+ for (const part of parts) fs.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$1.existsSync(modelPath)) if (formatEntry.isDirectory && !fs$1.existsSync(path$1.join(modelPath, "Manifest.json"))) fs$1.rmSync(modelPath, {
611
+ if (fs.existsSync(modelPath)) if (formatEntry.isDirectory && !fs.existsSync(path$1.join(modelPath, "Manifest.json"))) fs.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$1.mkdirSync(modelsDir, { recursive: true });
618
+ fs.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$1.existsSync(modelPath)) return false;
676
+ if (!modelPath || !fs.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$1.existsSync(modelPath)) return false;
684
- fs$1.rmSync(revisionRecordPath(modelPath), { force: true });
683
+ if (!modelPath || !fs.existsSync(modelPath)) return false;
684
+ fs.rmSync(revisionRecordPath(modelPath), { force: true });
685
685
  const formatEntry = entry.formats[format];
686
- if (formatEntry?.isDirectory) fs$1.rmSync(modelPath, {
686
+ if (formatEntry?.isDirectory) fs.rmSync(modelPath, {
687
687
  recursive: true,
688
688
  force: true
689
689
  });
690
690
  else {
691
- fs$1.unlinkSync(modelPath);
691
+ fs.unlinkSync(modelPath);
692
692
  if (formatEntry) for (const sibling of siblingFilesFor(formatEntry)) {
693
693
  const sibPath = path$1.join(modelsDir, sibling);
694
- if (fs$1.existsSync(sibPath)) fs$1.unlinkSync(sibPath);
694
+ if (fs.existsSync(sibPath)) fs.unlinkSync(sibPath);
695
695
  }
696
696
  }
697
697
  return true;
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-DLVfdGSW.js");
1
+ const require_dist = require("./dist-BDixk7cu.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
@@ -1,4 +1,4 @@
1
- import { H as DEVICE_SAN_CREDENTIAL_PREFIX, U as DEVICE_SAN_USER_PREFIX, ls as buildSecretRef } from "./dist-BhR34kF8.mjs";
1
+ import { H as DEVICE_SAN_CREDENTIAL_PREFIX, U as DEVICE_SAN_USER_PREFIX, ls as buildSecretRef } from "./dist-C_SNsYGY.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
@@ -8237,7 +8237,7 @@ function sleep(ms) {
8237
8237
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
8238
8238
  }
8239
8239
  //#endregion
8240
- //#region ../types/dist/composition-CRNwcFYY.mjs
8240
+ //#region ../types/dist/composition-pOHbTzRB.mjs
8241
8241
  var AUDIO_ENCODER_BY_CODEC = {
8242
8242
  opus: "libopus",
8243
8243
  aac: "aac",
@@ -8875,6 +8875,7 @@ function evaluateDwell(activeRaw, onForMsRaw, offForMsRaw, call, nowMs, hooks) {
8875
8875
  const active = asBoolean(activeRaw, "dwell", 0);
8876
8876
  const onForMs = asNonNegativeMs(onForMsRaw, "dwell", 1);
8877
8877
  const offForMs = asNonNegativeMs(offForMsRaw, "dwell", 2);
8878
+ call.transition = null;
8878
8879
  if (call.latched === null) {
8879
8880
  if (call.seenSince === null) call.seenSince = nowMs;
8880
8881
  const delay = active ? onForMs : offForMs;
@@ -8885,20 +8886,52 @@ function evaluateDwell(activeRaw, onForMsRaw, offForMsRaw, call, nowMs, hooks) {
8885
8886
  hooks?.noteDeadline?.(call.seenSince + delay);
8886
8887
  return null;
8887
8888
  }
8888
- if (active === call.latched) {
8889
- call.pendingSince = null;
8890
- return call.latched;
8891
- }
8889
+ if (active === call.latched) return holdAgainstReturn(call, active, onForMs, nowMs, hooks);
8890
+ call.returnSince = null;
8892
8891
  if (call.pendingSince === null) call.pendingSince = nowMs;
8893
8892
  const delay = active ? onForMs : offForMs;
8894
- if (nowMs - call.pendingSince >= delay) {
8895
- call.latched = active;
8896
- call.pendingSince = null;
8897
- return call.latched;
8898
- }
8893
+ if (nowMs - call.pendingSince >= delay) return flip(call, active, call.pendingSince);
8899
8894
  hooks?.noteDeadline?.(call.pendingSince + delay);
8900
8895
  return call.latched;
8901
8896
  }
8897
+ function flip(call, to, startedAt) {
8898
+ const transition = {
8899
+ value: to,
8900
+ startedAt
8901
+ };
8902
+ call.latched = to;
8903
+ call.pendingSince = null;
8904
+ call.returnSince = null;
8905
+ call.transition = transition;
8906
+ return to;
8907
+ }
8908
+ /**
8909
+ * The input is on the latched side. Without a pending transition that is the
8910
+ * steady state. A pending ON is dropped at once (a start needs `onForMs` of
8911
+ * unbroken activity). A pending OFF survives a return until the return has held
8912
+ * `onForMs`: a shorter one (an anti-crease pulse) must not re-arm a finished
8913
+ * run, and the original deadline still fires once the input is off again.
8914
+ */
8915
+ function holdAgainstReturn(call, latched, onForMs, nowMs, hooks) {
8916
+ if (call.pendingSince === null) {
8917
+ call.returnSince = null;
8918
+ return latched;
8919
+ }
8920
+ if (!latched) {
8921
+ call.pendingSince = null;
8922
+ call.returnSince = null;
8923
+ return latched;
8924
+ }
8925
+ if (call.returnSince === null) call.returnSince = nowMs;
8926
+ const returnDeadline = call.returnSince + onForMs;
8927
+ if (nowMs >= returnDeadline) {
8928
+ call.pendingSince = null;
8929
+ call.returnSince = null;
8930
+ return latched;
8931
+ }
8932
+ hooks?.noteDeadline?.(returnDeadline);
8933
+ return latched;
8934
+ }
8902
8935
  /**
8903
8936
  * `schmitt(x, high, low[, onForMs, offForMs])`: true once `x >= high`, false
8904
8937
  * once `x <= low`, and the last answer in between. A transition waits its delay
@@ -8935,7 +8968,7 @@ function evaluateSchmitt(args, call, nowMs, seed, hooks) {
8935
8968
  return call.latched;
8936
8969
  }
8937
8970
  /** `latchedAt(value)`: epoch ms when `value` last changed; null clears the stamp. */
8938
- function evaluateLatchedAt(value, call, nowMs) {
8971
+ function evaluateLatchedAt(value, call, nowMs, dwellTransition = null) {
8939
8972
  if (value === null) {
8940
8973
  call.last = null;
8941
8974
  call.at = null;
@@ -8944,7 +8977,7 @@ function evaluateLatchedAt(value, call, nowMs) {
8944
8977
  if (typeof value !== "boolean" && typeof value !== "number" && typeof value !== "string") return call.at;
8945
8978
  if (call.last !== value) {
8946
8979
  call.last = value;
8947
- call.at = nowMs;
8980
+ call.at = dwellTransition?.value === false && value === false ? dwellTransition.startedAt : nowMs;
8948
8981
  }
8949
8982
  return call.at;
8950
8983
  }
@@ -9673,6 +9706,7 @@ function createStatefulExpressionMemory() {
9673
9706
  return {
9674
9707
  calls: /* @__PURE__ */ new Map(),
9675
9708
  acceptedEdgeAt: null,
9709
+ dwellTransition: null,
9676
9710
  disarmRoseNext: false
9677
9711
  };
9678
9712
  }
@@ -9680,6 +9714,7 @@ function cloneStatefulExpressionMemory(memory) {
9680
9714
  return {
9681
9715
  calls: new Map([...memory.calls].map(([path, call]) => [path, { ...call }])),
9682
9716
  acceptedEdgeAt: memory.acceptedEdgeAt,
9717
+ dwellTransition: memory.dwellTransition,
9683
9718
  disarmRoseNext: memory.disarmRoseNext
9684
9719
  };
9685
9720
  }
@@ -9709,11 +9744,15 @@ function evaluateStatefulExpressionCall(invocation, memory, env, hooks) {
9709
9744
  const call = existing?.kind === "dwell" ? existing : {
9710
9745
  kind: "dwell",
9711
9746
  pendingSince: null,
9747
+ returnSince: null,
9748
+ transition: null,
9712
9749
  latched: typeof env.currentOutput === "boolean" ? env.currentOutput : null,
9713
9750
  seenSince: null
9714
9751
  };
9715
9752
  memory.calls.set(invocation.path, call);
9716
- return evaluateDwell(invocation.args[0], invocation.args[1], invocation.args[2], call, env.nowMs, hooks);
9753
+ const dwelled = evaluateDwell(invocation.args[0], invocation.args[1], invocation.args[2], call, env.nowMs, hooks);
9754
+ memory.dwellTransition = call.transition;
9755
+ return dwelled;
9717
9756
  }
9718
9757
  case "schmitt": {
9719
9758
  const call = existing?.kind === "schmitt" ? existing : {
@@ -9732,7 +9771,9 @@ function evaluateStatefulExpressionCall(invocation, memory, env, hooks) {
9732
9771
  at: null
9733
9772
  };
9734
9773
  memory.calls.set(invocation.path, call);
9735
- return evaluateLatchedAt(invocation.args[0], call, env.nowMs);
9774
+ const stamped = evaluateLatchedAt(invocation.args[0], call, env.nowMs, memory.dwellTransition);
9775
+ memory.dwellTransition = null;
9776
+ return stamped;
9736
9777
  }
9737
9778
  }
9738
9779
  }
@@ -54645,6 +54686,9 @@ var RunningProposalEvidenceSchema = zod.z.object({
54645
54686
  runsFound: zod.z.number().int().nonnegative(),
54646
54687
  pausesFound: zod.z.number().int().nonnegative(),
54647
54688
  longestPauseMs: zod.z.number().nonnegative(),
54689
+ /** Episodes shorter than ~90 s (an anti-crease pulse, a display waking): never a run, never a pause. */
54690
+ pulsesFound: zod.z.number().int().nonnegative(),
54691
+ longestPulseMs: zod.z.number().nonnegative(),
54648
54692
  idleFloorW: zod.z.number(),
54649
54693
  noiseCeilingW: zod.z.number(),
54650
54694
  plateauW: zod.z.number(),
@@ -92725,11 +92769,15 @@ zod.z.discriminatedUnion("kind", [zod.z.object({
92725
92769
  * 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
92726
92770
  * near F. A device that is not near one level most of the time has no floor.
92727
92771
  * 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
92728
- * 3. gaps between episodes split in two by the largest log-scale jump (>= 3x):
92729
- * the short ones are pauses INSIDE a run (a soak), the long ones separate runs.
92772
+ * 3. an episode shorter than `PULSE_MAX_MS` is a PULSE (an anti-crease tumble, a
92773
+ * display waking): it is neither a run nor a pause. Among the remaining
92774
+ * episodes, gaps over `PAUSE_MAX_MS` always separate runs; the rest split in
92775
+ * two by the largest log-scale jump (>= 3x): the short ones are pauses INSIDE
92776
+ * a run (a soak), the long ones separate runs. A stretch under `MIN_RUN_MS`
92777
+ * is no run.
92730
92778
  * 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
92731
- * grid a person would type; stop dwell covers the longest pause; start dwell
92732
- * covers the longest standby blip above T.
92779
+ * grid a person would type; stop dwell covers the longest pause and the
92780
+ * kind's floor; start dwell covers the longest pulse and standby blip above T.
92733
92781
  * 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
92734
92782
  * run must hold exactly one true interval and nothing may flap outside.
92735
92783
  */
@@ -92748,6 +92796,17 @@ var STOP_FACTOR = 1.5;
92748
92796
  var STOP_STEP_MS = 30 * SECOND_MS;
92749
92797
  var STOP_MIN_MS = 60 * SECOND_MS;
92750
92798
  var STOP_MAX_MS = 20 * MINUTE_MS$1;
92799
+ /** An episode shorter than this is a pulse: the start dwell is held above it. */
92800
+ var PULSE_MAX_MS = 90 * SECOND_MS;
92801
+ 30 * MINUTE_MS$1;
92802
+ /** A stretch above the threshold shorter than this is a pulse, not a run. */
92803
+ var MIN_RUN_MS = 10 * MINUTE_MS$1;
92804
+ /** What a kind needs at least before it is called stopped: a soak pause is longer for a washer. */
92805
+ var STOP_FLOOR_BY_KIND = {
92806
+ [DeviceType.Dryer]: 3 * MINUTE_MS$1,
92807
+ [DeviceType.Dishwasher]: 3 * MINUTE_MS$1,
92808
+ [DeviceType.Washer]: 10 * MINUTE_MS$1
92809
+ };
92751
92810
  var START_STEP_MS = 10 * SECOND_MS;
92752
92811
  var START_MIN_MS = 10 * SECOND_MS;
92753
92812
  var STOP_WALK_STEPS = 6;
@@ -92804,17 +92863,25 @@ function proposeRunningThreshold(series) {
92804
92863
  const active = segments.filter((s) => s.value > coarse);
92805
92864
  const episodes = mergeContiguous(active);
92806
92865
  if (durationOf(active) < MIN_ACTIVE_MS || episodes.length === 0) return insufficient("no-runs", 0);
92807
- const { runs, pauses, betweenGaps } = splitRuns(episodes);
92866
+ const pulseEpisodes = episodes.filter((e) => e.end - e.start < PULSE_MAX_MS);
92867
+ const split = splitRuns(episodes.filter((e) => e.end - e.start >= PULSE_MAX_MS));
92868
+ const runs = split.runs.filter((r) => r.end - r.start >= MIN_RUN_MS);
92869
+ const { pauses, betweenGaps } = split;
92870
+ const pulsesFound = pulseEpisodes.length + (split.runs.length - runs.length);
92871
+ const longestPulse = maxOf(pulseEpisodes.map((e) => e.end - e.start));
92872
+ if (runs.length === 0) return insufficient("no-runs", 0);
92808
92873
  const plateau = weightedQuantile(weigh(active.filter((s) => runs.some((r) => s.start < r.end && s.end > r.start))), PLATEAU_QUANTILE);
92809
92874
  const threshold = pickThreshold(noise, plateau);
92810
92875
  if (threshold === null) return insufficient("no-separation", runs.length);
92811
92876
  const notes = [];
92812
92877
  const longestPause = pauses.length === 0 ? 0 : Math.max(...pauses);
92813
- let stop = clamp(roundUp(STOP_FACTOR * longestPause, STOP_STEP_MS), STOP_MIN_MS, STOP_MAX_MS);
92878
+ const stopFloor = series.deviceType === void 0 ? STOP_MIN_MS : STOP_FLOOR_BY_KIND[series.deviceType] ?? STOP_MIN_MS;
92879
+ let stop = clamp(Math.max(stopFloor, roundUp(STOP_FACTOR * longestPause, STOP_STEP_MS)), STOP_MIN_MS, STOP_MAX_MS);
92814
92880
  const shortestGap = betweenGaps.length === 0 ? null : Math.min(...betweenGaps);
92815
- if (shortestGap !== null && stop > shortestGap / 2) notes.push("stop-dwell-exceeds-half-of-shortest-gap");
92881
+ if (shortestGap !== null && stop >= shortestGap) notes.push("stop-dwell-exceeds-shortest-gap");
92816
92882
  const blips = excursionsOutside(segments, threshold, runs);
92817
92883
  let start = Math.max(START_MIN_MS, roundUp(STOP_FACTOR * maxOf(blips), START_STEP_MS));
92884
+ if (pulsesFound > 0) start = Math.max(start, PULSE_MAX_MS);
92818
92885
  const shortestRun = Math.min(...runs.map((r) => r.end - r.start));
92819
92886
  if (start > shortestRun / 2) {
92820
92887
  notes.push("start-dwell-exceeds-half-of-shortest-run");
@@ -92844,6 +92911,8 @@ function proposeRunningThreshold(series) {
92844
92911
  runsFound: runs.length,
92845
92912
  pausesFound: pauses.length,
92846
92913
  longestPauseMs: longestPause,
92914
+ pulsesFound,
92915
+ longestPulseMs: longestPulse,
92847
92916
  idleFloorW: idleFloor,
92848
92917
  noiseCeilingW: noise,
92849
92918
  plateauW: plateau,
@@ -92928,8 +92997,9 @@ function mergeContiguous(segments) {
92928
92997
  }
92929
92998
  /**
92930
92999
  * Gaps between episodes: the largest log-scale jump (>= 3x) in the sorted gaps
92931
- * separates pauses inside a run from the gaps between runs. No jump: every gap
92932
- * separates runs — a lone pause is indistinguishable from a short standby.
93000
+ * separates pauses inside a run from the gaps between runs, but a pause is never
93001
+ * longer than `PAUSE_MAX_MS`: a cut above it is not taken. No jump: every gap separates
93002
+ * runs - a lone pause is indistinguishable from a short standby.
92933
93003
  */
92934
93004
  function splitRuns(episodes) {
92935
93005
  const gaps = episodes.slice(1).map((e, i) => e.start - (episodes[i]?.end ?? e.start));
@@ -92940,7 +93010,7 @@ function splitRuns(episodes) {
92940
93010
  const lo = sorted[i] ?? 0;
92941
93011
  const hi = sorted[i + 1] ?? 0;
92942
93012
  const ratio = lo > 0 ? hi / lo : Number.POSITIVE_INFINITY;
92943
- if (ratio >= best) {
93013
+ if (ratio >= best && lo <= 18e5) {
92944
93014
  best = ratio;
92945
93015
  cut = lo;
92946
93016
  }
@@ -92984,17 +93054,21 @@ function pickThreshold(noise, plateau) {
92984
93054
  function excursionsOutside(segments, threshold, runs) {
92985
93055
  return mergeContiguous(segments.filter((s) => s.value >= threshold)).filter((h) => !runs.some((r) => h.start < r.end && h.end > r.start)).map((h) => h.end - h.start);
92986
93056
  }
92987
- /** Drive the real `dwell` evaluation over the series, deadlines included. */
92988
93057
  function replayDwell(segments, to, threshold, startMs, stopMs, runs) {
93058
+ return judge(runDwell(segments, to, threshold, startMs, stopMs), runs);
93059
+ }
93060
+ function runDwell(segments, to, threshold, startMs, stopMs) {
92989
93061
  const call = {
92990
93062
  kind: "dwell",
92991
93063
  pendingSince: null,
93064
+ returnSince: null,
92992
93065
  latched: null,
92993
- seenSince: null
93066
+ seenSince: null,
93067
+ transition: null
92994
93068
  };
92995
93069
  let deadline = null;
92996
93070
  const hooks = { noteDeadline: (at) => {
92997
- deadline = at;
93071
+ deadline = deadline === null ? at : Math.min(deadline, at);
92998
93072
  } };
92999
93073
  const intervals = [];
93000
93074
  let openAt = null;
@@ -93020,7 +93094,7 @@ function replayDwell(segments, to, threshold, startMs, stopMs, runs) {
93020
93094
  start: openAt,
93021
93095
  end: to
93022
93096
  });
93023
- return judge(intervals, runs);
93097
+ return intervals;
93024
93098
  }
93025
93099
  function judge(intervals, runs) {
93026
93100
  const hits = (i, r) => i.start < r.end && i.end > r.start;
@@ -93398,6 +93472,7 @@ function expressionOutcome(source, read, now, stateful) {
93398
93472
  continue;
93399
93473
  }
93400
93474
  values[name] = reading.value;
93475
+ if (reading.state === "fresh" && reading.transition !== void 0 && stateful !== void 0) stateful.expressionMemory.dwellTransition = reading.transition;
93401
93476
  if (reading.state === "stale") staleReasons.push(`\`${name}\`: ${reading.reason}`);
93402
93477
  }
93403
93478
  const unavailable = fatalUnavailable ?? nonFatalUnavailable;
@@ -93430,6 +93505,8 @@ function expressionOutcome(source, read, now, stateful) {
93430
93505
  nowMs: now
93431
93506
  }, hooks) }
93432
93507
  });
93508
+ const transition = stateful?.expressionMemory.dwellTransition ?? null;
93509
+ if (stateful !== void 0) stateful.expressionMemory.dwellTransition = null;
93433
93510
  if (!result.ok) return {
93434
93511
  state: "unavailable",
93435
93512
  value: null,
@@ -93442,7 +93519,8 @@ function expressionOutcome(source, read, now, stateful) {
93442
93519
  state: staleReasons.length > 0 ? "stale" : "fresh",
93443
93520
  value: result.value,
93444
93521
  reason: staleReasons.length > 0 ? staleReasons.join("; ") : null,
93445
- deadline: deadlines.length > 0 ? Math.min(...deadlines) : null
93522
+ deadline: deadlines.length > 0 ? Math.min(...deadlines) : null,
93523
+ ...transition === null ? {} : { transition }
93446
93524
  };
93447
93525
  }
93448
93526
  function aggregateRead(reading) {