@camstack/server 1.2.787 → 1.2.789

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 (93) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/core/addon/addon-registry.service.js +12 -15
  3. package/dist/core/addon/boot-health-snapshot.js +42 -0
  4. package/dist/core/addon/hub-spawn-gate.js +1 -0
  5. package/package.json +15 -39
  6. package/system/dist/addon-utils.mjs +1 -1
  7. package/system/dist/{agent-https--lvZp4PX.js → agent-https-jJDe-XNl.js} +1 -1
  8. package/system/dist/{agent-https-pSCzmbQd.mjs → agent-https-szf2FU49.mjs} +1 -1
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  10. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  12. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
  13. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  14. package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
  15. package/system/dist/builtins/autotrack/index.js +1 -1
  16. package/system/dist/builtins/autotrack/index.mjs +1 -1
  17. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  18. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
  19. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  20. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  21. package/system/dist/builtins/camera-grid/index.js +1 -1
  22. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  23. package/system/dist/builtins/composer/composer.addon.js +3 -3
  24. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  25. package/system/dist/builtins/console-logging/index.js +1 -1
  26. package/system/dist/builtins/console-logging/index.mjs +1 -1
  27. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  28. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  29. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  30. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  31. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  32. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  33. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  34. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  35. package/system/dist/builtins/keychain/index.js +4 -4
  36. package/system/dist/builtins/keychain/index.mjs +4 -4
  37. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  38. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  39. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  40. package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
  41. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  42. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  43. package/system/dist/builtins/loki-logging/index.js +1 -1
  44. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  45. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  46. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
  47. package/system/dist/builtins/platform-probe/index.js +1 -1
  48. package/system/dist/builtins/platform-probe/index.mjs +10 -10
  49. package/system/dist/builtins/record-entries/index.js +1 -1
  50. package/system/dist/builtins/record-entries/index.mjs +1 -1
  51. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  52. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  53. package/system/dist/builtins/snapshot/index.js +1 -1
  54. package/system/dist/builtins/snapshot/index.mjs +1 -1
  55. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  56. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
  57. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  58. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  59. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  60. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  61. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  62. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  63. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  64. package/system/dist/builtins/system-config/system-config.addon.mjs +285 -285
  65. package/system/dist/builtins/winston-logging/index.js +1 -1
  66. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  67. package/system/dist/{capture-engine-N1-UaQr0.mjs → capture-engine-BsKY_3xa.mjs} +1 -1
  68. package/system/dist/{capture-engine-CTFHb-UX.js → capture-engine-DNHgjQot.js} +1 -1
  69. package/system/dist/{composition-sources-Qe3MRI1x.mjs → composition-sources-BRdGsbVT.mjs} +1 -1
  70. package/system/dist/{composition-sources-Yjz-b6-8.js → composition-sources-BgO0GQYW.js} +1 -1
  71. package/system/dist/{constants-7gannWcO.js → constants-C3jGKQSQ.js} +1 -1
  72. package/system/dist/{constants-lWMAnwmj.mjs → constants-CQeMrR4f.mjs} +1 -1
  73. package/system/dist/{coral-accelerators-BW3OcrLD.mjs → coral-accelerators-DBlgWB8k.mjs} +6 -6
  74. package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
  75. package/system/dist/{device-ca-8lpRo9Ss.mjs → device-ca-ByVi5eUC.mjs} +1 -1
  76. package/system/dist/{device-ca-HGx3Pwb6.js → device-ca-D3y6wGmn.js} +1 -1
  77. package/system/dist/{dist-j7uy5oG9.js → dist-BRI-Mwx0.js} +69 -31
  78. package/system/dist/{dist-DgZrPBbX.mjs → dist-BsQA6-0i.mjs} +69 -31
  79. package/system/dist/file-host-worker.js +1 -1
  80. package/system/dist/file-host-worker.mjs +1 -1
  81. package/system/dist/{hub-mdns-ciao-BM3peDu1.mjs → hub-mdns-ciao-8dJTW2LI.mjs} +2 -2
  82. package/system/dist/{hub-mdns-ciao-BUKHJL6N.js → hub-mdns-ciao-Ry_Jpljx.js} +2 -2
  83. package/system/dist/index.js +53 -11
  84. package/system/dist/index.mjs +264 -222
  85. package/system/dist/kernel/addon-health-monitor.d.ts +21 -0
  86. package/system/dist/{legacy-integration-rows-door-DIm4Q3Jj.mjs → legacy-integration-rows-door-CjXTbmvH.mjs} +1 -1
  87. package/system/dist/{legacy-integration-rows-door-D51X6Fdr.js → legacy-integration-rows-door-D5BdSNla.js} +1 -1
  88. package/system/dist/migrations/hub/2026-11-06-addon-settings-bare-rows.d.ts +3 -0
  89. package/system/dist/{restore-archive-8jRnSzmw.js → restore-archive-GoWJMdHy.js} +1 -1
  90. package/system/dist/{restore-archive-D-Wmp8OK.mjs → restore-archive-vn4co_kf.mjs} +150 -150
  91. package/system/dist/{wal-maintenance-CBnqPn4u.mjs → wal-maintenance-CadfiGWy.mjs} +0 -0
  92. package/system/dist/{wal-maintenance-D0FMnpba.js → wal-maintenance-sSlXJm4k.js} +0 -0
  93. 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-j7uy5oG9.js");
