@camstack/server 1.2.928 → 1.2.930

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 (241) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +10 -10
  3. package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
  4. package/system/dist/addon-id-Di0lNJ89.js +50 -0
  5. package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
  6. package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
  7. package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
  8. package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
  9. package/system/dist/addon-utils.mjs +1 -1
  10. package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
  11. package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
  12. package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
  13. package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
  14. package/system/dist/base-device-2sL1DMm1.js +1103 -0
  15. package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
  16. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
  17. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +6 -4
  18. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
  19. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +7 -5
  20. package/system/dist/builtins/alerts/alerts.addon.js +113 -56
  21. package/system/dist/builtins/alerts/alerts.addon.mjs +60 -3
  22. package/system/dist/builtins/autotrack/index.js +21 -17
  23. package/system/dist/builtins/autotrack/index.mjs +5 -1
  24. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
  25. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +8 -5
  26. package/system/dist/builtins/calendars/calendars.addon.js +8 -6
  27. package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
  28. package/system/dist/builtins/camera-grid/index.js +615 -58
  29. package/system/dist/builtins/camera-grid/index.mjs +558 -1
  30. package/system/dist/builtins/composer/composer.addon.js +788 -209
  31. package/system/dist/builtins/composer/composer.addon.mjs +583 -4
  32. package/system/dist/builtins/console-logging/index.js +4 -3
  33. package/system/dist/builtins/console-logging/index.mjs +2 -1
  34. package/system/dist/builtins/core-blocks/actions-service.d.ts +18 -1
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.js +8670 -386
  36. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +8294 -11
  37. package/system/dist/builtins/core-blocks/tcp-connect.d.ts +3 -0
  38. package/system/dist/builtins/core-notifier/core-notifier.addon.js +250 -21
  39. package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +230 -1
  40. package/system/dist/builtins/device-history/device-history.addon.js +110 -31
  41. package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
  42. package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
  43. package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
  44. package/system/dist/builtins/hub-forwarder/index.js +4 -3
  45. package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
  46. package/system/dist/builtins/keychain/index.js +31 -28
  47. package/system/dist/builtins/keychain/index.mjs +7 -4
  48. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
  49. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
  50. package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
  51. package/system/dist/builtins/local-auth/local-auth.addon.mjs +106 -6
  52. package/system/dist/builtins/local-network/local-network.addon.js +43 -39
  53. package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
  54. package/system/dist/builtins/loki-logging/index.js +23 -17
  55. package/system/dist/builtins/loki-logging/index.mjs +7 -1
  56. package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
  57. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +151 -10
  58. package/system/dist/builtins/platform-probe/index.js +25 -23
  59. package/system/dist/builtins/platform-probe/index.mjs +12 -10
  60. package/system/dist/builtins/record-entries/index.js +9 -7
  61. package/system/dist/builtins/record-entries/index.mjs +3 -1
  62. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
  63. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  64. package/system/dist/builtins/snapshot/index.js +97 -44
  65. package/system/dist/builtins/snapshot/index.mjs +54 -1
  66. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
  67. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +21 -20
  68. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  69. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  70. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +87 -61
  71. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
  72. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
  73. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
  74. package/system/dist/builtins/system-config/system-config.addon.js +17 -14
  75. package/system/dist/builtins/system-config/system-config.addon.mjs +118 -115
  76. package/system/dist/builtins/winston-logging/index.js +7 -5
  77. package/system/dist/builtins/winston-logging/index.mjs +3 -1
  78. package/system/dist/calendars.cap-CaFlShS9.js +155 -0
  79. package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
  80. package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
  81. package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
  82. package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
  83. package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
  84. package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
  85. package/system/dist/capability-definition-HCmTem8c.js +242 -0
  86. package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
  87. package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
  88. package/system/dist/command-origin-claim-Cief660O.js +35 -0
  89. package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
  90. package/system/dist/composition-sources-BEUWn2s_.mjs +391 -0
  91. package/system/dist/composition-sources-acfR4hDq.js +408 -0
  92. package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
  93. package/system/dist/constants-C860Y6U4.js +26 -0
  94. package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
  95. package/system/dist/constants-DCLpoF4L.mjs +21 -0
  96. package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
  97. package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
  98. package/system/dist/core-blocks.cap-BMeMCBrx.js +18733 -0
  99. package/system/dist/core-blocks.cap-BRPsLAij.mjs +18008 -0
  100. package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
  101. package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
  102. package/system/dist/custom-actions-D92NRi2c.js +36 -0
  103. package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
  104. package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
  105. package/system/dist/declared-device-BWphj9WE.js +303 -0
  106. package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
  107. package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
  108. package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
  109. package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
  110. package/system/dist/device-certificate-CguVACQO.js +162 -0
  111. package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
  112. package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
  113. package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
  114. package/system/dist/device-kind-CsSiv_YF.js +101 -0
  115. package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
  116. package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
  117. package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
  118. package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
  119. package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
  120. package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
  121. package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
  122. package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
  123. package/system/dist/device-type-CbQsnFdC.js +477 -0
  124. package/system/dist/device-type-DgEvK3ch.mjs +454 -0
  125. package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
  126. package/system/dist/entry-kind-cq90c--V.js +55 -0
  127. package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
  128. package/system/dist/error.cap-DBhgPeWK.js +3848 -0
  129. package/system/dist/file-host-worker.js +1 -1
  130. package/system/dist/file-host-worker.mjs +1 -1
  131. package/system/dist/history-catalog-BKRarIL_.js +831 -0
  132. package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
  133. package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
  134. package/system/dist/{hub-identity-CYC1820R.mjs → hub-identity-DjMN9Ac2.mjs} +10 -10
  135. package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
  136. package/system/dist/{hub-mdns-ciao-CCDxM5qz.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
  137. package/system/dist/index.js +763 -151
  138. package/system/dist/index.mjs +832 -220
  139. package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
  140. package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
  141. package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
  142. package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
  143. package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
  144. package/system/dist/l10n-CGMvp7NF.js +15 -0
  145. package/system/dist/labels-DX5S8deC.js +81 -0
  146. package/system/dist/labels-DsBcU7md.mjs +64 -0
  147. package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
  148. package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
  149. package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
  150. package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
  151. package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
  152. package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
  153. package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
  154. package/system/dist/mask-shape-CmPA2fst.js +92 -0
  155. package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
  156. package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
  157. package/system/dist/migration-BMjgkyG2.js +380 -0
  158. package/system/dist/migration-DRJAtdy7.mjs +321 -0
  159. package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
  160. package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
  161. package/system/dist/notification-rules.cap-BDh0LDhV.js +3428 -0
  162. package/system/dist/notification-rules.cap-DUmiMBQB.mjs +3357 -0
  163. package/system/dist/notification-targets-CRH-9Dy5.js +509 -0
  164. package/system/dist/notification-targets-DaNE-pIt.mjs +486 -0
  165. package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
  166. package/system/dist/ops-log-pxt9176Z.js +81 -0
  167. package/system/dist/pinned-binary-BOhOSNff.js +28 -0
  168. package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
  169. package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
  170. package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
  171. package/system/dist/prefix-walk-BkMxoXpL.js +843 -0
  172. package/system/dist/prefix-walk-ifwg_ukx.mjs +790 -0
  173. package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
  174. package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
  175. package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
  176. package/system/dist/quantity-lY1KiTSZ.js +143 -0
  177. package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
  178. package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
  179. package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
  180. package/system/dist/record-entries.cap-ti1C046R.js +80 -0
  181. package/system/dist/record-kind-DoBfYHCs.js +203 -0
  182. package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
  183. package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
  184. package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
  185. package/system/dist/records.cap-ClcWV64i.js +329 -0
  186. package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
  187. package/system/dist/relocate-CdVQAk-w.js +804 -0
  188. package/system/dist/relocate-CoZZTui1.mjs +661 -0
  189. package/system/dist/rename-composition-block-BJsL58Ih.js +34798 -0
  190. package/system/dist/rename-composition-block-OAtErZgq.mjs +33631 -0
  191. package/system/dist/{restore-archive-BJfyu0sG.mjs → restore-archive-CjAyKpgX.mjs} +96 -94
  192. package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
  193. package/system/dist/scoped-settings-CylSSq_8.js +955 -0
  194. package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
  195. package/system/dist/server-name-BIhLuHvX.mjs +35 -0
  196. package/system/dist/server-name-OALNvpqC.js +52 -0
  197. package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
  198. package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
  199. package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
  200. package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
  201. package/system/dist/source-info-DGB7SdB_.mjs +190 -0
  202. package/system/dist/source-info-DtWf4k2j.js +225 -0
  203. package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
  204. package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
  205. package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
  206. package/system/dist/storage-location-CTweDMZf.js +198 -0
  207. package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
  208. package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
  209. package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
  210. package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
  211. package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
  212. package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
  213. package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
  214. package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
  215. package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
  216. package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
  217. package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
  218. package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
  219. package/system/dist/system-reasons-Be_k1W8g.js +25 -0
  220. package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
  221. package/system/dist/tag-BxLazvVb.js +2138 -0
  222. package/system/dist/tag-uZBAq6ox.mjs +2073 -0
  223. package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
  224. package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
  225. package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
  226. package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
  227. package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
  228. package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
  229. package/system/dist/zod-secret-DS7mj1bk.js +78 -0
  230. package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
  231. package/system/package.json +1 -1
  232. package/system/dist/composition-sources-BI614LJx.mjs +0 -141
  233. package/system/dist/composition-sources-v_kkb8A9.js +0 -152
  234. package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
  235. package/system/dist/coral-accelerators-BW3OcrLD.mjs +0 -231
  236. package/system/dist/dist-BCHMSqzc.mjs +0 -143467
  237. package/system/dist/dist-BZfvhfS1.js +0 -146970
  238. package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
  239. package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
  240. package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
  241. package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
@@ -0,0 +1,521 @@
1
+ import { EDGETPU_LIB_ENV, chooseEdgetpuDelegate, nodeDataRootFromEnv } from "@camstack/types/node";
2
+ import fs from "node:fs";
3
+ //#region ../types/dist/esm/inference/coral-units.mjs
4
+ /** Bus order of the enumeration: USB first (the historical key), then PCIe. */
5
+ var BUS_ORDER = ["usb", "pci"];
6
+ function unitDevice(bus, index) {
7
+ return index === 0 ? bus : `${bus}:${index}`;
8
+ }
9
+ function countOn(coral, bus) {
10
+ if (coral.units !== void 0) return coral.units.filter((u) => u.bus === bus).reduce((n, u) => n + Math.max(0, u.count), 0);
11
+ return bus === (coral.bus === "pci" ? "pci" : "usb") ? Math.max(1, coral.count ?? 1) : 0;
12
+ }
13
+ /** Every usable Coral unit on a node, USB first then PCIe, in ordinal order. */
14
+ function coralUsableUnits(coral) {
15
+ if (coral == null) return [];
16
+ const out = [];
17
+ for (const bus of BUS_ORDER) {
18
+ const count = countOn(coral, bus);
19
+ for (let index = 0; index < count; index++) out.push({
20
+ bus,
21
+ index,
22
+ device: unitDevice(bus, index)
23
+ });
24
+ }
25
+ return out;
26
+ }
27
+ //#endregion
28
+ //#region ../types/dist/esm/inference/runtime-capabilities.mjs
29
+ var AUTO = {
30
+ value: "auto",
31
+ label: "Auto"
32
+ };
33
+ var CPU = {
34
+ value: "cpu",
35
+ label: "CPU"
36
+ };
37
+ var USB = {
38
+ value: "usb",
39
+ label: "Coral USB"
40
+ };
41
+ function coralUnitOption(unit) {
42
+ const bus = unit.bus === "pci" ? "PCIe" : "USB";
43
+ const label = unit.index === 0 ? `Coral ${bus}` : `Coral ${bus} ${unit.index + 1}`;
44
+ return {
45
+ value: unit.device,
46
+ label
47
+ };
48
+ }
49
+ var ONNX_CUDA_EP = "CUDAExecutionProvider";
50
+ /**
51
+ * The `HardwareInfo.nvidia` slot for a found card. Usable only when the node's
52
+ * ONNX Runtime lists the CUDA execution provider (`ort.get_available_providers()`,
53
+ * the signal the inference pool binds on); `null` = not reported = not usable.
54
+ */
55
+ function describeNvidia(probe, onnxExecutionProviders) {
56
+ const base = {
57
+ type: "nvidia",
58
+ name: probe.name,
59
+ ...probe.memoryMB === void 0 ? {} : { memoryMB: probe.memoryMB }
60
+ };
61
+ return onnxExecutionProviders?.includes(ONNX_CUDA_EP) === true ? {
62
+ ...base,
63
+ usable: true
64
+ } : {
65
+ ...base,
66
+ usable: false,
67
+ reason: "no-cuda-execution-provider"
68
+ };
69
+ }
70
+ /**
71
+ * CUDA is offered only for a USABLE NVIDIA slot. An NVIDIA GPU alone is not
72
+ * enough: without the EP the pool binds the CPU provider and a `cuda` device
73
+ * would be the CPU under another name. `gpu.type === 'nvidia'` (older nodes)
74
+ * never counts.
75
+ */
76
+ function onnxCudaAvailable(hw) {
77
+ return hw?.nvidia?.usable === true;
78
+ }
79
+ var RUNTIMES = [
80
+ {
81
+ id: "onnx",
82
+ supports: () => true,
83
+ devices: (hw) => {
84
+ if (!hw) return [CPU];
85
+ const out = [CPU];
86
+ if (onnxCudaAvailable(hw)) out.push({
87
+ value: "cuda",
88
+ label: "CUDA"
89
+ });
90
+ if (hw.gpu?.type === "amd" && hw.platform === "linux") out.push({
91
+ value: "webgpu",
92
+ label: "WebGPU (AMD iGPU)"
93
+ });
94
+ if (hw.npu?.type === "apple-ane") out.push({
95
+ value: "coreml",
96
+ label: "CoreML EP"
97
+ });
98
+ return out;
99
+ },
100
+ defaultDevice: "cpu"
101
+ },
102
+ {
103
+ id: "openvino",
104
+ supports: (hw) => hw?.arch === "x64" && hw.platform !== "darwin" && (hw.gpu?.type === "intel" || hw.gpu?.type === "amd"),
105
+ devices: (hw) => {
106
+ if (!hw) return [AUTO];
107
+ if (hw.gpu?.type === "amd") return [CPU];
108
+ const out = [AUTO, CPU];
109
+ if (hw.gpu?.type === "intel") out.push({
110
+ value: "gpu",
111
+ label: "GPU"
112
+ });
113
+ if (hw.npu?.type === "intel-npu") out.push({
114
+ value: "npu",
115
+ label: "NPU"
116
+ });
117
+ return out;
118
+ },
119
+ defaultDevice: "auto"
120
+ },
121
+ {
122
+ id: "coreml",
123
+ supports: (hw) => hw?.platform === "darwin",
124
+ devices: (hw) => {
125
+ const all = {
126
+ value: "all",
127
+ label: "All (ANE + GPU + CPU)"
128
+ };
129
+ if (!hw) return [all];
130
+ const out = [all];
131
+ if (hw.npu?.type === "apple-ane") out.push({
132
+ value: "ane",
133
+ label: "Apple Neural Engine"
134
+ });
135
+ out.push({
136
+ value: "gpu",
137
+ label: "GPU"
138
+ }, CPU);
139
+ return out;
140
+ },
141
+ defaultDevice: "all"
142
+ },
143
+ {
144
+ id: "edgetpu",
145
+ supports: (hw) => coralUsableUnits(hw?.coral).length > 0,
146
+ devices: (hw) => {
147
+ const units = coralUsableUnits(hw?.coral);
148
+ return units.length > 0 ? units.map(coralUnitOption) : [USB];
149
+ },
150
+ defaultDevice: "usb"
151
+ }
152
+ ];
153
+ /**
154
+ * Returns the list of supported runtime IDs for given hardware.
155
+ * onnx is always included (universal floor); accelerators added when hw matches.
156
+ */
157
+ function supportedRuntimes(hw) {
158
+ return RUNTIMES.filter((r) => r.supports(hw)).map((r) => r.id);
159
+ }
160
+ /**
161
+ * Scores all applicable inference backends for the given hardware.
162
+ *
163
+ * Rules (hardware-driven only — no Python import probes):
164
+ * - coreml: score 95, darwin+arm64
165
+ * - cuda: score 85, only for a usable `nvidia` slot (the CUDA EP exists)
166
+ * - openvino: score 90 if intel-npu present, else 80 if intel gpu
167
+ * - edgetpu: score 70, a usable Coral unit (USB or PCIe)
168
+ * - cpu: score 50 (universal floor, always included)
169
+ *
170
+ * All hardware-matched entries are `available: true`.
171
+ * Scores are sorted descending; `best` is the first available entry
172
+ * (or last entry as fallback).
173
+ */
174
+ function scoreRuntimes(hw) {
175
+ const scores = [];
176
+ if (hw.platform === "darwin" && hw.arch === "arm64") scores.push({
177
+ runtime: "python",
178
+ backend: "coreml",
179
+ format: "coreml",
180
+ score: 95,
181
+ reason: "Apple Neural Engine (Python CoreML)",
182
+ available: true
183
+ });
184
+ if (onnxCudaAvailable(hw)) scores.push({
185
+ runtime: "python",
186
+ backend: "cuda",
187
+ format: "onnx",
188
+ score: 85,
189
+ reason: "NVIDIA CUDA (Python ONNX Runtime)",
190
+ available: true
191
+ });
192
+ if (hw.gpu?.type === "intel") {
193
+ const score = hw.npu?.type === "intel-npu" ? 90 : 80;
194
+ scores.push({
195
+ runtime: "python",
196
+ backend: "openvino",
197
+ format: "openvino",
198
+ score,
199
+ reason: "Intel OpenVINO",
200
+ available: true
201
+ });
202
+ }
203
+ if (hw.gpu?.type === "amd") {
204
+ if (hw.platform === "linux") scores.push({
205
+ runtime: "python",
206
+ backend: "onnx",
207
+ format: "onnx",
208
+ score: 75,
209
+ reason: "ONNX WebGPU (AMD iGPU)",
210
+ available: true
211
+ });
212
+ scores.push({
213
+ runtime: "python",
214
+ backend: "openvino",
215
+ format: "openvino",
216
+ score: 65,
217
+ reason: "OpenVINO CPU (AMD x64)",
218
+ available: true
219
+ });
220
+ }
221
+ if (coralUsableUnits(hw.coral).length > 0) scores.push({
222
+ runtime: "python",
223
+ backend: "edgetpu",
224
+ format: "tflite",
225
+ score: 70,
226
+ reason: "Coral Edge TPU (Python LiteRT)",
227
+ available: true
228
+ });
229
+ scores.push({
230
+ runtime: "python",
231
+ backend: "cpu",
232
+ format: "onnx",
233
+ score: 50,
234
+ reason: "CPU (Python ONNX Runtime)",
235
+ available: true
236
+ });
237
+ const sorted = scores.toSorted((a, b) => b.score - a.score);
238
+ return {
239
+ scores: sorted,
240
+ best: sorted.find((s) => s.available) ?? sorted[sorted.length - 1]
241
+ };
242
+ }
243
+ var DEVICE_FOR_BACKEND = {
244
+ cuda: "gpu",
245
+ edgetpu: "usb",
246
+ coreml: "all",
247
+ cpu: "cpu"
248
+ };
249
+ function device(backend, dev, format, score) {
250
+ return {
251
+ key: backend === "cpu" ? "cpu" : `${backend}:${dev}`,
252
+ backend,
253
+ device: dev,
254
+ format,
255
+ runtime: "python",
256
+ score,
257
+ available: true
258
+ };
259
+ }
260
+ /**
261
+ * Enumerate every usable inference device on a node — one descriptor PER PHYSICAL
262
+ * ACCELERATOR, so the orchestrator can run and balance across all of them
263
+ * CONCURRENTLY (each device is its own pool). Critically, OpenVINO is expanded
264
+ * into its distinct devices (NPU / iGPU / CPU) rather than a single AUTO entry:
265
+ * the Intel NPU ("AI Boost") and the iGPU are separate accelerators and run in
266
+ * parallel — collapsing them to AUTO would leave one idle. NPU is scored above
267
+ * the iGPU (faster for int8 detection AND frees the GPU).
268
+ */
269
+ function enumerateInferenceDevices(hw) {
270
+ const { scores } = scoreRuntimes(hw);
271
+ const out = [];
272
+ for (const s of scores) {
273
+ if (s.backend === "openvino") {
274
+ if (hw.npu?.type === "intel-npu") out.push(device("openvino", "npu", s.format, s.score + 2));
275
+ if (hw.gpu?.type === "intel") out.push(device("openvino", "gpu", s.format, s.score));
276
+ if (hw.gpu?.type === "amd") out.push(device("openvino", "cpu", s.format, s.score));
277
+ continue;
278
+ }
279
+ if (s.backend === "edgetpu") {
280
+ for (const unit of coralUsableUnits(hw.coral)) out.push(device("edgetpu", unit.device, s.format, s.score));
281
+ continue;
282
+ }
283
+ if (s.backend === "onnx" && s.reason.startsWith("ONNX WebGPU")) {
284
+ out.push(device("onnx", "webgpu", s.format, s.score));
285
+ continue;
286
+ }
287
+ const dev = DEVICE_FOR_BACKEND[s.backend] ?? s.backend;
288
+ out.push(device(s.backend, dev, s.format, s.score));
289
+ }
290
+ return out;
291
+ }
292
+ //#endregion
293
+ //#region src/builtins/platform-probe/coral-accelerators.ts
294
+ /**
295
+ * Coral USB Edge TPU USB identifiers.
296
+ *
297
+ * The device enumerates as `1a6e:089a` (Global Unichip) BEFORE the libedgetpu
298
+ * firmware loads, then re-enumerates as `18d1:9302` (Google) AFTER. Either id
299
+ * means a Coral is physically attached, so both count as a positive signal.
300
+ */
301
+ var CORAL_USB_IDS = [{
302
+ vendor: "1a6e",
303
+ product: "089a"
304
+ }, {
305
+ vendor: "18d1",
306
+ product: "9302"
307
+ }];
308
+ /** The PCIe / M.2 Coral's PCI function id (Global Unichip "Apex"). */
309
+ var CORAL_PCI_VENDOR = "0x1ac1";
310
+ var CORAL_PCI_DEVICE = "0x089a";
311
+ /** A unit the apex driver bound: `/sys/class/apex/apex_<N>` ↔ `/dev/apex_<N>`. */
312
+ var APEX_ENTRY = /^apex_(\d+)$/;
313
+ function currentDelegateHost() {
314
+ return {
315
+ platform: process.platform,
316
+ dataDir: nodeDataRootFromEnv(process.env),
317
+ override: process.env[EDGETPU_LIB_ENV]
318
+ };
319
+ }
320
+ /** usbfs names a device `/dev/bus/usb/<busnum>/<devnum>`, each zero-padded to three digits. */
321
+ function usbDeviceNode(device, fsx) {
322
+ const bus = Number.parseInt(fsx.readUsbAttr(device, "busnum"), 10);
323
+ const dev = Number.parseInt(fsx.readUsbAttr(device, "devnum"), 10);
324
+ if (!Number.isInteger(bus) || !Number.isInteger(dev) || bus <= 0 || dev <= 0) return null;
325
+ return `/dev/bus/usb/${String(bus).padStart(3, "0")}/${String(dev).padStart(3, "0")}`;
326
+ }
327
+ /**
328
+ * USB units: sysfs is the HOST's view — a container whose `/dev/bus/usb`
329
+ * mapping was removed still lists the stick under `/sys/bus/usb/devices`. A
330
+ * listed Coral is usable only when its usbfs device node is in this process's
331
+ * view AND opens read/write; otherwise it is present but not accessible.
332
+ */
333
+ function classifyUsb(devices, fsx) {
334
+ let usable = 0;
335
+ const inaccessibleNodes = [];
336
+ for (const device of devices) {
337
+ const vendor = fsx.readUsbAttr(device, "idVendor").toLowerCase();
338
+ const product = fsx.readUsbAttr(device, "idProduct").toLowerCase();
339
+ if (!CORAL_USB_IDS.some((id) => id.vendor === vendor && id.product === product)) continue;
340
+ const node = usbDeviceNode(device, fsx);
341
+ if (node !== null && fsx.exists(node) && fsx.canOpen(node)) usable++;
342
+ else inaccessibleNodes.push(node ?? `/sys/bus/usb/devices/${device}`);
343
+ }
344
+ return {
345
+ usable,
346
+ inaccessibleNodes
347
+ };
348
+ }
349
+ function countPciCorals(fsx) {
350
+ let count = 0;
351
+ for (const device of fsx.listPciDevices()) {
352
+ const vendor = fsx.readPciAttr(device, "vendor").toLowerCase();
353
+ const product = fsx.readPciAttr(device, "device").toLowerCase();
354
+ if (vendor === CORAL_PCI_VENDOR && product === CORAL_PCI_DEVICE) count++;
355
+ }
356
+ return count;
357
+ }
358
+ /**
359
+ * PCIe units: each `/sys/class/apex/apex_N` is a unit the driver bound; it is
360
+ * usable only when `/dev/apex_N` is in this process's view AND opens read/write.
361
+ * PCI functions with the Coral id beyond the bound units have no driver.
362
+ */
363
+ function classifyPci(fsx) {
364
+ let usable = 0;
365
+ let notAccessible = 0;
366
+ for (const entry of fsx.listApexClass()) {
367
+ const match = APEX_ENTRY.exec(entry);
368
+ if (match === null) continue;
369
+ const node = `/dev/apex_${match[1]}`;
370
+ if (fsx.exists(node) && fsx.canOpen(node)) usable++;
371
+ else notAccessible++;
372
+ }
373
+ const driverMissing = Math.max(0, countPciCorals(fsx) - usable - notAccessible);
374
+ return {
375
+ usable,
376
+ notAccessible,
377
+ driverMissing
378
+ };
379
+ }
380
+ /**
381
+ * Detect Coral Edge TPUs on USB and PCIe/M.2 — the answer only. See
382
+ * {@link detectCoralAccelerator} for the evidence that decided it.
383
+ */
384
+ function classifyCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
385
+ return detectCoralAccelerator(fsx, delegateHost).info;
386
+ }
387
+ /**
388
+ * Detect Coral Edge TPUs on USB and PCIe/M.2, with the evidence that decided.
389
+ *
390
+ * - USB: every matching USB device counts (multiple Corals run concurrently),
391
+ * usable only if its `/dev/bus/usb/<BBB>/<DDD>` node opens read/write — a
392
+ * listed stick whose node is missing or refused is `device-not-accessible`.
393
+ * - PCIe: the apex driver's units, each usable only if its device node opens;
394
+ * a Coral PCI function the driver did not bind is `driver-missing`.
395
+ * - Fallback: when the USB bus is NOT OBSERVABLE (`/sys/bus/usb/devices`
396
+ * missing, unreadable or empty — a macOS desktop, a restricted container)
397
+ * and no PCI Coral was seen, an installed libedgetpu delegate means one USB
398
+ * Coral is assumed. A bus that IS readable and lists no Coral id is the
399
+ * answer: no USB Coral. The delegate stays installed after a stick is
400
+ * unplugged or moved to another node, so it is evidence only where nothing
401
+ * better exists (D919).
402
+ *
403
+ * Returns `null` only when no Coral was found at all; a present-but-unusable
404
+ * Coral is reported with its typed reason, never as absent (D393/D315).
405
+ */
406
+ function detectCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
407
+ const usbDevices = fsx.listUsbDevices();
408
+ const usbBus = usbDevices !== null && usbDevices.length > 0 ? "observed" : "unobservable";
409
+ const usb = usbDevices === null ? {
410
+ usable: 0,
411
+ inaccessibleNodes: []
412
+ } : classifyUsb(usbDevices, fsx);
413
+ const usbSeen = usb.usable + usb.inaccessibleNodes.length;
414
+ const inaccessibleUsbNodes = usb.inaccessibleNodes;
415
+ const pci = classifyPci(fsx);
416
+ const units = [];
417
+ if (usb.usable > 0) units.push({
418
+ bus: "usb",
419
+ count: usb.usable
420
+ });
421
+ if (pci.usable > 0) units.push({
422
+ bus: "pci",
423
+ count: pci.usable
424
+ });
425
+ const unavailable = [];
426
+ if (usb.inaccessibleNodes.length > 0) unavailable.push({
427
+ bus: "usb",
428
+ count: usb.inaccessibleNodes.length,
429
+ reason: "device-not-accessible"
430
+ });
431
+ if (pci.driverMissing > 0) unavailable.push({
432
+ bus: "pci",
433
+ count: pci.driverMissing,
434
+ reason: "driver-missing"
435
+ });
436
+ if (pci.notAccessible > 0) unavailable.push({
437
+ bus: "pci",
438
+ count: pci.notAccessible,
439
+ reason: "device-not-accessible"
440
+ });
441
+ if (units.length > 0 || unavailable.length > 0) return {
442
+ info: unavailable.length > 0 ? {
443
+ type: "coral-edgetpu",
444
+ units,
445
+ unavailable
446
+ } : {
447
+ type: "coral-edgetpu",
448
+ units
449
+ },
450
+ usbBus,
451
+ decidedBy: usbSeen > 0 ? "usb-ids" : "pci",
452
+ inaccessibleUsbNodes
453
+ };
454
+ if (usbBus === "unobservable" && chooseEdgetpuDelegate({
455
+ ...delegateHost,
456
+ exists: (p) => fsx.exists(p)
457
+ }) !== null) return {
458
+ info: {
459
+ type: "coral-edgetpu",
460
+ units: [{
461
+ bus: "usb",
462
+ count: 1
463
+ }]
464
+ },
465
+ usbBus,
466
+ decidedBy: "delegate-fallback",
467
+ inaccessibleUsbNodes
468
+ };
469
+ return {
470
+ info: null,
471
+ usbBus,
472
+ decidedBy: "none",
473
+ inaccessibleUsbNodes
474
+ };
475
+ }
476
+ function safeListOrNull(dir) {
477
+ try {
478
+ return fs.readdirSync(dir);
479
+ } catch {
480
+ return null;
481
+ }
482
+ }
483
+ function safeList(dir) {
484
+ try {
485
+ return fs.readdirSync(dir);
486
+ } catch {
487
+ return [];
488
+ }
489
+ }
490
+ function safeRead(path) {
491
+ try {
492
+ return fs.readFileSync(path, "utf8").trim();
493
+ } catch {
494
+ return "";
495
+ }
496
+ }
497
+ /** The real filesystem view: `/sys` for enumeration, `/dev` for access. */
498
+ var nodeCoralFs = {
499
+ listUsbDevices: () => safeListOrNull("/sys/bus/usb/devices"),
500
+ readUsbAttr: (device, attr) => safeRead(`/sys/bus/usb/devices/${device}/${attr}`),
501
+ listPciDevices: () => safeList("/sys/bus/pci/devices"),
502
+ readPciAttr: (device, attr) => safeRead(`/sys/bus/pci/devices/${device}/${attr}`),
503
+ listApexClass: () => safeList("/sys/class/apex"),
504
+ canOpen: (path) => {
505
+ try {
506
+ fs.accessSync(path, fs.constants.R_OK | fs.constants.W_OK);
507
+ return true;
508
+ } catch {
509
+ return false;
510
+ }
511
+ },
512
+ exists: (path) => {
513
+ try {
514
+ return fs.existsSync(path);
515
+ } catch {
516
+ return false;
517
+ }
518
+ }
519
+ };
520
+ //#endregion
521
+ export { enumerateInferenceDevices as a, describeNvidia as i, detectCoralAccelerator as n, scoreRuntimes as o, nodeCoralFs as r, supportedRuntimes as s, classifyCoralAccelerator as t };