@camstack/system 1.2.457 → 1.2.459

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 (106) hide show
  1. package/dist/addon-runner.js +163 -27
  2. package/dist/addon-runner.mjs +193 -57
  3. package/dist/{agent-https-CoyOZ3pC.js → agent-https-Dnr_nIVx.js} +3 -723
  4. package/dist/{agent-https-CK9Z4sSR.mjs → agent-https-Iw3RSQup.mjs} +4 -616
  5. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  8. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  9. package/dist/builtins/alerts/alerts.addon.js +5 -7
  10. package/dist/builtins/alerts/alerts.addon.mjs +5 -7
  11. package/dist/builtins/alerts/record-kinds.d.ts +1 -1
  12. package/dist/builtins/autotrack/index.js +1 -1
  13. package/dist/builtins/autotrack/index.mjs +1 -1
  14. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +242 -4
  15. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +240 -2
  16. package/dist/builtins/calendars/calendars.addon.js +2 -10
  17. package/dist/builtins/calendars/calendars.addon.mjs +2 -3
  18. package/dist/builtins/calendars/record-kinds.d.ts +1 -1
  19. package/dist/builtins/camera-grid/index.js +1 -1
  20. package/dist/builtins/camera-grid/index.mjs +1 -1
  21. package/dist/builtins/composer/composer.addon.js +2 -2
  22. package/dist/builtins/composer/composer.addon.mjs +2 -2
  23. package/dist/builtins/console-logging/index.js +1 -1
  24. package/dist/builtins/console-logging/index.mjs +1 -1
  25. package/dist/builtins/core-blocks/core-blocks.addon.js +4 -6
  26. package/dist/builtins/core-blocks/core-blocks.addon.mjs +4 -6
  27. package/dist/builtins/device-history/device-history.addon.d.ts +13 -0
  28. package/dist/builtins/device-history/device-history.addon.js +296 -233
  29. package/dist/builtins/device-history/device-history.addon.mjs +296 -233
  30. package/dist/builtins/device-history/ingest/producer-ingest.d.ts +11 -1
  31. package/dist/builtins/device-manager/device-manager.addon.js +2 -4
  32. package/dist/builtins/device-manager/device-manager.addon.mjs +2 -4
  33. package/dist/builtins/hub-forwarder/index.js +1 -1
  34. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  35. package/dist/builtins/keychain/index.js +41 -43
  36. package/dist/builtins/keychain/index.mjs +41 -43
  37. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  38. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  39. package/dist/builtins/local-auth/local-auth.addon.js +24 -40
  40. package/dist/builtins/local-auth/local-auth.addon.mjs +24 -40
  41. package/dist/builtins/local-network/local-network.addon.js +2 -2
  42. package/dist/builtins/local-network/local-network.addon.mjs +2 -2
  43. package/dist/builtins/loki-logging/index.js +1 -1
  44. package/dist/builtins/loki-logging/index.mjs +1 -1
  45. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  46. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  47. package/dist/builtins/native-metrics/node-metrics-history-recorder.d.ts +1 -2
  48. package/dist/builtins/platform-probe/coral-accelerators.d.ts +26 -9
  49. package/dist/builtins/platform-probe/index.js +11 -68
  50. package/dist/builtins/platform-probe/index.mjs +11 -68
  51. package/dist/builtins/record-entries/index.js +1 -1
  52. package/dist/builtins/record-entries/index.mjs +1 -1
  53. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  54. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  55. package/dist/builtins/snapshot/index.js +1 -1
  56. package/dist/builtins/snapshot/index.mjs +1 -1
  57. package/dist/builtins/sqlite-storage/file-host-protocol.d.ts +0 -15
  58. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  59. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  60. package/dist/builtins/sqlite-storage/index.js +1 -1
  61. package/dist/builtins/sqlite-storage/index.mjs +1 -1
  62. package/dist/builtins/sqlite-storage/owned-sqlite-file.d.ts +0 -44
  63. package/dist/builtins/sqlite-storage/records/records-catalog.d.ts +0 -2
  64. package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +0 -21
  65. package/dist/builtins/sqlite-storage/records/records-engine.d.ts +3 -20
  66. package/dist/builtins/sqlite-storage/records/records-provider.d.ts +4 -18
  67. package/dist/builtins/sqlite-storage/records/records-sql.d.ts +1 -1
  68. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +0 -17
  69. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +21 -196
  70. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +21 -196
  71. package/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +6 -14
  72. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +2 -2
  73. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +7 -9
  74. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +7 -9
  75. package/dist/builtins/system-config/system-config.addon.js +667 -40
  76. package/dist/builtins/system-config/system-config.addon.mjs +625 -15
  77. package/dist/builtins/winston-logging/index.js +1 -1
  78. package/dist/builtins/winston-logging/index.mjs +1 -1
  79. package/dist/{composition-sources-B_jeZDRJ.mjs → composition-sources-DNRZWR1j.mjs} +1 -1
  80. package/dist/{composition-sources-qKyvMAvc.js → composition-sources-b0e_2I-D.js} +1 -1
  81. package/dist/{constants-B_X9cWEK.js → constants-6OeJiZgi.js} +1 -1
  82. package/dist/{constants-cxKcZRMi.mjs → constants-BnkOdj9Q.mjs} +1 -1
  83. package/dist/coral-accelerators-Bi_c3Rft.js +175 -0
  84. package/dist/coral-accelerators-DcnZvctM.mjs +162 -0
  85. package/dist/{device-ca-BB6nHAL5.mjs → device-ca-Bnkw8GyU.mjs} +1 -1
  86. package/dist/{device-ca-CVK3YcR_.js → device-ca-CPTDs--d.js} +1 -1
  87. package/dist/{dist-C89nqNnn.js → dist-Bn-RNanh.js} +84 -140
  88. package/dist/{dist-Dhux90yB.mjs → dist-Wy8cTxg6.mjs} +85 -123
  89. package/dist/file-host-worker.js +1 -1
  90. package/dist/file-host-worker.mjs +1 -1
  91. package/dist/{hub-mdns-ciao-B8olZqqd.mjs → hub-mdns-ciao-CJu0nhla.mjs} +2 -2
  92. package/dist/{hub-mdns-ciao-DB1Y9agt.js → hub-mdns-ciao-CTBTlia4.js} +2 -2
  93. package/dist/index.js +32 -58
  94. package/dist/index.mjs +16 -42
  95. package/dist/kernel/hwaccel/hwaccel-resolver.d.ts +7 -3
  96. package/dist/{restore-archive-DyOaPeAr.mjs → restore-archive-CmP-iiG9.mjs} +84 -331
  97. package/dist/{restore-archive-4DOUR5Gu.js → restore-archive-DM1OBYq4.js} +89 -342
  98. package/dist/{wal-maintenance-DVN-DiVP.js → wal-maintenance-DUHEp_09.js} +0 -0
  99. package/dist/{wal-maintenance-BMiX6UIa.mjs → wal-maintenance-NKbwWovZ.mjs} +0 -0
  100. package/package.json +1 -1
  101. package/dist/builtins/records/legacy-table-row-count.d.ts +0 -5
  102. package/dist/builtins/records/phase6-declare-gate.d.ts +0 -28
  103. package/dist/builtins/sqlite-storage/records/count-settings-array-legacy.d.ts +0 -5
  104. package/dist/builtins/sqlite-storage/records/count-settings-brokers-legacy.d.ts +0 -6
  105. package/dist/phase6-declare-gate-BO-_jLh_.js +0 -98
  106. package/dist/phase6-declare-gate-x9ZCbQJP.mjs +0 -93
