@camstack/system 1.2.469 → 1.2.470
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.
- package/dist/addon-runner.js +56 -25
- package/dist/addon-runner.mjs +56 -25
- package/dist/addon-utils.mjs +1 -1
- package/dist/{agent-https-5OgOR-eF.js → agent-https-D_oo3PNv.js} +1 -1
- package/dist/{agent-https-b-zX78oB.mjs → agent-https-DmNQyAl7.mjs} +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
- package/dist/builtins/alerts/alerts.addon.js +1 -1
- package/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
- package/dist/builtins/calendars/calendars.addon.js +1 -1
- package/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- package/dist/builtins/composer/composer.addon.js +2 -2
- package/dist/builtins/composer/composer.addon.mjs +2 -2
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
- package/dist/builtins/device-history/device-history.addon.js +1 -1
- package/dist/builtins/device-history/device-history.addon.mjs +1 -1
- package/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +3 -3
- package/dist/builtins/keychain/index.mjs +3 -3
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
- package/dist/builtins/local-network/local-network.addon.js +2 -2
- package/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
- package/dist/builtins/platform-probe/accelerator-reprobe.d.ts +23 -0
- package/dist/builtins/platform-probe/coral-accelerators.d.ts +37 -8
- package/dist/builtins/platform-probe/index.d.ts +17 -1
- package/dist/builtins/platform-probe/index.js +192 -11
- package/dist/builtins/platform-probe/index.mjs +198 -18
- package/dist/builtins/platform-probe/platform-scorer.d.ts +14 -0
- package/dist/builtins/record-entries/index.js +1 -1
- package/dist/builtins/record-entries/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
- package/dist/builtins/sqlite-storage/index.js +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/dist/builtins/system-config/system-config.addon.js +3 -3
- package/dist/builtins/system-config/system-config.addon.mjs +115 -115
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-DTdzzyf0.mjs → composition-sources-B0tqvf0t.mjs} +1 -1
- package/dist/{composition-sources-BGXTiUZm.js → composition-sources-CRJffEiB.js} +1 -1
- package/dist/{constants-md_POijo.mjs → constants--A505iuO.mjs} +1 -1
- package/dist/{constants-2mPqJjkR.js → constants-WF1AqoKF.js} +1 -1
- package/dist/{coral-accelerators-oUXmmbc2.js → coral-accelerators-Cri32b7q.js} +61 -24
- package/dist/{coral-accelerators-Qhn5TOYZ.mjs → coral-accelerators-Dl-GnMHn.mjs} +61 -30
- package/dist/{custom-action-registry-DZSCLBuT.mjs → custom-action-registry-BGYDjTqY.mjs} +37 -37
- package/dist/{device-ca-CFdyrqeJ.mjs → device-ca-DYmToMp8.mjs} +1 -1
- package/dist/{device-ca-CC58lmNV.js → device-ca-R4MZZtc0.js} +1 -1
- package/dist/{dist-DuBtzSCh.js → dist-DRL3rEfN.js} +77 -2
- package/dist/{dist-CtVVtyTX.mjs → dist-X1r44BdF.mjs} +77 -2
- package/dist/file-host-worker.js +1 -1
- package/dist/file-host-worker.mjs +1 -1
- package/dist/{hub-mdns-ciao-CmuWLPci.mjs → hub-mdns-ciao-CZV5Hion.mjs} +2 -2
- package/dist/{hub-mdns-ciao-BLsX_2cL.js → hub-mdns-ciao-DUoTS6jN.js} +2 -2
- package/dist/index.js +8 -8
- package/dist/index.mjs +225 -225
- package/dist/{restore-archive-CxPAuaNs.js → restore-archive-Df6PsOHP.js} +1 -1
- package/dist/{restore-archive-D2w3z_ob.mjs → restore-archive-X0ciGMmO.mjs} +94 -94
- package/dist/{wal-maintenance-DeluFl_1.mjs → wal-maintenance-D6J_MmZ8.mjs} +0 -0
- package/dist/{wal-maintenance-EK28XXnc.js → wal-maintenance-DYvzJiuK.js} +0 -0
- package/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-
|
|
6
|
+
const require_dist = require("../../dist-DRL3rEfN.js");
|
|
7
7
|
const require_formatter = require("../../formatter-DqAKDlvN.js");
|
|
8
8
|
const require_log_file_read_protocol = require("../../log-file-read-protocol-D0WcLbIV.js");
|
|
9
9
|
let node_path = require("node:path");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ln as logDestinationCapability, ei as BaseAddon } from "../../dist-
|
|
1
|
+
import { Ln as logDestinationCapability, ei as BaseAddon } from "../../dist-X1r44BdF.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
|
|
3
3
|
import { a as LogFileIndexStore, i as serveRead, n as isFromReader, t as CancelBook } from "../../log-file-read-protocol-B7M3X3bT.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $r as errMsg, Kr as compositionSourceKey } from "./dist-
|
|
1
|
+
import { $r as errMsg, Kr as compositionSourceKey } from "./dist-X1r44BdF.mjs";
|
|
2
2
|
//#region src/builtins/core-blocks/composition-sources.ts
|
|
3
3
|
/**
|
|
4
4
|
* Describe what a composition reads and writes for SAVE-time validation
|
|
@@ -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-
|
|
2
|
+
var MESH_CA_KEY_REF = require("./dist-DRL3rEfN.js").buildSecretRef({
|
|
3
3
|
owner: "system",
|
|
4
4
|
scope: { kind: "global" },
|
|
5
5
|
fieldPath: "meshCaKey"
|
|
@@ -29,9 +29,9 @@ function currentDelegateHost() {
|
|
|
29
29
|
override: process.env[_camstack_types_node.EDGETPU_LIB_ENV]
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
function countUsbCorals(fsx) {
|
|
32
|
+
function countUsbCorals(devices, fsx) {
|
|
33
33
|
let count = 0;
|
|
34
|
-
for (const device of
|
|
34
|
+
for (const device of devices) {
|
|
35
35
|
const vendor = fsx.readUsbAttr(device, "idVendor").toLowerCase();
|
|
36
36
|
const product = fsx.readUsbAttr(device, "idProduct").toLowerCase();
|
|
37
37
|
if (CORAL_USB_IDS.some((id) => id.vendor === vendor && id.product === product)) count++;
|
|
@@ -70,21 +70,33 @@ function classifyPci(fsx) {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
* Detect Coral Edge TPUs on USB and PCIe/M.2.
|
|
73
|
+
* Detect Coral Edge TPUs on USB and PCIe/M.2 — the answer only. See
|
|
74
|
+
* {@link detectCoralAccelerator} for the evidence that decided it.
|
|
75
|
+
*/
|
|
76
|
+
function classifyCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
|
|
77
|
+
return detectCoralAccelerator(fsx, delegateHost).info;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Detect Coral Edge TPUs on USB and PCIe/M.2, with the evidence that decided.
|
|
74
81
|
*
|
|
75
82
|
* - USB: every matching USB device counts (multiple Corals run concurrently).
|
|
76
83
|
* - PCIe: the apex driver's units, each usable only if its device node opens;
|
|
77
84
|
* a Coral PCI function the driver did not bind is `driver-missing`.
|
|
78
|
-
* - Fallback: when
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
85
|
+
* - Fallback: when the USB bus is NOT OBSERVABLE (`/sys/bus/usb/devices`
|
|
86
|
+
* missing, unreadable or empty — a macOS desktop, a restricted container)
|
|
87
|
+
* and no PCI Coral was seen, an installed libedgetpu delegate means one USB
|
|
88
|
+
* Coral is assumed. A bus that IS readable and lists no Coral id is the
|
|
89
|
+
* answer: no USB Coral. The delegate stays installed after a stick is
|
|
90
|
+
* unplugged or moved to another node, so it is evidence only where nothing
|
|
91
|
+
* better exists (D919).
|
|
82
92
|
*
|
|
83
93
|
* Returns `null` only when no Coral was found at all; a present-but-unusable
|
|
84
94
|
* Coral is reported with its typed reason, never as absent (D393/D315).
|
|
85
95
|
*/
|
|
86
|
-
function
|
|
87
|
-
const
|
|
96
|
+
function detectCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
|
|
97
|
+
const usbDevices = fsx.listUsbDevices();
|
|
98
|
+
const usbBus = usbDevices !== null && usbDevices.length > 0 ? "observed" : "unobservable";
|
|
99
|
+
const usb = usbDevices === null ? 0 : countUsbCorals(usbDevices, fsx);
|
|
88
100
|
const pci = classifyPci(fsx);
|
|
89
101
|
const units = [];
|
|
90
102
|
if (usb > 0) units.push({
|
|
@@ -106,25 +118,44 @@ function classifyCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
|
|
|
106
118
|
count: pci.notAccessible,
|
|
107
119
|
reason: "device-not-accessible"
|
|
108
120
|
});
|
|
109
|
-
if (units.length > 0 || unavailable.length > 0) return
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
121
|
+
if (units.length > 0 || unavailable.length > 0) return {
|
|
122
|
+
info: unavailable.length > 0 ? {
|
|
123
|
+
type: "coral-edgetpu",
|
|
124
|
+
units,
|
|
125
|
+
unavailable
|
|
126
|
+
} : {
|
|
127
|
+
type: "coral-edgetpu",
|
|
128
|
+
units
|
|
129
|
+
},
|
|
130
|
+
usbBus,
|
|
131
|
+
decidedBy: usb > 0 ? "usb-ids" : "pci"
|
|
116
132
|
};
|
|
117
|
-
if ((0, _camstack_types_node.chooseEdgetpuDelegate)({
|
|
133
|
+
if (usbBus === "unobservable" && (0, _camstack_types_node.chooseEdgetpuDelegate)({
|
|
118
134
|
...delegateHost,
|
|
119
135
|
exists: (p) => fsx.exists(p)
|
|
120
136
|
}) !== null) return {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
137
|
+
info: {
|
|
138
|
+
type: "coral-edgetpu",
|
|
139
|
+
units: [{
|
|
140
|
+
bus: "usb",
|
|
141
|
+
count: 1
|
|
142
|
+
}]
|
|
143
|
+
},
|
|
144
|
+
usbBus,
|
|
145
|
+
decidedBy: "delegate-fallback"
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
info: null,
|
|
149
|
+
usbBus,
|
|
150
|
+
decidedBy: "none"
|
|
126
151
|
};
|
|
127
|
-
|
|
152
|
+
}
|
|
153
|
+
function safeListOrNull(dir) {
|
|
154
|
+
try {
|
|
155
|
+
return node_fs.default.readdirSync(dir);
|
|
156
|
+
} catch {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
128
159
|
}
|
|
129
160
|
function safeList(dir) {
|
|
130
161
|
try {
|
|
@@ -142,7 +173,7 @@ function safeRead(path) {
|
|
|
142
173
|
}
|
|
143
174
|
/** The real filesystem view: `/sys` for enumeration, `/dev` for access. */
|
|
144
175
|
var nodeCoralFs = {
|
|
145
|
-
listUsbDevices: () =>
|
|
176
|
+
listUsbDevices: () => safeListOrNull("/sys/bus/usb/devices"),
|
|
146
177
|
readUsbAttr: (device, attr) => safeRead(`/sys/bus/usb/devices/${device}/${attr}`),
|
|
147
178
|
listPciDevices: () => safeList("/sys/bus/pci/devices"),
|
|
148
179
|
readPciAttr: (device, attr) => safeRead(`/sys/bus/pci/devices/${device}/${attr}`),
|
|
@@ -170,6 +201,12 @@ Object.defineProperty(exports, "classifyCoralAccelerator", {
|
|
|
170
201
|
return classifyCoralAccelerator;
|
|
171
202
|
}
|
|
172
203
|
});
|
|
204
|
+
Object.defineProperty(exports, "detectCoralAccelerator", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
get: function() {
|
|
207
|
+
return detectCoralAccelerator;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
173
210
|
Object.defineProperty(exports, "nodeCoralFs", {
|
|
174
211
|
enumerable: true,
|
|
175
212
|
get: function() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EDGETPU_LIB_ENV, chooseEdgetpuDelegate, nodeDataRootFromEnv } from "@camstack/types/node";
|
|
2
|
-
import
|
|
2
|
+
import Kt from "node:fs";
|
|
3
3
|
//#region src/builtins/platform-probe/coral-accelerators.ts
|
|
4
4
|
/**
|
|
5
5
|
* Coral USB Edge TPU USB identifiers.
|
|
@@ -27,9 +27,9 @@ function currentDelegateHost() {
|
|
|
27
27
|
override: process.env[EDGETPU_LIB_ENV]
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function countUsbCorals(fsx) {
|
|
30
|
+
function countUsbCorals(devices, fsx) {
|
|
31
31
|
let count = 0;
|
|
32
|
-
for (const device of
|
|
32
|
+
for (const device of devices) {
|
|
33
33
|
const vendor = fsx.readUsbAttr(device, "idVendor").toLowerCase();
|
|
34
34
|
const product = fsx.readUsbAttr(device, "idProduct").toLowerCase();
|
|
35
35
|
if (CORAL_USB_IDS.some((id) => id.vendor === vendor && id.product === product)) count++;
|
|
@@ -68,21 +68,33 @@ function classifyPci(fsx) {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* Detect Coral Edge TPUs on USB and PCIe/M.2.
|
|
71
|
+
* Detect Coral Edge TPUs on USB and PCIe/M.2 — the answer only. See
|
|
72
|
+
* {@link detectCoralAccelerator} for the evidence that decided it.
|
|
73
|
+
*/
|
|
74
|
+
function classifyCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
|
|
75
|
+
return detectCoralAccelerator(fsx, delegateHost).info;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Detect Coral Edge TPUs on USB and PCIe/M.2, with the evidence that decided.
|
|
72
79
|
*
|
|
73
80
|
* - USB: every matching USB device counts (multiple Corals run concurrently).
|
|
74
81
|
* - PCIe: the apex driver's units, each usable only if its device node opens;
|
|
75
82
|
* a Coral PCI function the driver did not bind is `driver-missing`.
|
|
76
|
-
* - Fallback: when
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
83
|
+
* - Fallback: when the USB bus is NOT OBSERVABLE (`/sys/bus/usb/devices`
|
|
84
|
+
* missing, unreadable or empty — a macOS desktop, a restricted container)
|
|
85
|
+
* and no PCI Coral was seen, an installed libedgetpu delegate means one USB
|
|
86
|
+
* Coral is assumed. A bus that IS readable and lists no Coral id is the
|
|
87
|
+
* answer: no USB Coral. The delegate stays installed after a stick is
|
|
88
|
+
* unplugged or moved to another node, so it is evidence only where nothing
|
|
89
|
+
* better exists (D919).
|
|
80
90
|
*
|
|
81
91
|
* Returns `null` only when no Coral was found at all; a present-but-unusable
|
|
82
92
|
* Coral is reported with its typed reason, never as absent (D393/D315).
|
|
83
93
|
*/
|
|
84
|
-
function
|
|
85
|
-
const
|
|
94
|
+
function detectCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
|
|
95
|
+
const usbDevices = fsx.listUsbDevices();
|
|
96
|
+
const usbBus = usbDevices !== null && usbDevices.length > 0 ? "observed" : "unobservable";
|
|
97
|
+
const usb = usbDevices === null ? 0 : countUsbCorals(usbDevices, fsx);
|
|
86
98
|
const pci = classifyPci(fsx);
|
|
87
99
|
const units = [];
|
|
88
100
|
if (usb > 0) units.push({
|
|
@@ -104,50 +116,69 @@ function classifyCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
|
|
|
104
116
|
count: pci.notAccessible,
|
|
105
117
|
reason: "device-not-accessible"
|
|
106
118
|
});
|
|
107
|
-
if (units.length > 0 || unavailable.length > 0) return
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
119
|
+
if (units.length > 0 || unavailable.length > 0) return {
|
|
120
|
+
info: unavailable.length > 0 ? {
|
|
121
|
+
type: "coral-edgetpu",
|
|
122
|
+
units,
|
|
123
|
+
unavailable
|
|
124
|
+
} : {
|
|
125
|
+
type: "coral-edgetpu",
|
|
126
|
+
units
|
|
127
|
+
},
|
|
128
|
+
usbBus,
|
|
129
|
+
decidedBy: usb > 0 ? "usb-ids" : "pci"
|
|
114
130
|
};
|
|
115
|
-
if (chooseEdgetpuDelegate({
|
|
131
|
+
if (usbBus === "unobservable" && chooseEdgetpuDelegate({
|
|
116
132
|
...delegateHost,
|
|
117
133
|
exists: (p) => fsx.exists(p)
|
|
118
134
|
}) !== null) return {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
135
|
+
info: {
|
|
136
|
+
type: "coral-edgetpu",
|
|
137
|
+
units: [{
|
|
138
|
+
bus: "usb",
|
|
139
|
+
count: 1
|
|
140
|
+
}]
|
|
141
|
+
},
|
|
142
|
+
usbBus,
|
|
143
|
+
decidedBy: "delegate-fallback"
|
|
124
144
|
};
|
|
125
|
-
return
|
|
145
|
+
return {
|
|
146
|
+
info: null,
|
|
147
|
+
usbBus,
|
|
148
|
+
decidedBy: "none"
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function safeListOrNull(dir) {
|
|
152
|
+
try {
|
|
153
|
+
return Kt.readdirSync(dir);
|
|
154
|
+
} catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
126
157
|
}
|
|
127
158
|
function safeList(dir) {
|
|
128
159
|
try {
|
|
129
|
-
return
|
|
160
|
+
return Kt.readdirSync(dir);
|
|
130
161
|
} catch {
|
|
131
162
|
return [];
|
|
132
163
|
}
|
|
133
164
|
}
|
|
134
165
|
function safeRead(path) {
|
|
135
166
|
try {
|
|
136
|
-
return
|
|
167
|
+
return Kt.readFileSync(path, "utf8").trim();
|
|
137
168
|
} catch {
|
|
138
169
|
return "";
|
|
139
170
|
}
|
|
140
171
|
}
|
|
141
172
|
/** The real filesystem view: `/sys` for enumeration, `/dev` for access. */
|
|
142
173
|
var nodeCoralFs = {
|
|
143
|
-
listUsbDevices: () =>
|
|
174
|
+
listUsbDevices: () => safeListOrNull("/sys/bus/usb/devices"),
|
|
144
175
|
readUsbAttr: (device, attr) => safeRead(`/sys/bus/usb/devices/${device}/${attr}`),
|
|
145
176
|
listPciDevices: () => safeList("/sys/bus/pci/devices"),
|
|
146
177
|
readPciAttr: (device, attr) => safeRead(`/sys/bus/pci/devices/${device}/${attr}`),
|
|
147
178
|
listApexClass: () => safeList("/sys/class/apex"),
|
|
148
179
|
canOpen: (path) => {
|
|
149
180
|
try {
|
|
150
|
-
|
|
181
|
+
Kt.accessSync(path, Kt.constants.R_OK | Kt.constants.W_OK);
|
|
151
182
|
return true;
|
|
152
183
|
} catch {
|
|
153
184
|
return false;
|
|
@@ -155,11 +186,11 @@ var nodeCoralFs = {
|
|
|
155
186
|
},
|
|
156
187
|
exists: (path) => {
|
|
157
188
|
try {
|
|
158
|
-
return
|
|
189
|
+
return Kt.existsSync(path);
|
|
159
190
|
} catch {
|
|
160
191
|
return false;
|
|
161
192
|
}
|
|
162
193
|
}
|
|
163
194
|
};
|
|
164
195
|
//#endregion
|
|
165
|
-
export {
|
|
196
|
+
export { detectCoralAccelerator as n, nodeCoralFs as r, classifyCoralAccelerator as t };
|
|
@@ -3,7 +3,7 @@ import * as path$1 from "node:path";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
import { HF_REPO, MODEL_FORMATS, describeCustomActions, hfModelUrl } from "@camstack/types/addon";
|
|
6
|
-
import * as fs
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
7
|
import { createReadStream, promises } from "node:fs";
|
|
8
8
|
import { createServer } from "node:http";
|
|
9
9
|
import { brotliCompress, constants as constants$1, gzip } from "node:zlib";
|
|
@@ -159,7 +159,7 @@ var HOSTED_MODEL_REVISIONS = {
|
|
|
159
159
|
//#endregion
|
|
160
160
|
//#region src/download/model-downloader.ts
|
|
161
161
|
function isNonEmptyFile(filePath) {
|
|
162
|
-
return fs
|
|
162
|
+
return fs.existsSync(filePath) && fs.statSync(filePath).size > 0;
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
165
165
|
* Sibling files of a single-file (non-directory) format — extra files the
|
|
@@ -236,11 +236,11 @@ function resolveRedirectUrl(current, location) {
|
|
|
236
236
|
return new URL(location, current);
|
|
237
237
|
}
|
|
238
238
|
async function downloadFile(url, destPath, onProgressOrOptions) {
|
|
239
|
-
if (fs
|
|
239
|
+
if (fs.existsSync(destPath)) return destPath;
|
|
240
240
|
const opts = normalizeDownloadOptions(onProgressOrOptions);
|
|
241
241
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
242
242
|
const maxRedirects = opts.maxRedirects ?? DEFAULT_MAX_REDIRECTS;
|
|
243
|
-
fs
|
|
243
|
+
fs.mkdirSync(path$1.dirname(destPath), { recursive: true });
|
|
244
244
|
const tmpPath = destPath + ".downloading";
|
|
245
245
|
try {
|
|
246
246
|
let current = url;
|
|
@@ -278,7 +278,7 @@ async function downloadFile(url, destPath, onProgressOrOptions) {
|
|
|
278
278
|
if (!response.body) throw new Error(`No response body from ${url}`);
|
|
279
279
|
const total = parseInt(response.headers.get("content-length") ?? "0", 10);
|
|
280
280
|
let downloaded = 0;
|
|
281
|
-
const fileStream = fs
|
|
281
|
+
const fileStream = fs.createWriteStream(tmpPath);
|
|
282
282
|
const reader = response.body.getReader();
|
|
283
283
|
try {
|
|
284
284
|
for (;;) {
|
|
@@ -296,11 +296,11 @@ async function downloadFile(url, destPath, onProgressOrOptions) {
|
|
|
296
296
|
fileStream.on("error", reject);
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
|
-
fs
|
|
299
|
+
fs.renameSync(tmpPath, destPath);
|
|
300
300
|
return destPath;
|
|
301
301
|
} catch (err) {
|
|
302
302
|
try {
|
|
303
|
-
fs
|
|
303
|
+
fs.unlinkSync(tmpPath);
|
|
304
304
|
} catch {}
|
|
305
305
|
throw err;
|
|
306
306
|
}
|
|
@@ -324,12 +324,12 @@ async function downloadModel(options) {
|
|
|
324
324
|
const { url, fallbackUrls = [], destDir, filename, expectedSha256, onProgress } = options;
|
|
325
325
|
const fname = filename ?? url.split("/").pop() ?? "model.bin";
|
|
326
326
|
const destPath = path$1.join(destDir, fname);
|
|
327
|
-
if (fs
|
|
327
|
+
if (fs.existsSync(destPath)) return {
|
|
328
328
|
filePath: destPath,
|
|
329
329
|
downloadedBytes: 0,
|
|
330
330
|
fromCache: true
|
|
331
331
|
};
|
|
332
|
-
fs
|
|
332
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
333
333
|
const urls = [url, ...fallbackUrls];
|
|
334
334
|
let lastError = null;
|
|
335
335
|
for (const tryUrl of urls) try {
|
|
@@ -337,25 +337,25 @@ async function downloadModel(options) {
|
|
|
337
337
|
if (expectedSha256) {
|
|
338
338
|
const hash = await computeSha256(destPath);
|
|
339
339
|
if (hash !== expectedSha256) {
|
|
340
|
-
fs
|
|
340
|
+
fs.unlinkSync(destPath);
|
|
341
341
|
throw new Error(`SHA256 mismatch: expected ${expectedSha256}, got ${hash}`);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
return {
|
|
345
345
|
filePath: destPath,
|
|
346
|
-
downloadedBytes: fs
|
|
346
|
+
downloadedBytes: fs.statSync(destPath).size,
|
|
347
347
|
fromCache: false
|
|
348
348
|
};
|
|
349
349
|
} catch (e) {
|
|
350
350
|
lastError = e;
|
|
351
|
-
if (fs
|
|
351
|
+
if (fs.existsSync(destPath)) fs.unlinkSync(destPath);
|
|
352
352
|
}
|
|
353
353
|
throw lastError ?? /* @__PURE__ */ new Error(`Failed to download model from ${url}`);
|
|
354
354
|
}
|
|
355
355
|
async function computeSha256(filePath) {
|
|
356
356
|
return new Promise((resolve, reject) => {
|
|
357
357
|
const hash = createHash("sha256");
|
|
358
|
-
const stream = fs
|
|
358
|
+
const stream = fs.createReadStream(filePath);
|
|
359
359
|
stream.on("data", (chunk) => hash.update(chunk));
|
|
360
360
|
stream.on("end", () => resolve(hash.digest("hex")));
|
|
361
361
|
stream.on("error", reject);
|
|
@@ -380,28 +380,28 @@ async function downloadDirectory(url, destDir, knownFiles, onProgress) {
|
|
|
380
380
|
fileUrl: `https://huggingface.co/${repo}/resolve/main/${dirPath}/${f}`
|
|
381
381
|
}));
|
|
382
382
|
const tmpDir = destDir + ".downloading";
|
|
383
|
-
fs
|
|
383
|
+
fs.rmSync(tmpDir, {
|
|
384
384
|
recursive: true,
|
|
385
385
|
force: true
|
|
386
386
|
});
|
|
387
|
-
fs
|
|
387
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
388
388
|
let totalDownloaded = 0;
|
|
389
389
|
try {
|
|
390
390
|
for (const file of files) {
|
|
391
391
|
const destPath = path$1.join(tmpDir, file.relativePath);
|
|
392
|
-
fs
|
|
392
|
+
fs.mkdirSync(path$1.dirname(destPath), { recursive: true });
|
|
393
393
|
await downloadFile(file.fileUrl, destPath, (downloaded, _total) => {
|
|
394
394
|
onProgress?.(totalDownloaded + downloaded, void 0);
|
|
395
395
|
});
|
|
396
|
-
totalDownloaded += fs
|
|
396
|
+
totalDownloaded += fs.statSync(destPath).size;
|
|
397
397
|
}
|
|
398
|
-
fs
|
|
398
|
+
fs.rmSync(destDir, {
|
|
399
399
|
recursive: true,
|
|
400
400
|
force: true
|
|
401
401
|
});
|
|
402
|
-
fs
|
|
402
|
+
fs.renameSync(tmpDir, destDir);
|
|
403
403
|
} catch (err) {
|
|
404
|
-
fs
|
|
404
|
+
fs.rmSync(tmpDir, {
|
|
405
405
|
recursive: true,
|
|
406
406
|
force: true
|
|
407
407
|
});
|
|
@@ -433,7 +433,7 @@ function revisionRecordPath(modelPath) {
|
|
|
433
433
|
}
|
|
434
434
|
function readRevisionRecord(modelPath) {
|
|
435
435
|
try {
|
|
436
|
-
return fs
|
|
436
|
+
return fs.readFileSync(revisionRecordPath(modelPath), "utf8").trim();
|
|
437
437
|
} catch {
|
|
438
438
|
return null;
|
|
439
439
|
}
|
|
@@ -497,8 +497,8 @@ function writeRevisionRecord(modelPath, revision) {
|
|
|
497
497
|
if (revision === void 0) return;
|
|
498
498
|
const record = revisionRecordPath(modelPath);
|
|
499
499
|
const tmp = `${record}.tmp`;
|
|
500
|
-
fs
|
|
501
|
-
fs
|
|
500
|
+
fs.writeFileSync(tmp, `${revision}\n`);
|
|
501
|
+
fs.renameSync(tmp, record);
|
|
502
502
|
}
|
|
503
503
|
/**
|
|
504
504
|
* Prove an unrecorded (or differently recorded) copy current by hashing its
|
|
@@ -518,9 +518,9 @@ async function adoptByHash(modelsDir, modelPath, formatEntry) {
|
|
|
518
518
|
}
|
|
519
519
|
/** True when every file of the format is on disk, whatever revision it holds. */
|
|
520
520
|
function isCompleteCopy(modelsDir, modelPath, formatEntry) {
|
|
521
|
-
if (!fs
|
|
522
|
-
if (formatEntry.isDirectory) return fs
|
|
523
|
-
if (fs
|
|
521
|
+
if (!fs.existsSync(modelPath)) return false;
|
|
522
|
+
if (formatEntry.isDirectory) return fs.existsSync(path$1.join(modelPath, "Manifest.json"));
|
|
523
|
+
if (fs.statSync(modelPath).size <= 0) return false;
|
|
524
524
|
return siblingFilesFor(formatEntry).every((f) => isNonEmptyFile(path$1.join(modelsDir, f)));
|
|
525
525
|
}
|
|
526
526
|
/**
|
|
@@ -542,14 +542,14 @@ async function replaceSingleFileFormat(url, modelPath, modelsDir, siblings, onPr
|
|
|
542
542
|
}));
|
|
543
543
|
try {
|
|
544
544
|
for (const [i, part] of parts.entries()) {
|
|
545
|
-
fs
|
|
545
|
+
fs.rmSync(part.staged, { force: true });
|
|
546
546
|
await downloadFile(part.url, part.staged, i === 0 ? (downloaded, total) => onProgress?.(downloaded, total === 0 ? void 0 : total) : void 0);
|
|
547
547
|
}
|
|
548
548
|
} catch (err) {
|
|
549
|
-
for (const part of parts) fs
|
|
549
|
+
for (const part of parts) fs.rmSync(part.staged, { force: true });
|
|
550
550
|
throw err;
|
|
551
551
|
}
|
|
552
|
-
for (const part of parts) fs
|
|
552
|
+
for (const part of parts) fs.renameSync(part.staged, part.dest);
|
|
553
553
|
}
|
|
554
554
|
/**
|
|
555
555
|
* Resolve a `ModelCatalogEntry` against `modelsDir`: download model file
|
|
@@ -564,14 +564,14 @@ async function ensureModel(modelsDir, entry, format, onProgress) {
|
|
|
564
564
|
const modelPath = path$1.join(modelsDir, filename);
|
|
565
565
|
const siblings = siblingFilesFor(formatEntry);
|
|
566
566
|
let outdated = false;
|
|
567
|
-
if (fs
|
|
567
|
+
if (fs.existsSync(modelPath)) if (formatEntry.isDirectory && !fs.existsSync(path$1.join(modelPath, "Manifest.json"))) fs.rmSync(modelPath, {
|
|
568
568
|
recursive: true,
|
|
569
569
|
force: true
|
|
570
570
|
});
|
|
571
571
|
else if (siblings.some((f) => !isNonEmptyFile(path$1.join(modelsDir, f)))) outdated = !isCurrentRevision(modelPath, formatEntry) && !await adoptByHash(modelsDir, modelPath, formatEntry);
|
|
572
572
|
else if (isCurrentRevision(modelPath, formatEntry) || await adoptByHash(modelsDir, modelPath, formatEntry)) return modelPath;
|
|
573
573
|
else outdated = true;
|
|
574
|
-
fs
|
|
574
|
+
fs.mkdirSync(modelsDir, { recursive: true });
|
|
575
575
|
if (formatEntry.isDirectory) await downloadDirectory(formatEntry.url, modelPath, formatEntry.files, onProgress);
|
|
576
576
|
else if (outdated) await replaceSingleFileFormat(formatEntry.url, modelPath, modelsDir, siblings, onProgress);
|
|
577
577
|
else {
|
|
@@ -629,25 +629,25 @@ function isModelDownloaded(modelsDir, entry, format) {
|
|
|
629
629
|
const formatEntry = entry.formats[format];
|
|
630
630
|
if (!formatEntry) return false;
|
|
631
631
|
const modelPath = getModelFilePath(modelsDir, entry, format);
|
|
632
|
-
if (!modelPath || !fs
|
|
632
|
+
if (!modelPath || !fs.existsSync(modelPath)) return false;
|
|
633
633
|
if (!isCurrentRevision(modelPath, formatEntry)) return false;
|
|
634
634
|
return isCompleteCopy(modelsDir, modelPath, formatEntry);
|
|
635
635
|
}
|
|
636
636
|
/** Remove the on-disk model file/directory. Returns true if something was deleted. */
|
|
637
637
|
function deleteModelFromDisk(modelsDir, entry, format) {
|
|
638
638
|
const modelPath = getModelFilePath(modelsDir, entry, format);
|
|
639
|
-
if (!modelPath || !fs
|
|
640
|
-
fs
|
|
639
|
+
if (!modelPath || !fs.existsSync(modelPath)) return false;
|
|
640
|
+
fs.rmSync(revisionRecordPath(modelPath), { force: true });
|
|
641
641
|
const formatEntry = entry.formats[format];
|
|
642
|
-
if (formatEntry?.isDirectory) fs
|
|
642
|
+
if (formatEntry?.isDirectory) fs.rmSync(modelPath, {
|
|
643
643
|
recursive: true,
|
|
644
644
|
force: true
|
|
645
645
|
});
|
|
646
646
|
else {
|
|
647
|
-
fs
|
|
647
|
+
fs.unlinkSync(modelPath);
|
|
648
648
|
if (formatEntry) for (const sibling of siblingFilesFor(formatEntry)) {
|
|
649
649
|
const sibPath = path$1.join(modelsDir, sibling);
|
|
650
|
-
if (fs
|
|
650
|
+
if (fs.existsSync(sibPath)) fs.unlinkSync(sibPath);
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
653
|
return true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as DEVICE_SAN_USER_PREFIX, Ri as buildSecretRef, k as DEVICE_SAN_CREDENTIAL_PREFIX } from "./dist-
|
|
1
|
+
import { A as DEVICE_SAN_USER_PREFIX, Ri as buildSecretRef, k as DEVICE_SAN_CREDENTIAL_PREFIX } from "./dist-X1r44BdF.mjs";
|
|
2
2
|
import { S as backdatedNotBefore, 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-DK__ETIe.mjs";
|
|
3
3
|
import { X509Certificate, createPublicKey, randomBytes, verify, webcrypto } from "node:crypto";
|
|
4
4
|
//#region src/auth/jwt-signing-key.ts
|