@camstack/system 1.2.458 → 1.2.460
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 +26 -11
- package/dist/addon-runner.mjs +26 -11
- package/dist/addon-utils.mjs +1 -1
- package/dist/{agent-https-DOELEug8.js → agent-https-Dnr_nIVx.js} +3 -723
- package/dist/{agent-https-CQA3W-3e.mjs → agent-https-Iw3RSQup.mjs} +4 -616
- 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 +5 -7
- package/dist/builtins/alerts/alerts.addon.mjs +5 -7
- package/dist/builtins/alerts/record-kinds.d.ts +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 +242 -4
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +243 -5
- package/dist/builtins/calendars/calendars.addon.js +2 -10
- package/dist/builtins/calendars/calendars.addon.mjs +2 -3
- package/dist/builtins/calendars/record-kinds.d.ts +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 +4 -6
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +4 -6
- 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 +2 -4
- package/dist/builtins/device-manager/device-manager.addon.mjs +2 -4
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +41 -43
- package/dist/builtins/keychain/index.mjs +41 -43
- 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 +24 -40
- package/dist/builtins/local-auth/local-auth.addon.mjs +27 -43
- 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 +39 -4
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +48 -13
- package/dist/builtins/native-metrics/node-metrics-history-recorder.d.ts +16 -2
- package/dist/builtins/platform-probe/coral-accelerators.d.ts +10 -1
- package/dist/builtins/platform-probe/index.js +7 -4
- package/dist/builtins/platform-probe/index.mjs +13 -10
- package/dist/builtins/platform-probe/platform-scorer.d.ts +4 -1
- 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/file-host-protocol.d.ts +0 -15
- 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/owned-sqlite-file.d.ts +0 -44
- package/dist/builtins/sqlite-storage/records/records-catalog.d.ts +0 -2
- package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +0 -21
- package/dist/builtins/sqlite-storage/records/records-engine.d.ts +3 -20
- package/dist/builtins/sqlite-storage/records/records-plan.d.ts +9 -4
- package/dist/builtins/sqlite-storage/records/records-provider.d.ts +4 -18
- package/dist/builtins/sqlite-storage/records/records-sql.d.ts +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +0 -17
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +21 -196
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +21 -196
- package/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +6 -14
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +2 -2
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +7 -9
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +7 -9
- package/dist/builtins/system-config/system-config.addon.js +667 -40
- package/dist/builtins/system-config/system-config.addon.mjs +737 -127
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-BVguN7VV.mjs → composition-sources-DNRZWR1j.mjs} +1 -1
- package/dist/{composition-sources-DURQNDJ4.js → composition-sources-b0e_2I-D.js} +1 -1
- package/dist/{constants-Njka8Cv6.js → constants-6OeJiZgi.js} +1 -1
- package/dist/{constants-FGjnsE2x.mjs → constants-BnkOdj9Q.mjs} +1 -1
- package/dist/{coral-accelerators-DcnZvctM.mjs → coral-accelerators-Qhn5TOYZ.mjs} +18 -15
- package/dist/{coral-accelerators-Bi_c3Rft.js → coral-accelerators-oUXmmbc2.js} +13 -10
- package/dist/{custom-action-registry-stpC3Zy-.mjs → custom-action-registry-DStvrQKI.mjs} +37 -37
- package/dist/{device-ca-lEaAQ9Xi.mjs → device-ca-Bnkw8GyU.mjs} +1 -1
- package/dist/{device-ca-BrVK_5s3.js → device-ca-CPTDs--d.js} +1 -1
- package/dist/{dist-BZQjLPiz.js → dist-Bn-RNanh.js} +29 -130
- package/dist/{dist-B_GRPhnY.mjs → dist-Wy8cTxg6.mjs} +30 -113
- package/dist/file-host-worker.js +1 -1
- package/dist/file-host-worker.mjs +1 -1
- package/dist/{hub-mdns-ciao-Bg2HfTwP.mjs → hub-mdns-ciao-CJu0nhla.mjs} +2 -2
- package/dist/{hub-mdns-ciao-nce3TXs_.js → hub-mdns-ciao-CTBTlia4.js} +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +56 -31
- package/dist/index.mjs +257 -233
- package/dist/kernel/deps/addon-deps-manager.d.ts +9 -0
- package/dist/{restore-archive-C7kLDI_0.mjs → restore-archive-CM23Pq9B.mjs} +177 -424
- package/dist/{restore-archive-FyfZ8YMC.js → restore-archive-DM1OBYq4.js} +89 -342
- package/dist/{wal-maintenance-Duejh7Lx.mjs → wal-maintenance-Bj_MmDkr.mjs} +0 -0
- package/dist/{wal-maintenance-DfSIOj24.js → wal-maintenance-CaJjuLHq.js} +0 -0
- package/package.json +1 -1
- package/dist/builtins/records/legacy-table-row-count.d.ts +0 -5
- package/dist/builtins/records/phase6-declare-gate.d.ts +0 -28
- package/dist/builtins/sqlite-storage/records/count-settings-array-legacy.d.ts +0 -5
- package/dist/builtins/sqlite-storage/records/count-settings-brokers-legacy.d.ts +0 -6
- package/dist/phase6-declare-gate-Dag1_WR2.js +0 -98
- package/dist/phase6-declare-gate-Lb-mrVvz.mjs +0 -93
|
@@ -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-Bn-RNanh.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 { ni as BaseAddon, zn as logDestinationCapability } from "../../dist-
|
|
1
|
+
import { ni as BaseAddon, zn as logDestinationCapability } from "../../dist-Wy8cTxg6.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 { Jr as compositionSourceKey, ti as errMsg } from "./dist-
|
|
1
|
+
import { Jr as compositionSourceKey, ti as errMsg } from "./dist-Wy8cTxg6.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-Bn-RNanh.js").buildSecretRef({
|
|
3
3
|
owner: "system",
|
|
4
4
|
scope: { kind: "global" },
|
|
5
5
|
fieldPath: "meshCaKey"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EDGETPU_LIB_ENV, chooseEdgetpuDelegate, nodeDataRootFromEnv } from "@camstack/types/node";
|
|
2
|
+
import fs from "node:fs";
|
|
2
3
|
//#region src/builtins/platform-probe/coral-accelerators.ts
|
|
3
4
|
/**
|
|
4
5
|
* Coral USB Edge TPU USB identifiers.
|
|
@@ -19,13 +20,13 @@ var CORAL_PCI_VENDOR = "0x1ac1";
|
|
|
19
20
|
var CORAL_PCI_DEVICE = "0x089a";
|
|
20
21
|
/** A unit the apex driver bound: `/sys/class/apex/apex_<N>` ↔ `/dev/apex_<N>`. */
|
|
21
22
|
var APEX_ENTRY = /^apex_(\d+)$/;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
function currentDelegateHost() {
|
|
24
|
+
return {
|
|
25
|
+
platform: process.platform,
|
|
26
|
+
dataDir: nodeDataRootFromEnv(process.env),
|
|
27
|
+
override: process.env[EDGETPU_LIB_ENV]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
29
30
|
function countUsbCorals(fsx) {
|
|
30
31
|
let count = 0;
|
|
31
32
|
for (const device of fsx.listUsbDevices()) {
|
|
@@ -80,7 +81,7 @@ function classifyPci(fsx) {
|
|
|
80
81
|
* Returns `null` only when no Coral was found at all; a present-but-unusable
|
|
81
82
|
* Coral is reported with its typed reason, never as absent (D393/D315).
|
|
82
83
|
*/
|
|
83
|
-
function classifyCoralAccelerator(fsx) {
|
|
84
|
+
function classifyCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
|
|
84
85
|
const usb = countUsbCorals(fsx);
|
|
85
86
|
const pci = classifyPci(fsx);
|
|
86
87
|
const units = [];
|
|
@@ -111,8 +112,10 @@ function classifyCoralAccelerator(fsx) {
|
|
|
111
112
|
type: "coral-edgetpu",
|
|
112
113
|
units
|
|
113
114
|
};
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
if (chooseEdgetpuDelegate({
|
|
116
|
+
...delegateHost,
|
|
117
|
+
exists: (p) => fsx.exists(p)
|
|
118
|
+
}) !== null) return {
|
|
116
119
|
type: "coral-edgetpu",
|
|
117
120
|
units: [{
|
|
118
121
|
bus: "usb",
|
|
@@ -123,14 +126,14 @@ function classifyCoralAccelerator(fsx) {
|
|
|
123
126
|
}
|
|
124
127
|
function safeList(dir) {
|
|
125
128
|
try {
|
|
126
|
-
return
|
|
129
|
+
return fs.readdirSync(dir);
|
|
127
130
|
} catch {
|
|
128
131
|
return [];
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
134
|
function safeRead(path) {
|
|
132
135
|
try {
|
|
133
|
-
return
|
|
136
|
+
return fs.readFileSync(path, "utf8").trim();
|
|
134
137
|
} catch {
|
|
135
138
|
return "";
|
|
136
139
|
}
|
|
@@ -144,7 +147,7 @@ var nodeCoralFs = {
|
|
|
144
147
|
listApexClass: () => safeList("/sys/class/apex"),
|
|
145
148
|
canOpen: (path) => {
|
|
146
149
|
try {
|
|
147
|
-
|
|
150
|
+
fs.accessSync(path, fs.constants.R_OK | fs.constants.W_OK);
|
|
148
151
|
return true;
|
|
149
152
|
} catch {
|
|
150
153
|
return false;
|
|
@@ -152,7 +155,7 @@ var nodeCoralFs = {
|
|
|
152
155
|
},
|
|
153
156
|
exists: (path) => {
|
|
154
157
|
try {
|
|
155
|
-
return
|
|
158
|
+
return fs.existsSync(path);
|
|
156
159
|
} catch {
|
|
157
160
|
return false;
|
|
158
161
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Cek0wNdY.js");
|
|
2
|
+
let _camstack_types_node = require("@camstack/types/node");
|
|
2
3
|
let node_fs = require("node:fs");
|
|
3
4
|
node_fs = require_chunk.__toESM(node_fs);
|
|
4
5
|
//#region src/builtins/platform-probe/coral-accelerators.ts
|
|
@@ -21,13 +22,13 @@ var CORAL_PCI_VENDOR = "0x1ac1";
|
|
|
21
22
|
var CORAL_PCI_DEVICE = "0x089a";
|
|
22
23
|
/** A unit the apex driver bound: `/sys/class/apex/apex_<N>` ↔ `/dev/apex_<N>`. */
|
|
23
24
|
var APEX_ENTRY = /^apex_(\d+)$/;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
function currentDelegateHost() {
|
|
26
|
+
return {
|
|
27
|
+
platform: process.platform,
|
|
28
|
+
dataDir: (0, _camstack_types_node.nodeDataRootFromEnv)(process.env),
|
|
29
|
+
override: process.env[_camstack_types_node.EDGETPU_LIB_ENV]
|
|
30
|
+
};
|
|
31
|
+
}
|
|
31
32
|
function countUsbCorals(fsx) {
|
|
32
33
|
let count = 0;
|
|
33
34
|
for (const device of fsx.listUsbDevices()) {
|
|
@@ -82,7 +83,7 @@ function classifyPci(fsx) {
|
|
|
82
83
|
* Returns `null` only when no Coral was found at all; a present-but-unusable
|
|
83
84
|
* Coral is reported with its typed reason, never as absent (D393/D315).
|
|
84
85
|
*/
|
|
85
|
-
function classifyCoralAccelerator(fsx) {
|
|
86
|
+
function classifyCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
|
|
86
87
|
const usb = countUsbCorals(fsx);
|
|
87
88
|
const pci = classifyPci(fsx);
|
|
88
89
|
const units = [];
|
|
@@ -113,8 +114,10 @@ function classifyCoralAccelerator(fsx) {
|
|
|
113
114
|
type: "coral-edgetpu",
|
|
114
115
|
units
|
|
115
116
|
};
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
if ((0, _camstack_types_node.chooseEdgetpuDelegate)({
|
|
118
|
+
...delegateHost,
|
|
119
|
+
exists: (p) => fsx.exists(p)
|
|
120
|
+
}) !== null) return {
|
|
118
121
|
type: "coral-edgetpu",
|
|
119
122
|
units: [{
|
|
120
123
|
bus: "usb",
|
|
@@ -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 from "node:fs";
|
|
6
|
+
import * as fs$1 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";
|
|
@@ -157,7 +157,7 @@ var HOSTED_MODEL_REVISIONS = {
|
|
|
157
157
|
//#endregion
|
|
158
158
|
//#region src/download/model-downloader.ts
|
|
159
159
|
function isNonEmptyFile(filePath) {
|
|
160
|
-
return fs.existsSync(filePath) && fs.statSync(filePath).size > 0;
|
|
160
|
+
return fs$1.existsSync(filePath) && fs$1.statSync(filePath).size > 0;
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
163
|
* Sibling files of a single-file (non-directory) format — extra files the
|
|
@@ -234,11 +234,11 @@ function resolveRedirectUrl(current, location) {
|
|
|
234
234
|
return new URL(location, current);
|
|
235
235
|
}
|
|
236
236
|
async function downloadFile(url, destPath, onProgressOrOptions) {
|
|
237
|
-
if (fs.existsSync(destPath)) return destPath;
|
|
237
|
+
if (fs$1.existsSync(destPath)) return destPath;
|
|
238
238
|
const opts = normalizeDownloadOptions(onProgressOrOptions);
|
|
239
239
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
240
240
|
const maxRedirects = opts.maxRedirects ?? DEFAULT_MAX_REDIRECTS;
|
|
241
|
-
fs.mkdirSync(path$1.dirname(destPath), { recursive: true });
|
|
241
|
+
fs$1.mkdirSync(path$1.dirname(destPath), { recursive: true });
|
|
242
242
|
const tmpPath = destPath + ".downloading";
|
|
243
243
|
try {
|
|
244
244
|
let current = url;
|
|
@@ -276,7 +276,7 @@ async function downloadFile(url, destPath, onProgressOrOptions) {
|
|
|
276
276
|
if (!response.body) throw new Error(`No response body from ${url}`);
|
|
277
277
|
const total = parseInt(response.headers.get("content-length") ?? "0", 10);
|
|
278
278
|
let downloaded = 0;
|
|
279
|
-
const fileStream = fs.createWriteStream(tmpPath);
|
|
279
|
+
const fileStream = fs$1.createWriteStream(tmpPath);
|
|
280
280
|
const reader = response.body.getReader();
|
|
281
281
|
try {
|
|
282
282
|
for (;;) {
|
|
@@ -294,11 +294,11 @@ async function downloadFile(url, destPath, onProgressOrOptions) {
|
|
|
294
294
|
fileStream.on("error", reject);
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
|
-
fs.renameSync(tmpPath, destPath);
|
|
297
|
+
fs$1.renameSync(tmpPath, destPath);
|
|
298
298
|
return destPath;
|
|
299
299
|
} catch (err) {
|
|
300
300
|
try {
|
|
301
|
-
fs.unlinkSync(tmpPath);
|
|
301
|
+
fs$1.unlinkSync(tmpPath);
|
|
302
302
|
} catch {}
|
|
303
303
|
throw err;
|
|
304
304
|
}
|
|
@@ -322,12 +322,12 @@ async function downloadModel(options) {
|
|
|
322
322
|
const { url, fallbackUrls = [], destDir, filename, expectedSha256, onProgress } = options;
|
|
323
323
|
const fname = filename ?? url.split("/").pop() ?? "model.bin";
|
|
324
324
|
const destPath = path$1.join(destDir, fname);
|
|
325
|
-
if (fs.existsSync(destPath)) return {
|
|
325
|
+
if (fs$1.existsSync(destPath)) return {
|
|
326
326
|
filePath: destPath,
|
|
327
327
|
downloadedBytes: 0,
|
|
328
328
|
fromCache: true
|
|
329
329
|
};
|
|
330
|
-
fs.mkdirSync(destDir, { recursive: true });
|
|
330
|
+
fs$1.mkdirSync(destDir, { recursive: true });
|
|
331
331
|
const urls = [url, ...fallbackUrls];
|
|
332
332
|
let lastError = null;
|
|
333
333
|
for (const tryUrl of urls) try {
|
|
@@ -335,25 +335,25 @@ async function downloadModel(options) {
|
|
|
335
335
|
if (expectedSha256) {
|
|
336
336
|
const hash = await computeSha256(destPath);
|
|
337
337
|
if (hash !== expectedSha256) {
|
|
338
|
-
fs.unlinkSync(destPath);
|
|
338
|
+
fs$1.unlinkSync(destPath);
|
|
339
339
|
throw new Error(`SHA256 mismatch: expected ${expectedSha256}, got ${hash}`);
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
return {
|
|
343
343
|
filePath: destPath,
|
|
344
|
-
downloadedBytes: fs.statSync(destPath).size,
|
|
344
|
+
downloadedBytes: fs$1.statSync(destPath).size,
|
|
345
345
|
fromCache: false
|
|
346
346
|
};
|
|
347
347
|
} catch (e) {
|
|
348
348
|
lastError = e;
|
|
349
|
-
if (fs.existsSync(destPath)) fs.unlinkSync(destPath);
|
|
349
|
+
if (fs$1.existsSync(destPath)) fs$1.unlinkSync(destPath);
|
|
350
350
|
}
|
|
351
351
|
throw lastError ?? /* @__PURE__ */ new Error(`Failed to download model from ${url}`);
|
|
352
352
|
}
|
|
353
353
|
async function computeSha256(filePath) {
|
|
354
354
|
return new Promise((resolve, reject) => {
|
|
355
355
|
const hash = createHash("sha256");
|
|
356
|
-
const stream = fs.createReadStream(filePath);
|
|
356
|
+
const stream = fs$1.createReadStream(filePath);
|
|
357
357
|
stream.on("data", (chunk) => hash.update(chunk));
|
|
358
358
|
stream.on("end", () => resolve(hash.digest("hex")));
|
|
359
359
|
stream.on("error", reject);
|
|
@@ -378,28 +378,28 @@ async function downloadDirectory(url, destDir, knownFiles, onProgress) {
|
|
|
378
378
|
fileUrl: `https://huggingface.co/${repo}/resolve/main/${dirPath}/${f}`
|
|
379
379
|
}));
|
|
380
380
|
const tmpDir = destDir + ".downloading";
|
|
381
|
-
fs.rmSync(tmpDir, {
|
|
381
|
+
fs$1.rmSync(tmpDir, {
|
|
382
382
|
recursive: true,
|
|
383
383
|
force: true
|
|
384
384
|
});
|
|
385
|
-
fs.mkdirSync(tmpDir, { recursive: true });
|
|
385
|
+
fs$1.mkdirSync(tmpDir, { recursive: true });
|
|
386
386
|
let totalDownloaded = 0;
|
|
387
387
|
try {
|
|
388
388
|
for (const file of files) {
|
|
389
389
|
const destPath = path$1.join(tmpDir, file.relativePath);
|
|
390
|
-
fs.mkdirSync(path$1.dirname(destPath), { recursive: true });
|
|
390
|
+
fs$1.mkdirSync(path$1.dirname(destPath), { recursive: true });
|
|
391
391
|
await downloadFile(file.fileUrl, destPath, (downloaded, _total) => {
|
|
392
392
|
onProgress?.(totalDownloaded + downloaded, void 0);
|
|
393
393
|
});
|
|
394
|
-
totalDownloaded += fs.statSync(destPath).size;
|
|
394
|
+
totalDownloaded += fs$1.statSync(destPath).size;
|
|
395
395
|
}
|
|
396
|
-
fs.rmSync(destDir, {
|
|
396
|
+
fs$1.rmSync(destDir, {
|
|
397
397
|
recursive: true,
|
|
398
398
|
force: true
|
|
399
399
|
});
|
|
400
|
-
fs.renameSync(tmpDir, destDir);
|
|
400
|
+
fs$1.renameSync(tmpDir, destDir);
|
|
401
401
|
} catch (err) {
|
|
402
|
-
fs.rmSync(tmpDir, {
|
|
402
|
+
fs$1.rmSync(tmpDir, {
|
|
403
403
|
recursive: true,
|
|
404
404
|
force: true
|
|
405
405
|
});
|
|
@@ -431,7 +431,7 @@ function revisionRecordPath(modelPath) {
|
|
|
431
431
|
}
|
|
432
432
|
function readRevisionRecord(modelPath) {
|
|
433
433
|
try {
|
|
434
|
-
return fs.readFileSync(revisionRecordPath(modelPath), "utf8").trim();
|
|
434
|
+
return fs$1.readFileSync(revisionRecordPath(modelPath), "utf8").trim();
|
|
435
435
|
} catch {
|
|
436
436
|
return null;
|
|
437
437
|
}
|
|
@@ -495,8 +495,8 @@ function writeRevisionRecord(modelPath, revision) {
|
|
|
495
495
|
if (revision === void 0) return;
|
|
496
496
|
const record = revisionRecordPath(modelPath);
|
|
497
497
|
const tmp = `${record}.tmp`;
|
|
498
|
-
fs.writeFileSync(tmp, `${revision}\n`);
|
|
499
|
-
fs.renameSync(tmp, record);
|
|
498
|
+
fs$1.writeFileSync(tmp, `${revision}\n`);
|
|
499
|
+
fs$1.renameSync(tmp, record);
|
|
500
500
|
}
|
|
501
501
|
/**
|
|
502
502
|
* Prove an unrecorded (or differently recorded) copy current by hashing its
|
|
@@ -516,9 +516,9 @@ async function adoptByHash(modelsDir, modelPath, formatEntry) {
|
|
|
516
516
|
}
|
|
517
517
|
/** True when every file of the format is on disk, whatever revision it holds. */
|
|
518
518
|
function isCompleteCopy(modelsDir, modelPath, formatEntry) {
|
|
519
|
-
if (!fs.existsSync(modelPath)) return false;
|
|
520
|
-
if (formatEntry.isDirectory) return fs.existsSync(path$1.join(modelPath, "Manifest.json"));
|
|
521
|
-
if (fs.statSync(modelPath).size <= 0) return false;
|
|
519
|
+
if (!fs$1.existsSync(modelPath)) return false;
|
|
520
|
+
if (formatEntry.isDirectory) return fs$1.existsSync(path$1.join(modelPath, "Manifest.json"));
|
|
521
|
+
if (fs$1.statSync(modelPath).size <= 0) return false;
|
|
522
522
|
return siblingFilesFor(formatEntry).every((f) => isNonEmptyFile(path$1.join(modelsDir, f)));
|
|
523
523
|
}
|
|
524
524
|
/**
|
|
@@ -540,14 +540,14 @@ async function replaceSingleFileFormat(url, modelPath, modelsDir, siblings, onPr
|
|
|
540
540
|
}));
|
|
541
541
|
try {
|
|
542
542
|
for (const [i, part] of parts.entries()) {
|
|
543
|
-
fs.rmSync(part.staged, { force: true });
|
|
543
|
+
fs$1.rmSync(part.staged, { force: true });
|
|
544
544
|
await downloadFile(part.url, part.staged, i === 0 ? (downloaded, total) => onProgress?.(downloaded, total === 0 ? void 0 : total) : void 0);
|
|
545
545
|
}
|
|
546
546
|
} catch (err) {
|
|
547
|
-
for (const part of parts) fs.rmSync(part.staged, { force: true });
|
|
547
|
+
for (const part of parts) fs$1.rmSync(part.staged, { force: true });
|
|
548
548
|
throw err;
|
|
549
549
|
}
|
|
550
|
-
for (const part of parts) fs.renameSync(part.staged, part.dest);
|
|
550
|
+
for (const part of parts) fs$1.renameSync(part.staged, part.dest);
|
|
551
551
|
}
|
|
552
552
|
/**
|
|
553
553
|
* Resolve a `ModelCatalogEntry` against `modelsDir`: download model file
|
|
@@ -562,14 +562,14 @@ async function ensureModel(modelsDir, entry, format, onProgress) {
|
|
|
562
562
|
const modelPath = path$1.join(modelsDir, filename);
|
|
563
563
|
const siblings = siblingFilesFor(formatEntry);
|
|
564
564
|
let outdated = false;
|
|
565
|
-
if (fs.existsSync(modelPath)) if (formatEntry.isDirectory && !fs.existsSync(path$1.join(modelPath, "Manifest.json"))) fs.rmSync(modelPath, {
|
|
565
|
+
if (fs$1.existsSync(modelPath)) if (formatEntry.isDirectory && !fs$1.existsSync(path$1.join(modelPath, "Manifest.json"))) fs$1.rmSync(modelPath, {
|
|
566
566
|
recursive: true,
|
|
567
567
|
force: true
|
|
568
568
|
});
|
|
569
569
|
else if (siblings.some((f) => !isNonEmptyFile(path$1.join(modelsDir, f)))) outdated = !isCurrentRevision(modelPath, formatEntry) && !await adoptByHash(modelsDir, modelPath, formatEntry);
|
|
570
570
|
else if (isCurrentRevision(modelPath, formatEntry) || await adoptByHash(modelsDir, modelPath, formatEntry)) return modelPath;
|
|
571
571
|
else outdated = true;
|
|
572
|
-
fs.mkdirSync(modelsDir, { recursive: true });
|
|
572
|
+
fs$1.mkdirSync(modelsDir, { recursive: true });
|
|
573
573
|
if (formatEntry.isDirectory) await downloadDirectory(formatEntry.url, modelPath, formatEntry.files, onProgress);
|
|
574
574
|
else if (outdated) await replaceSingleFileFormat(formatEntry.url, modelPath, modelsDir, siblings, onProgress);
|
|
575
575
|
else {
|
|
@@ -627,25 +627,25 @@ function isModelDownloaded(modelsDir, entry, format) {
|
|
|
627
627
|
const formatEntry = entry.formats[format];
|
|
628
628
|
if (!formatEntry) return false;
|
|
629
629
|
const modelPath = getModelFilePath(modelsDir, entry, format);
|
|
630
|
-
if (!modelPath || !fs.existsSync(modelPath)) return false;
|
|
630
|
+
if (!modelPath || !fs$1.existsSync(modelPath)) return false;
|
|
631
631
|
if (!isCurrentRevision(modelPath, formatEntry)) return false;
|
|
632
632
|
return isCompleteCopy(modelsDir, modelPath, formatEntry);
|
|
633
633
|
}
|
|
634
634
|
/** Remove the on-disk model file/directory. Returns true if something was deleted. */
|
|
635
635
|
function deleteModelFromDisk(modelsDir, entry, format) {
|
|
636
636
|
const modelPath = getModelFilePath(modelsDir, entry, format);
|
|
637
|
-
if (!modelPath || !fs.existsSync(modelPath)) return false;
|
|
638
|
-
fs.rmSync(revisionRecordPath(modelPath), { force: true });
|
|
637
|
+
if (!modelPath || !fs$1.existsSync(modelPath)) return false;
|
|
638
|
+
fs$1.rmSync(revisionRecordPath(modelPath), { force: true });
|
|
639
639
|
const formatEntry = entry.formats[format];
|
|
640
|
-
if (formatEntry?.isDirectory) fs.rmSync(modelPath, {
|
|
640
|
+
if (formatEntry?.isDirectory) fs$1.rmSync(modelPath, {
|
|
641
641
|
recursive: true,
|
|
642
642
|
force: true
|
|
643
643
|
});
|
|
644
644
|
else {
|
|
645
|
-
fs.unlinkSync(modelPath);
|
|
645
|
+
fs$1.unlinkSync(modelPath);
|
|
646
646
|
if (formatEntry) for (const sibling of siblingFilesFor(formatEntry)) {
|
|
647
647
|
const sibPath = path$1.join(modelsDir, sibling);
|
|
648
|
-
if (fs.existsSync(sibPath)) fs.unlinkSync(sibPath);
|
|
648
|
+
if (fs$1.existsSync(sibPath)) fs$1.unlinkSync(sibPath);
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
651
|
return true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as DEVICE_SAN_CREDENTIAL_PREFIX, Li as buildSecretRef, j as DEVICE_SAN_USER_PREFIX } from "./dist-
|
|
1
|
+
import { A as DEVICE_SAN_CREDENTIAL_PREFIX, Li as buildSecretRef, j as DEVICE_SAN_USER_PREFIX } from "./dist-Wy8cTxg6.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
|