6
+ const require_dist = require("../../dist-BRI-Mwx0.js");
7
7
  const require_formatter = require("../../formatter-xbxeV4GD.js");
8
8
  const require_log_file_read_protocol = require("../../log-file-read-protocol-DSV_vQRb.js");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { Lo as BaseAddon, fi as logDestinationCapability } from "../../dist-DgZrPBbX.mjs";
1
+ import { Lo as BaseAddon, fi as logDestinationCapability } from "../../dist-BsQA6-0i.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-hTaAsYlX.mjs";
4
4
  import { createRequire } from "node:module";
@@ -1,4 +1,4 @@
1
- import { Ko as HISTORY_DEFAULT_MIN_INTERVAL_MS, wc as DeviceType, zs as historyItemFieldPath } from "./dist-DgZrPBbX.mjs";
1
+ import { Ko as HISTORY_DEFAULT_MIN_INTERVAL_MS, wc as DeviceType, zs as historyItemFieldPath } from "./dist-BsQA6-0i.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
- const require_dist = require("./dist-j7uy5oG9.js");
1
+ const require_dist = require("./dist-BRI-Mwx0.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 { Tc as errMsg, yo as compositionSourceKey } from "./dist-DgZrPBbX.mjs";
1
+ import { Tc as errMsg, yo as compositionSourceKey } from "./dist-BsQA6-0i.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-j7uy5oG9.js");
1
+ const require_dist = require("./dist-BRI-Mwx0.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-j7uy5oG9.js").buildSecretRef({
2
+ var MESH_CA_KEY_REF = require("./dist-BRI-Mwx0.js").buildSecretRef({
3
3
  owner: "system",
4
4
  scope: { kind: "global" },
5
5
  fieldPath: "meshCaKey"
@@ -1,4 +1,4 @@
1
- import { Cs as buildSecretRef } from "./dist-DgZrPBbX.mjs";
1
+ import { Cs as buildSecretRef } from "./dist-BsQA6-0i.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
  }
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- import * as fs from "node:fs";
2
+ import * as fs$1 from "node:fs";
3
3
  import { createReadStream, promises } from "node:fs";
4
4
  import * as path$1 from "node:path";
5
5
  import path from "node:path";
@@ -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 { Cs as buildSecretRef, G as DEVICE_SAN_USER_PREFIX, W as DEVICE_SAN_CREDENTIAL_PREFIX } from "./dist-DgZrPBbX.mjs";
1
+ import { Cs as buildSecretRef, G as DEVICE_SAN_USER_PREFIX, W as DEVICE_SAN_CREDENTIAL_PREFIX } from "./dist-BsQA6-0i.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-j7uy5oG9.js");
1
+ const require_dist = require("./dist-BRI-Mwx0.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
@@ -1171,7 +1171,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1171
1171
  return DeviceRole;
1172
1172
  }({});
1173
1173
  //#endregion
1174
- //#region ../types/dist/sleep-CdKka2ri.mjs
1174
+ //#region ../types/dist/sleep-D7ZKm4nb.mjs
1175
1175
  /**
1176
1176
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1177
1177
  * window to float samples (D455).
@@ -1944,10 +1944,33 @@ function integrationRowsApiOver(api) {
1944
1944
  };
1945
1945
  }
1946
1946
  var PREFIX = "records/";
1947
+ /**
1948
+ * Cross-realm brand. An addon bundles its own copy of this module (D15) while
1949
+ * `ctx.records` is the HOST's door, so an error thrown by the host is an
1950
+ * instance of the host's classes, not of the addon's. The brand plus the code
1951
+ * make `instanceof` answer by identity of the failure, not of the copy.
1952
+ */
1953
+ var RECORDS_ERROR_BRAND = Symbol.for("camstack.records-error");
1954
+ function carriesBrand(value) {
1955
+ return typeof value === "object" && value !== null && Reflect.get(value, RECORDS_ERROR_BRAND) === true;
1956
+ }
1947
1957
  /** The base of every records failure. `detail` is the human part of the message. */
1948
1958
  var RecordsError = class extends Error {
1959
+ /** The code a subclass stands for; the base stands for every code. */
1960
+ static code = void 0;
1961
+ /**
1962
+ * `instanceof` across copies of this module: any branded error is a
1963
+ * `RecordsError`, and is an instance of a subclass only when its code is the
1964
+ * subclass's code. Same-copy answers are unchanged.
1965
+ */
1966
+ static [Symbol.hasInstance](value) {
1967
+ if (Function.prototype[Symbol.hasInstance].call(this, value)) return true;
1968
+ if (!carriesBrand(value)) return false;
1969
+ return this.code === void 0 || value.code === this.code;
1970
+ }
1949
1971
  code;
1950
1972
  detail;
1973
+ [RECORDS_ERROR_BRAND] = true;
1951
1974
  constructor(code, detail) {
1952
1975
  super(`${PREFIX}${code}: ${detail}`);
1953
1976
  this.name = "RecordsError";
@@ -1956,96 +1979,110 @@ var RecordsError = class extends Error {
1956
1979
  }
1957
1980
  };
1958
1981
  /** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
1959
- var RevConflictError = class extends RecordsError {
1982
+ var RevConflictError = class RevConflictError extends RecordsError {
1983
+ static code = "rev-conflict";
1960
1984
  constructor(detail) {
1961
- super("rev-conflict", detail);
1985
+ super(RevConflictError.code, detail);
1962
1986
  this.name = "RevConflictError";
1963
1987
  }
1964
1988
  };
1965
1989
  /** `data` exceeds the kind's `maxDataBytes`. Bytes are never record fields (D613). */
1966
- var RecordTooLargeError = class extends RecordsError {
1990
+ var RecordTooLargeError = class RecordTooLargeError extends RecordsError {
1991
+ static code = "too-large";
1967
1992
  constructor(detail) {
1968
- super("too-large", detail);
1993
+ super(RecordTooLargeError.code, detail);
1969
1994
  this.name = "RecordTooLargeError";
1970
1995
  }
1971
1996
  };
1972
1997
  /** A filter, order or aggregate names a field no declared index serves. */
1973
- var UnindexedFilterError = class extends RecordsError {
1998
+ var UnindexedFilterError = class UnindexedFilterError extends RecordsError {
1999
+ static code = "unindexed-filter";
1974
2000
  constructor(detail) {
1975
- super("unindexed-filter", detail);
2001
+ super(UnindexedFilterError.code, detail);
1976
2002
  this.name = "UnindexedFilterError";
1977
2003
  }
1978
2004
  };
1979
2005
  /** A bulk delete with no predicate at all. */
1980
- var FilterRequiredError = class extends RecordsError {
2006
+ var FilterRequiredError = class FilterRequiredError extends RecordsError {
2007
+ static code = "filter-required";
1981
2008
  constructor(detail) {
1982
- super("filter-required", detail);
2009
+ super(FilterRequiredError.code, detail);
1983
2010
  this.name = "FilterRequiredError";
1984
2011
  }
1985
2012
  };
1986
2013
  /** The caller declared no such kind (another addon's kind is indistinguishable from none). */
1987
- var UnknownRecordKindError = class extends RecordsError {
2014
+ var UnknownRecordKindError = class UnknownRecordKindError extends RecordsError {
2015
+ static code = "unknown-kind";
1988
2016
  constructor(detail) {
1989
- super("unknown-kind", detail);
2017
+ super(UnknownRecordKindError.code, detail);
1990
2018
  this.name = "UnknownRecordKindError";
1991
2019
  }
1992
2020
  };
1993
- var RecordNotFoundError = class extends RecordsError {
2021
+ var RecordNotFoundError = class RecordNotFoundError extends RecordsError {
2022
+ static code = "not-found";
1994
2023
  constructor(detail) {
1995
- super("not-found", detail);
2024
+ super(RecordNotFoundError.code, detail);
1996
2025
  this.name = "RecordNotFoundError";
1997
2026
  }
1998
2027
  };
1999
2028
  /** A unique index refused the write. */
2000
- var RecordUniqueViolationError = class extends RecordsError {
2029
+ var RecordUniqueViolationError = class RecordUniqueViolationError extends RecordsError {
2030
+ static code = "unique-violation";
2001
2031
  constructor(detail) {
2002
- super("unique-violation", detail);
2032
+ super(RecordUniqueViolationError.code, detail);
2003
2033
  this.name = "RecordUniqueViolationError";
2004
2034
  }
2005
2035
  };
2006
2036
  /** A secret field held a plain string where only a keychain marker may be stored. */
2007
- var PlaintextSecretError = class extends RecordsError {
2037
+ var PlaintextSecretError = class PlaintextSecretError extends RecordsError {
2038
+ static code = "plaintext-secret";
2008
2039
  constructor(detail) {
2009
- super("plaintext-secret", detail);
2040
+ super(PlaintextSecretError.code, detail);
2010
2041
  this.name = "PlaintextSecretError";
2011
2042
  }
2012
2043
  };
2013
2044
  /** A marker whose ref is not the row's own (the D878 rule). */
2014
- var ForeignSecretMarkerError = class extends RecordsError {
2045
+ var ForeignSecretMarkerError = class ForeignSecretMarkerError extends RecordsError {
2046
+ static code = "foreign-marker";
2015
2047
  constructor(detail) {
2016
- super("foreign-marker", detail);
2048
+ super(ForeignSecretMarkerError.code, detail);
2017
2049
  this.name = "ForeignSecretMarkerError";
2018
2050
  }
2019
2051
  };
2020
2052
  /** The keychain could not store or serve a value: explicit, never an empty string. */
2021
- var RecordSecretUnavailableError = class extends RecordsError {
2053
+ var RecordSecretUnavailableError = class RecordSecretUnavailableError extends RecordsError {
2054
+ static code = "secret-unavailable";
2022
2055
  constructor(detail) {
2023
- super("secret-unavailable", detail);
2056
+ super(RecordSecretUnavailableError.code, detail);
2024
2057
  this.name = "RecordSecretUnavailableError";
2025
2058
  }
2026
2059
  };
2027
- var InvalidRecordError = class extends RecordsError {
2060
+ var InvalidRecordError = class InvalidRecordError extends RecordsError {
2061
+ static code = "invalid-record";
2028
2062
  constructor(detail) {
2029
- super("invalid-record", detail);
2063
+ super(InvalidRecordError.code, detail);
2030
2064
  this.name = "InvalidRecordError";
2031
2065
  }
2032
2066
  };
2033
2067
  /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
2034
- var DeclarationRefusedError = class extends RecordsError {
2068
+ var DeclarationRefusedError = class DeclarationRefusedError extends RecordsError {
2069
+ static code = "declaration-refused";
2035
2070
  constructor(detail) {
2036
- super("declaration-refused", detail);
2071
+ super(DeclarationRefusedError.code, detail);
2037
2072
  this.name = "DeclarationRefusedError";
2038
2073
  }
2039
2074
  };
2040
- var NoCallerError = class extends RecordsError {
2075
+ var NoCallerError = class NoCallerError extends RecordsError {
2076
+ static code = "no-caller";
2041
2077
  constructor(detail) {
2042
- super("no-caller", detail);
2078
+ super(NoCallerError.code, detail);
2043
2079
  this.name = "NoCallerError";
2044
2080
  }
2045
2081
  };
2046
- var BatchTooLargeError = class extends RecordsError {
2082
+ var BatchTooLargeError = class BatchTooLargeError extends RecordsError {
2083
+ static code = "batch-too-large";
2047
2084
  constructor(detail) {
2048
- super("batch-too-large", detail);
2085
+ super(BatchTooLargeError.code, detail);
2049
2086
  this.name = "BatchTooLargeError";
2050
2087
  }
2051
2088
  };
@@ -2054,9 +2091,10 @@ var BatchTooLargeError = class extends RecordsError {
2054
2091
  * caller did not declare in ONE file and ONE `transactFamily`. The detail names
2055
2092
  * which rule (`cross-file`, `cross-family`, `no-family`); it is never a silent split.
2056
2093
  */
2057
- var TransactRefusedError = class extends RecordsError {
2094
+ var TransactRefusedError = class TransactRefusedError extends RecordsError {
2095
+ static code = "transact-refused";
2058
2096
  constructor(detail) {
2059
- super("transact-refused", detail);
2097
+ super(TransactRefusedError.code, detail);
2060
2098
  this.name = "TransactRefusedError";
2061
2099
  }
2062
2100
  };