@@ -7865,6 +7865,166 @@ function ipcParentLink(getCallOut) {
7865
7865
  };
7866
7866
  }
7867
7867
  //#endregion
7868
+ //#region src/builtins/platform-probe/coral-accelerators.ts
7869
+ /**
7870
+ * Coral USB Edge TPU USB identifiers.
7871
+ *
7872
+ * The device enumerates as `1a6e:089a` (Global Unichip) BEFORE the libedgetpu
7873
+ * firmware loads, then re-enumerates as `18d1:9302` (Google) AFTER. Either id
7874
+ * means a Coral is physically attached, so both count as a positive signal.
7875
+ */
7876
+ var CORAL_USB_IDS = [{
7877
+ vendor: "1a6e",
7878
+ product: "089a"
7879
+ }, {
7880
+ vendor: "18d1",
7881
+ product: "9302"
7882
+ }];
7883
+ /** The PCIe / M.2 Coral's PCI function id (Global Unichip "Apex"). */
7884
+ var CORAL_PCI_VENDOR = "0x1ac1";
7885
+ var CORAL_PCI_DEVICE = "0x089a";
7886
+ /** A unit the apex driver bound: `/sys/class/apex/apex_<N>` ↔ `/dev/apex_<N>`. */
7887
+ var APEX_ENTRY = /^apex_(\d+)$/;
7888
+ /**
7889
+ * Default install path of the libedgetpu delegate on the hub, provisioned
7890
+ * out-of-band by `/data/deps/edgetpu-install.sh` (it is a system shared
7891
+ * library, not a pip package). Overridable via `CAMSTACK_EDGETPU_LIB` — kept in
7892
+ * sync with the Python pool's own default in `inference_pool.py`.
7893
+ */
7894
+ var DEFAULT_EDGETPU_LIB = "/data/deps/edgetpu/lib/libedgetpu.so.1";
7895
+ function countUsbCorals(fsx) {
7896
+ let count = 0;
7897
+ for (const device of fsx.listUsbDevices()) {
7898
+ const vendor = fsx.readUsbAttr(device, "idVendor").toLowerCase();
7899
+ const product = fsx.readUsbAttr(device, "idProduct").toLowerCase();
7900
+ if (CORAL_USB_IDS.some((id) => id.vendor === vendor && id.product === product)) count++;
7901
+ }
7902
+ return count;
7903
+ }
7904
+ function countPciCorals(fsx) {
7905
+ let count = 0;
7906
+ for (const device of fsx.listPciDevices()) {
7907
+ const vendor = fsx.readPciAttr(device, "vendor").toLowerCase();
7908
+ const product = fsx.readPciAttr(device, "device").toLowerCase();
7909
+ if (vendor === CORAL_PCI_VENDOR && product === CORAL_PCI_DEVICE) count++;
7910
+ }
7911
+ return count;
7912
+ }
7913
+ /**
7914
+ * PCIe units: each `/sys/class/apex/apex_N` is a unit the driver bound; it is
7915
+ * usable only when `/dev/apex_N` is in this process's view AND opens read/write.
7916
+ * PCI functions with the Coral id beyond the bound units have no driver.
7917
+ */
7918
+ function classifyPci(fsx) {
7919
+ let usable = 0;
7920
+ let notAccessible = 0;
7921
+ for (const entry of fsx.listApexClass()) {
7922
+ const match = APEX_ENTRY.exec(entry);
7923
+ if (match === null) continue;
7924
+ const node = `/dev/apex_${match[1]}`;
7925
+ if (fsx.exists(node) && fsx.canOpen(node)) usable++;
7926
+ else notAccessible++;
7927
+ }
7928
+ const driverMissing = Math.max(0, countPciCorals(fsx) - usable - notAccessible);
7929
+ return {
7930
+ usable,
7931
+ notAccessible,
7932
+ driverMissing
7933
+ };
7934
+ }
7935
+ /**
7936
+ * Detect Coral Edge TPUs on USB and PCIe/M.2.
7937
+ *
7938
+ * - USB: every matching USB device counts (multiple Corals run concurrently).
7939
+ * - PCIe: the apex driver's units, each usable only if its device node opens;
7940
+ * a Coral PCI function the driver did not bind is `driver-missing`.
7941
+ * - Fallback: when NO Coral signal of either bus is visible but the libedgetpu
7942
+ * delegate is installed (a container whose `/sys` USB view is limited), one
7943
+ * USB Coral is assumed — never when a PCI Coral was seen, since the delegate
7944
+ * then says nothing about USB.
7945
+ *
7946
+ * Returns `null` only when no Coral was found at all; a present-but-unusable
7947
+ * Coral is reported with its typed reason, never as absent (D393/D315).
7948
+ */
7949
+ function classifyCoralAccelerator(fsx) {
7950
+ const usb = countUsbCorals(fsx);
7951
+ const pci = classifyPci(fsx);
7952
+ const units = [];
7953
+ if (usb > 0) units.push({
7954
+ bus: "usb",
7955
+ count: usb
7956
+ });
7957
+ if (pci.usable > 0) units.push({
7958
+ bus: "pci",
7959
+ count: pci.usable
7960
+ });
7961
+ const unavailable = [];
7962
+ if (pci.driverMissing > 0) unavailable.push({
7963
+ bus: "pci",
7964
+ count: pci.driverMissing,
7965
+ reason: "driver-missing"
7966
+ });
7967
+ if (pci.notAccessible > 0) unavailable.push({
7968
+ bus: "pci",
7969
+ count: pci.notAccessible,
7970
+ reason: "device-not-accessible"
7971
+ });
7972
+ if (units.length > 0 || unavailable.length > 0) return unavailable.length > 0 ? {
7973
+ type: "coral-edgetpu",
7974
+ units,
7975
+ unavailable
7976
+ } : {
7977
+ type: "coral-edgetpu",
7978
+ units
7979
+ };
7980
+ const libPath = process.env["CAMSTACK_EDGETPU_LIB"] ?? DEFAULT_EDGETPU_LIB;
7981
+ if (fsx.exists(libPath)) return {
7982
+ type: "coral-edgetpu",
7983
+ units: [{
7984
+ bus: "usb",
7985
+ count: 1
7986
+ }]
7987
+ };
7988
+ return null;
7989
+ }
7990
+ function safeList(dir) {
7991
+ try {
7992
+ return node_fs.default.readdirSync(dir);
7993
+ } catch {
7994
+ return [];
7995
+ }
7996
+ }
7997
+ function safeRead(path) {
7998
+ try {
7999
+ return node_fs.default.readFileSync(path, "utf8").trim();
8000
+ } catch {
8001
+ return "";
8002
+ }
8003
+ }
8004
+ /** The real filesystem view: `/sys` for enumeration, `/dev` for access. */
8005
+ var nodeCoralFs = {
8006
+ listUsbDevices: () => safeList("/sys/bus/usb/devices"),
8007
+ readUsbAttr: (device, attr) => safeRead(`/sys/bus/usb/devices/${device}/${attr}`),
8008
+ listPciDevices: () => safeList("/sys/bus/pci/devices"),
8009
+ readPciAttr: (device, attr) => safeRead(`/sys/bus/pci/devices/${device}/${attr}`),
8010
+ listApexClass: () => safeList("/sys/class/apex"),
8011
+ canOpen: (path) => {
8012
+ try {
8013
+ node_fs.default.accessSync(path, node_fs.default.constants.R_OK | node_fs.default.constants.W_OK);
8014
+ return true;
8015
+ } catch {
8016
+ return false;
8017
+ }
8018
+ },
8019
+ exists: (path) => {
8020
+ try {
8021
+ return node_fs.default.existsSync(path);
8022
+ } catch {
8023
+ return false;
8024
+ }
8025
+ }
8026
+ };
8027
+ //#endregion
7868
8028
  //#region src/kernel/hwaccel/hwaccel-resolver.ts
7869
8029
  /**
7870
8030
  * Platform-probe for hardware video decode acceleration.
@@ -7889,30 +8049,6 @@ function safeExistsSync(path) {
7889
8049
  return false;
7890
8050
  }
7891
8051
  }
7892
- /**
7893
- * Detect a Coral USB Edge TPU: a matching USB device (`1a6e:089a` pre-init or
7894
- * `18d1:9302` post-init) OR the installed libedgetpu delegate (the hub
7895
- * provisions it out-of-band; its presence is a reliable "Coral is wired"
7896
- * signal even where the container's `/sys` USB view is limited).
7897
- */
7898
- function detectCoralUsb() {
7899
- const CORAL_IDS = [{
7900
- vendor: "1a6e",
7901
- product: "089a"
7902
- }, {
7903
- vendor: "18d1",
7904
- product: "9302"
7905
- }];
7906
- try {
7907
- for (const device of node_fs.readdirSync("/sys/bus/usb/devices")) try {
7908
- const base = `/sys/bus/usb/devices/${device}`;
7909
- const vendor = node_fs.readFileSync(`${base}/idVendor`, "utf8").trim().toLowerCase();
7910
- const product = node_fs.readFileSync(`${base}/idProduct`, "utf8").trim().toLowerCase();
7911
- if (CORAL_IDS.some((id) => id.vendor === vendor && id.product === product)) return true;
7912
- } catch {}
7913
- } catch {}
7914
- return safeExistsSync(process.env["CAMSTACK_EDGETPU_LIB"] ?? "/data/deps/edgetpu/lib/libedgetpu.so.1");
7915
- }
7916
8052
  /** Probe Linux GPU vendors by parsing /proc/bus/pci/devices or /sys/class/drm. */
7917
8053
  function probeLinuxGpus() {
7918
8054
  const signals = {
@@ -7921,7 +8057,7 @@ function probeLinuxGpus() {
7921
8057
  hasIntelGpu: false,
7922
8058
  hasRenderNode: false,
7923
8059
  hasIntelNpu: safeExistsSync("/dev/accel/accel0"),
7924
- hasCoral: detectCoralUsb()
8060
+ coral: classifyCoralAccelerator(nodeCoralFs)
7925
8061
  };
7926
8062
  signals.hasRenderNode = safeExistsSync("/dev/dri/renderD128");
7927
8063
  if (safeExistsSync("/dev/nvidia0") || safeExistsSync("/proc/driver/nvidia/version")) signals.hasNvidiaGpu = true;
@@ -7955,7 +8091,7 @@ function probePlatform() {
7955
8091
  hasIntelGpu: false,
7956
8092
  hasRenderNode: false,
7957
8093
  hasIntelNpu: false,
7958
- hasCoral: safeExistsSync(process.env["CAMSTACK_EDGETPU_LIB"] ?? "/data/deps/edgetpu/lib/libedgetpu.so.1")
8094
+ coral: classifyCoralAccelerator(nodeCoralFs)
7959
8095
  };
7960
8096
  }
7961
8097
  function pickBackendsForPlatform(signals) {
@@ -8046,7 +8182,7 @@ function mapSignalsToInferenceHardware(signals) {
8046
8182
  return {
8047
8183
  gpu: signals.hasNvidiaGpu ? { type: "nvidia" } : signals.hasAmdGpu ? { type: "amd" } : signals.hasIntelGpu ? { type: "intel" } : signals.hasRenderNode ? { type: "intel" } : null,
8048
8184
  npu: signals.platform === "darwin" && signals.arch === "arm64" ? { type: "apple-ane" } : signals.hasIntelNpu ? { type: "intel-npu" } : null,
8049
- coral: signals.hasCoral ? { type: "coral-edgetpu" } : null
8185
+ coral: signals.coral
8050
8186
  };
8051
8187
  }
8052
8188
  /**
@@ -1,6 +1,6 @@
1
1
  import { register } from "node:module";
2
- import * as fs from "node:fs";
3
- import { createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
2
+ import * as fs$1 from "node:fs";
3
+ import fs, { createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
4
4
  import * as path from "node:path";
5
5
  import { dirname, isAbsolute, join } from "node:path";
6
6
  import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry, ReadinessTimeoutError, addonSliceHandleApi, asJsonObject, asString, collectZodSecretPaths, createDeviceProxy, createEventBusSliceSource, createRecordsAccess, createSecretsAccess, describeCustomActions, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, isCollectionArrayMethodName, isProviderOptionalMethodName, maskUrlCredentials, normalizeAddonInitResult, readErrorI18n, readNodePin, resolveSecretViewsIn, scopeKey, scrubKnownSecrets, withCapInputDefaults } from "@camstack/types/addon";
@@ -222,7 +222,7 @@ async function defaultDownloadTarball(url, destTgz) {
222
222
  const res = await fetch(url);
223
223
  if (!res.ok || !res.body) throw new Error(`HTTP ${res.status} downloading ${url}`);
224
224
  const bytes = Buffer.from(await res.arrayBuffer());
225
- await fs.promises.writeFile(destTgz, bytes);
225
+ await fs$1.promises.writeFile(destTgz, bytes);
226
226
  }
227
227
  async function defaultExtractTarball(tgzPath, destDir) {
228
228
  await execFileAsync$3("tar", [
@@ -308,7 +308,7 @@ async function resolveUncached(options) {
308
308
  argsPrefix: []
309
309
  };
310
310
  const cliPath = bootstrappedCliPath(options.cacheDir);
311
- if (fs.existsSync(cliPath)) {
311
+ if (fs$1.existsSync(cliPath)) {
312
312
  options.logger.info("system npm unavailable — using bootstrapped npm", { meta: { cliPath } });
313
313
  return {
314
314
  command: process.execPath,
@@ -320,12 +320,12 @@ async function resolveUncached(options) {
320
320
  const registry = (options.registry ?? DEFAULT_REGISTRY).replace(/\/+$/, "");
321
321
  const tarballUrl = tarballUrlOf(await (options.fetchJson ?? defaultFetchJson)(`${registry}/npm/latest`));
322
322
  if (!tarballUrl) throw new Error(`registry metadata for 'npm' carries no dist.tarball (${registry})`);
323
- await fs.promises.mkdir(options.cacheDir, { recursive: true });
323
+ await fs$1.promises.mkdir(options.cacheDir, { recursive: true });
324
324
  const tgzPath = path.join(options.cacheDir, "npm-bootstrap.tgz");
325
325
  await (options.downloadTarball ?? defaultDownloadTarball)(tarballUrl, tgzPath);
326
326
  await (options.extractTarball ?? defaultExtractTarball)(tgzPath, options.cacheDir);
327
- await fs.promises.rm(tgzPath, { force: true });
328
- if (!fs.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
327
+ await fs$1.promises.rm(tgzPath, { force: true });
328
+ if (!fs$1.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
329
329
  options.logger.info("npm bootstrapped", { meta: { cliPath } });
330
330
  return {
331
331
  command: process.execPath,
@@ -389,7 +389,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
389
389
  count: Object.keys(native).length
390
390
  } });
391
391
  try {
392
- fs.writeFileSync(markerFile, markerHash);
392
+ fs$1.writeFileSync(markerFile, markerHash);
393
393
  } catch (err) {
394
394
  logger.warn("Failed to write native deps marker", { meta: {
395
395
  markerFile,
@@ -427,7 +427,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
427
427
  }
428
428
  await rebuildNativeDeps(addonDir, pending.map(([name]) => name), logger, npmCacheDir ?? defaultNpmCacheDir(), registry);
429
429
  try {
430
- fs.writeFileSync(markerFile, markerHash);
430
+ fs$1.writeFileSync(markerFile, markerHash);
431
431
  } catch (err) {
432
432
  logger.warn("Failed to write native deps marker", { meta: {
433
433
  markerFile,
@@ -449,12 +449,12 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
449
449
  if (source === target) continue;
450
450
  if (!hasBuiltBinary(source)) continue;
451
451
  try {
452
- fs.rmSync(target, {
452
+ fs$1.rmSync(target, {
453
453
  recursive: true,
454
454
  force: true
455
455
  });
456
- fs.mkdirSync(path.dirname(target), { recursive: true });
457
- fs.cpSync(source, target, {
456
+ fs$1.mkdirSync(path.dirname(target), { recursive: true });
457
+ fs$1.cpSync(source, target, {
458
458
  recursive: true,
459
459
  dereference: true
460
460
  });
@@ -476,12 +476,12 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
476
476
  }
477
477
  /** A package dir is "built" when it carries a compiled `.node` or a prebuilds tree. */
478
478
  function hasBuiltBinary(pkgDir) {
479
- if (!fs.existsSync(path.join(pkgDir, "package.json"))) return false;
479
+ if (!fs$1.existsSync(path.join(pkgDir, "package.json"))) return false;
480
480
  const releaseDir = path.join(pkgDir, "build", "Release");
481
481
  try {
482
- if (fs.existsSync(releaseDir) && fs.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
482
+ if (fs$1.existsSync(releaseDir) && fs$1.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
483
483
  } catch {}
484
- return fs.existsSync(path.join(pkgDir, "prebuilds"));
484
+ return fs$1.existsSync(path.join(pkgDir, "prebuilds"));
485
485
  }
486
486
  /** Candidate hoisted locations for `<name>`: NODE_PATH entries + ancestors of `addonDir`. */
487
487
  function candidateHoistedDirs(name, addonDir) {
@@ -519,7 +519,7 @@ function hashDeclaration(deps) {
519
519
  }
520
520
  function markerMatches(markerFile, expected) {
521
521
  try {
522
- return fs.readFileSync(markerFile, "utf-8").trim() === expected;
522
+ return fs$1.readFileSync(markerFile, "utf-8").trim() === expected;
523
523
  } catch {
524
524
  return false;
525
525
  }
@@ -7841,6 +7841,166 @@ function ipcParentLink(getCallOut) {
7841
7841
  };
7842
7842
  }
7843
7843
  //#endregion
7844
+ //#region src/builtins/platform-probe/coral-accelerators.ts
7845
+ /**
7846
+ * Coral USB Edge TPU USB identifiers.
7847
+ *
7848
+ * The device enumerates as `1a6e:089a` (Global Unichip) BEFORE the libedgetpu
7849
+ * firmware loads, then re-enumerates as `18d1:9302` (Google) AFTER. Either id
7850
+ * means a Coral is physically attached, so both count as a positive signal.
7851
+ */
7852
+ var CORAL_USB_IDS = [{
7853
+ vendor: "1a6e",
7854
+ product: "089a"
7855
+ }, {
7856
+ vendor: "18d1",
7857
+ product: "9302"
7858
+ }];
7859
+ /** The PCIe / M.2 Coral's PCI function id (Global Unichip "Apex"). */
7860
+ var CORAL_PCI_VENDOR = "0x1ac1";
7861
+ var CORAL_PCI_DEVICE = "0x089a";
7862
+ /** A unit the apex driver bound: `/sys/class/apex/apex_<N>` ↔ `/dev/apex_<N>`. */
7863
+ var APEX_ENTRY = /^apex_(\d+)$/;
7864
+ /**
7865
+ * Default install path of the libedgetpu delegate on the hub, provisioned
7866
+ * out-of-band by `/data/deps/edgetpu-install.sh` (it is a system shared
7867
+ * library, not a pip package). Overridable via `CAMSTACK_EDGETPU_LIB` — kept in
7868
+ * sync with the Python pool's own default in `inference_pool.py`.
7869
+ */
7870
+ var DEFAULT_EDGETPU_LIB = "/data/deps/edgetpu/lib/libedgetpu.so.1";
7871
+ function countUsbCorals(fsx) {
7872
+ let count = 0;
7873
+ for (const device of fsx.listUsbDevices()) {
7874
+ const vendor = fsx.readUsbAttr(device, "idVendor").toLowerCase();
7875
+ const product = fsx.readUsbAttr(device, "idProduct").toLowerCase();
7876
+ if (CORAL_USB_IDS.some((id) => id.vendor === vendor && id.product === product)) count++;
7877
+ }
7878
+ return count;
7879
+ }
7880
+ function countPciCorals(fsx) {
7881
+ let count = 0;
7882
+ for (const device of fsx.listPciDevices()) {
7883
+ const vendor = fsx.readPciAttr(device, "vendor").toLowerCase();
7884
+ const product = fsx.readPciAttr(device, "device").toLowerCase();
7885
+ if (vendor === CORAL_PCI_VENDOR && product === CORAL_PCI_DEVICE) count++;
7886
+ }
7887
+ return count;
7888
+ }
7889
+ /**
7890
+ * PCIe units: each `/sys/class/apex/apex_N` is a unit the driver bound; it is
7891
+ * usable only when `/dev/apex_N` is in this process's view AND opens read/write.
7892
+ * PCI functions with the Coral id beyond the bound units have no driver.
7893
+ */
7894
+ function classifyPci(fsx) {
7895
+ let usable = 0;
7896
+ let notAccessible = 0;
7897
+ for (const entry of fsx.listApexClass()) {
7898
+ const match = APEX_ENTRY.exec(entry);
7899
+ if (match === null) continue;
7900
+ const node = `/dev/apex_${match[1]}`;
7901
+ if (fsx.exists(node) && fsx.canOpen(node)) usable++;
7902
+ else notAccessible++;
7903
+ }
7904
+ const driverMissing = Math.max(0, countPciCorals(fsx) - usable - notAccessible);
7905
+ return {
7906
+ usable,
7907
+ notAccessible,
7908
+ driverMissing
7909
+ };
7910
+ }
7911
+ /**
7912
+ * Detect Coral Edge TPUs on USB and PCIe/M.2.
7913
+ *
7914
+ * - USB: every matching USB device counts (multiple Corals run concurrently).
7915
+ * - PCIe: the apex driver's units, each usable only if its device node opens;
7916
+ * a Coral PCI function the driver did not bind is `driver-missing`.
7917
+ * - Fallback: when NO Coral signal of either bus is visible but the libedgetpu
7918
+ * delegate is installed (a container whose `/sys` USB view is limited), one
7919
+ * USB Coral is assumed — never when a PCI Coral was seen, since the delegate
7920
+ * then says nothing about USB.
7921
+ *
7922
+ * Returns `null` only when no Coral was found at all; a present-but-unusable
7923
+ * Coral is reported with its typed reason, never as absent (D393/D315).
7924
+ */
7925
+ function classifyCoralAccelerator(fsx) {
7926
+ const usb = countUsbCorals(fsx);
7927
+ const pci = classifyPci(fsx);
7928
+ const units = [];
7929
+ if (usb > 0) units.push({
7930
+ bus: "usb",
7931
+ count: usb
7932
+ });
7933
+ if (pci.usable > 0) units.push({
7934
+ bus: "pci",
7935
+ count: pci.usable
7936
+ });
7937
+ const unavailable = [];
7938
+ if (pci.driverMissing > 0) unavailable.push({
7939
+ bus: "pci",
7940
+ count: pci.driverMissing,
7941
+ reason: "driver-missing"
7942
+ });
7943
+ if (pci.notAccessible > 0) unavailable.push({
7944
+ bus: "pci",
7945
+ count: pci.notAccessible,
7946
+ reason: "device-not-accessible"
7947
+ });
7948
+ if (units.length > 0 || unavailable.length > 0) return unavailable.length > 0 ? {
7949
+ type: "coral-edgetpu",
7950
+ units,
7951
+ unavailable
7952
+ } : {
7953
+ type: "coral-edgetpu",
7954
+ units
7955
+ };
7956
+ const libPath = process.env["CAMSTACK_EDGETPU_LIB"] ?? DEFAULT_EDGETPU_LIB;
7957
+ if (fsx.exists(libPath)) return {
7958
+ type: "coral-edgetpu",
7959
+ units: [{
7960
+ bus: "usb",
7961
+ count: 1
7962
+ }]
7963
+ };
7964
+ return null;
7965
+ }
7966
+ function safeList(dir) {
7967
+ try {
7968
+ return fs.readdirSync(dir);
7969
+ } catch {
7970
+ return [];
7971
+ }
7972
+ }
7973
+ function safeRead(path) {
7974
+ try {
7975
+ return fs.readFileSync(path, "utf8").trim();
7976
+ } catch {
7977
+ return "";
7978
+ }
7979
+ }
7980
+ /** The real filesystem view: `/sys` for enumeration, `/dev` for access. */
7981
+ var nodeCoralFs = {
7982
+ listUsbDevices: () => safeList("/sys/bus/usb/devices"),
7983
+ readUsbAttr: (device, attr) => safeRead(`/sys/bus/usb/devices/${device}/${attr}`),
7984
+ listPciDevices: () => safeList("/sys/bus/pci/devices"),
7985
+ readPciAttr: (device, attr) => safeRead(`/sys/bus/pci/devices/${device}/${attr}`),
7986
+ listApexClass: () => safeList("/sys/class/apex"),
7987
+ canOpen: (path) => {
7988
+ try {
7989
+ fs.accessSync(path, fs.constants.R_OK | fs.constants.W_OK);
7990
+ return true;
7991
+ } catch {
7992
+ return false;
7993
+ }
7994
+ },
7995
+ exists: (path) => {
7996
+ try {
7997
+ return fs.existsSync(path);
7998
+ } catch {
7999
+ return false;
8000
+ }
8001
+ }
8002
+ };
8003
+ //#endregion
7844
8004
  //#region src/kernel/hwaccel/hwaccel-resolver.ts
7845
8005
  /**
7846
8006
  * Platform-probe for hardware video decode acceleration.
@@ -7860,35 +8020,11 @@ function ipcParentLink(getCallOut) {
7860
8020
  */
7861
8021
  function safeExistsSync(path) {
7862
8022
  try {
7863
- return fs.existsSync(path);
8023
+ return fs$1.existsSync(path);
7864
8024
  } catch {
7865
8025
  return false;
7866
8026
  }
7867
8027
  }
7868
- /**
7869
- * Detect a Coral USB Edge TPU: a matching USB device (`1a6e:089a` pre-init or
7870
- * `18d1:9302` post-init) OR the installed libedgetpu delegate (the hub
7871
- * provisions it out-of-band; its presence is a reliable "Coral is wired"
7872
- * signal even where the container's `/sys` USB view is limited).
7873
- */
7874
- function detectCoralUsb() {
7875
- const CORAL_IDS = [{
7876
- vendor: "1a6e",
7877
- product: "089a"
7878
- }, {
7879
- vendor: "18d1",
7880
- product: "9302"
7881
- }];
7882
- try {
7883
- for (const device of fs.readdirSync("/sys/bus/usb/devices")) try {
7884
- const base = `/sys/bus/usb/devices/${device}`;
7885
- const vendor = fs.readFileSync(`${base}/idVendor`, "utf8").trim().toLowerCase();
7886
- const product = fs.readFileSync(`${base}/idProduct`, "utf8").trim().toLowerCase();
7887
- if (CORAL_IDS.some((id) => id.vendor === vendor && id.product === product)) return true;
7888
- } catch {}
7889
- } catch {}
7890
- return safeExistsSync(process.env["CAMSTACK_EDGETPU_LIB"] ?? "/data/deps/edgetpu/lib/libedgetpu.so.1");
7891
- }
7892
8028
  /** Probe Linux GPU vendors by parsing /proc/bus/pci/devices or /sys/class/drm. */
7893
8029
  function probeLinuxGpus() {
7894
8030
  const signals = {
@@ -7897,17 +8033,17 @@ function probeLinuxGpus() {
7897
8033
  hasIntelGpu: false,
7898
8034
  hasRenderNode: false,
7899
8035
  hasIntelNpu: safeExistsSync("/dev/accel/accel0"),
7900
- hasCoral: detectCoralUsb()
8036
+ coral: classifyCoralAccelerator(nodeCoralFs)
7901
8037
  };
7902
8038
  signals.hasRenderNode = safeExistsSync("/dev/dri/renderD128");
7903
8039
  if (safeExistsSync("/dev/nvidia0") || safeExistsSync("/proc/driver/nvidia/version")) signals.hasNvidiaGpu = true;
7904
8040
  try {
7905
8041
  const drmDir = "/sys/class/drm";
7906
- if (fs.existsSync(drmDir)) for (const entry of fs.readdirSync(drmDir)) {
8042
+ if (fs$1.existsSync(drmDir)) for (const entry of fs$1.readdirSync(drmDir)) {
7907
8043
  if (!entry.startsWith("card")) continue;
7908
8044
  const vendorPath = `${drmDir}/${entry}/device/vendor`;
7909
8045
  if (!safeExistsSync(vendorPath)) continue;
7910
- const vendor = fs.readFileSync(vendorPath, "utf8").trim().toLowerCase();
8046
+ const vendor = fs$1.readFileSync(vendorPath, "utf8").trim().toLowerCase();
7911
8047
  if (vendor === "0x10de") signals.hasNvidiaGpu = true;
7912
8048
  else if (vendor === "0x1002") signals.hasAmdGpu = true;
7913
8049
  else if (vendor === "0x8086") signals.hasIntelGpu = true;
@@ -7931,7 +8067,7 @@ function probePlatform() {
7931
8067
  hasIntelGpu: false,
7932
8068
  hasRenderNode: false,
7933
8069
  hasIntelNpu: false,
7934
- hasCoral: safeExistsSync(process.env["CAMSTACK_EDGETPU_LIB"] ?? "/data/deps/edgetpu/lib/libedgetpu.so.1")
8070
+ coral: classifyCoralAccelerator(nodeCoralFs)
7935
8071
  };
7936
8072
  }
7937
8073
  function pickBackendsForPlatform(signals) {
@@ -8022,7 +8158,7 @@ function mapSignalsToInferenceHardware(signals) {
8022
8158
  return {
8023
8159
  gpu: signals.hasNvidiaGpu ? { type: "nvidia" } : signals.hasAmdGpu ? { type: "amd" } : signals.hasIntelGpu ? { type: "intel" } : signals.hasRenderNode ? { type: "intel" } : null,
8024
8160
  npu: signals.platform === "darwin" && signals.arch === "arm64" ? { type: "apple-ane" } : signals.hasIntelNpu ? { type: "intel-npu" } : null,
8025
- coral: signals.hasCoral ? { type: "coral-edgetpu" } : null
8161
+ coral: signals.coral
8026
8162
  };
8027
8163
  }
8028
8164
  /**
@@ -8766,21 +8902,21 @@ function sleep(ms) {
8766
8902
  * crashed holder) is stolen.
8767
8903
  */
8768
8904
  async function withFileLock(lockPath, fn) {
8769
- fs.mkdirSync(join(lockPath, ".."), { recursive: true });
8905
+ fs$1.mkdirSync(join(lockPath, ".."), { recursive: true });
8770
8906
  for (;;) try {
8771
- const fd = fs.openSync(lockPath, "wx");
8772
- fs.closeSync(fd);
8907
+ const fd = fs$1.openSync(lockPath, "wx");
8908
+ fs$1.closeSync(fd);
8773
8909
  break;
8774
8910
  } catch {
8775
8911
  try {
8776
- if (Date.now() - fs.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs.rmSync(lockPath, { force: true });
8912
+ if (Date.now() - fs$1.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs$1.rmSync(lockPath, { force: true });
8777
8913
  else await sleep(LOCK_POLL_MS);
8778
8914
  } catch {}
8779
8915
  }
8780
8916
  try {
8781
8917
  return await fn();
8782
8918
  } finally {
8783
- fs.rmSync(lockPath, { force: true });
8919
+ fs$1.rmSync(lockPath, { force: true });
8784
8920
  }
8785
8921
  }
8786
8922
  /** Coalesce in-process + serialize cross-process for one binary id. */
@@ -10335,7 +10471,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
10335
10471
  const addonId = declaration.id;
10336
10472
  const nodeDataDir = process.env["CAMSTACK_DATA"] ?? dataDir;
10337
10473
  const addonDataDir = path.resolve(nodeDataDir, "addons-data", addonId);
10338
- fs.mkdirSync(addonDataDir, { recursive: true });
10474
+ fs$1.mkdirSync(addonDataDir, { recursive: true });
10339
10475
  if (runtime.mode === "broker") ensureBindingSubscription(runtime.broker);
10340
10476
  const regs = getRegistries(nodeId);
10341
10477
  const workerResolver = {
@@ -11203,11 +11339,11 @@ function parseAddonsSpec(raw) {
11203
11339
  }
11204
11340
  async function loadAddonModule(addonId, addonDir) {
11205
11341
  const pkgJsonPath = path.join(addonDir, "package.json");
11206
- if (!fs.existsSync(pkgJsonPath)) throw new Error(`No package.json at ${addonDir}`);
11207
- const declaration = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"))["camstack"]?.addons?.find((a) => a.id === addonId);
11342
+ if (!fs$1.existsSync(pkgJsonPath)) throw new Error(`No package.json at ${addonDir}`);
11343
+ const declaration = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"))["camstack"]?.addons?.find((a) => a.id === addonId);
11208
11344
  if (!declaration?.entry) throw new Error(`Addon "${addonId}" not found in ${pkgJsonPath} manifest`);
11209
11345
  const entryPath = path.resolve(addonDir, declaration.entry);
11210
- if (!fs.existsSync(entryPath)) throw new Error(`Entry point not found: ${entryPath}`);
11346
+ if (!fs$1.existsSync(entryPath)) throw new Error(`Entry point not found: ${entryPath}`);
11211
11347
  const modUnknown = await import(entryPath);
11212
11348
  const mod = isRecord(modUnknown) ? modUnknown : {};
11213
11349
  const AddonClass = resolveAddonClass(mod);
@@ -11404,7 +11540,7 @@ async function main() {
11404
11540
  });
11405
11541
  if (context.secrets !== void 0) addonSecrets.set(spec.addonId, context.secrets);
11406
11542
  try {
11407
- const pkgRaw = JSON.parse(fs.readFileSync(path.join(spec.addonDir, "package.json"), "utf-8"));
11543
+ const pkgRaw = JSON.parse(fs$1.readFileSync(path.join(spec.addonDir, "package.json"), "utf-8"));
11408
11544
  await installManifestNativeDeps(spec.addonDir, pkgRaw, context.logger);
11409
11545
  } catch (nativeErr) {
11410
11546
  console.error(`[addon-runner] native deps install failed for "${spec.addonId}": ${errMsg(nativeErr)}`);
@@ -11467,7 +11603,7 @@ async function main() {
11467
11603
  const refusal = findAddonRefusal(err);
11468
11604
  if (refusal !== null) {
11469
11605
  try {
11470
- fs.writeSync(1, formatRunnerRefusalLine(nodeId, refusalReportOf(spec.addonId, refusal)));
11606
+ fs$1.writeSync(1, formatRunnerRefusalLine(nodeId, refusalReportOf(spec.addonId, refusal)));
11471
11607
  } catch {}
11472
11608
  process.exit(78);
11473
11609
  }