home-hosted 0.10.3 → 0.11.0
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/README.md +1 -1
- package/dist/cli.js +753 -398
- package/dist/cli.js.map +1 -1
- package/docs/DDNS.md +3 -2
- package/docs/NOTIFICATIONS.md +3 -1
- package/docs/RESTORE_DEMO.md +5 -3
- package/docs/SERVERS.md +6 -2
- package/docs/UI_CREATION.md +9 -4
- package/package.json +1 -2
- package/uis/stock/dist/assets/{de-CiSKBON6.js → de-0YLueNal.js} +1 -1
- package/uis/stock/dist/assets/{es-BgNQbboq.js → es-FCHhRmn2.js} +1 -1
- package/uis/stock/dist/assets/{fr-WzBF8AXI.js → fr-C69Z8o0z.js} +1 -1
- package/uis/stock/dist/assets/{index-CXDl25BP.js → index-KdyqrVv8.js} +12 -12
- package/uis/stock/dist/assets/{ja-DMQqF4ip.js → ja-Chz9YOqR.js} +1 -1
- package/uis/stock/dist/assets/{ko-DgfSg9v_.js → ko-CtXZ2x1l.js} +1 -1
- package/uis/stock/dist/assets/{ru-DjIByX61.js → ru-D_jE64xN.js} +1 -1
- package/uis/stock/dist/assets/{vi-DOB8nYFC.js → vi-sxSffss7.js} +1 -1
- package/uis/stock/dist/assets/{zh-CN-DZ3WlUgy.js → zh-CN-ChTpf29X.js} +1 -1
- package/uis/stock/dist/index.html +1 -1
- package/uis/stock/dist/ui.json +3 -3
- package/AGENTS.md +0 -403
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import { defineCommand, runCommand } from "citty";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import readline from "node:readline";
|
|
6
6
|
import fs, { createReadStream } from "node:fs";
|
|
7
|
-
import { exec, execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
7
|
+
import cp, { exec, execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
8
8
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
9
9
|
import os from "node:os";
|
|
10
10
|
import { describeRoute, openAPIRouteHandler, resolver, validator } from "hono-openapi";
|
|
@@ -217,11 +217,17 @@ function findArg(argsDef, name) {
|
|
|
217
217
|
* with the wrong policy. This keeps the refusal the command line always had, from
|
|
218
218
|
* citty's own definitions rather than a second list.
|
|
219
219
|
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
220
|
+
* `undefined` means the command parses its own argv — `ui-switch` calls `node:util`'s
|
|
221
|
+
* `parseArgs` with its own options, which is strict already — so it is left alone. An
|
|
222
|
+
* **empty** definition is different: it declares that this command takes nothing, so
|
|
223
|
+
* every flag and every bare word is refused here. Reading `{}` as "parses its own argv"
|
|
224
|
+
* is what let `ui-revert`, which has no parser at all, accept and discard anything:
|
|
225
|
+
* `ui-revert --dry-run` deleted the installed UI and exited 0.
|
|
226
|
+
*
|
|
227
|
+
* Returns the message to print, or null.
|
|
222
228
|
*/
|
|
223
229
|
function rejectUnknownFlags(argv, argsDef) {
|
|
224
|
-
if (argsDef === void 0
|
|
230
|
+
if (argsDef === void 0) return null;
|
|
225
231
|
let positionals = Object.values(argsDef).filter((def) => def?.type === "positional").length;
|
|
226
232
|
for (let index = 0; index < argv.length; index++) {
|
|
227
233
|
const token = argv[index];
|
|
@@ -742,6 +748,100 @@ function secureCookieFor(mode, protocol) {
|
|
|
742
748
|
}
|
|
743
749
|
var init_cookies = __esmMin((() => {}));
|
|
744
750
|
//#endregion
|
|
751
|
+
//#region src/shared/host-readings.ts
|
|
752
|
+
/** A number the frame carries, or null when it carries none. */
|
|
753
|
+
function present(value) {
|
|
754
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* How a per-cpu load sits against the threshold the panel notifies on.
|
|
758
|
+
*
|
|
759
|
+
* The ratio is what a person configures: `host.loadPerCpu` is the count the alert fires at, so
|
|
760
|
+
* `danger` is that number itself and `warn` is the approach to it. `0` disables the alert in
|
|
761
|
+
* `sampleHost`, so nothing can breach it and the band is `ok` — painting a box red for a
|
|
762
|
+
* notification that will never arrive is the same defect as inventing a reading. It lives here
|
|
763
|
+
* rather than in a component so both UIs share one band, the mistake that produced two hardcoded
|
|
764
|
+
* copies of the default.
|
|
765
|
+
*/
|
|
766
|
+
function loadBand(loadPerCpu, alertPerCpu) {
|
|
767
|
+
return thresholdBand(loadPerCpu, alertPerCpu, 2);
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* How a reading sits against the threshold the panel notifies on.
|
|
771
|
+
*
|
|
772
|
+
* `danger` at the threshold is the whole point: the alert fires there, so a bar that stays `warn`
|
|
773
|
+
* while a notification goes out disagrees with the panel's own verdict. `0` disables that alert in
|
|
774
|
+
* `sampleHost`, so nothing can breach it and the band is `ok`. One rule for the per-cpu load, the
|
|
775
|
+
* three percentages and each disk — they differ only in what the number means, and the mistake this
|
|
776
|
+
* replaced was four surfaces each deciding a band for itself.
|
|
777
|
+
*/
|
|
778
|
+
function percentageBand(value, alertAt, fallback) {
|
|
779
|
+
return thresholdBand(value, alertAt, fallback);
|
|
780
|
+
}
|
|
781
|
+
function thresholdBand(value, alertAt, fallback) {
|
|
782
|
+
if (value === null || !Number.isFinite(value)) return null;
|
|
783
|
+
const threshold = alertAt === void 0 || !Number.isFinite(alertAt) ? fallback : alertAt;
|
|
784
|
+
if (threshold <= 0) return "ok";
|
|
785
|
+
if (value >= threshold) return "danger";
|
|
786
|
+
if (value >= threshold * .7) return "warn";
|
|
787
|
+
return "ok";
|
|
788
|
+
}
|
|
789
|
+
/** The readings of one host frame; a missing frame is the same as an unsampled one. */
|
|
790
|
+
function hostReadings(host) {
|
|
791
|
+
if (host === null || host === void 0) return NOTHING_SAMPLED;
|
|
792
|
+
if (!(host.sampledAt !== null)) return {
|
|
793
|
+
...NOTHING_SAMPLED,
|
|
794
|
+
disks: []
|
|
795
|
+
};
|
|
796
|
+
const load1m = present(host.loadAvg[0]);
|
|
797
|
+
const cpus = present(host.cpus);
|
|
798
|
+
const loadPerCpu = load1m === null ? null : load1m / Math.max(1, cpus ?? 1);
|
|
799
|
+
return {
|
|
800
|
+
sampled: true,
|
|
801
|
+
cpuUsedPercent: present(host.cpuUsedPercent),
|
|
802
|
+
memoryUsedPercent: present(host.memoryUsedPercent),
|
|
803
|
+
swapUsedPercent: present(host.swapUsedPercent),
|
|
804
|
+
load1m,
|
|
805
|
+
load5m: present(host.loadAvg[1]),
|
|
806
|
+
load15m: present(host.loadAvg[2]),
|
|
807
|
+
loadPerCpu,
|
|
808
|
+
loadBand: loadBand(loadPerCpu, host.loadAlertPerCpu),
|
|
809
|
+
memoryBand: percentageBand(present(host.memoryUsedPercent), host.memoryUsedPercentAlert, HOST_ALERT_DEFAULTS.memoryUsedPercent),
|
|
810
|
+
swapBand: percentageBand(present(host.swapUsedPercent), host.swapUsedPercentAlert, HOST_ALERT_DEFAULTS.swapUsedPercent),
|
|
811
|
+
tempBand: percentageBand(present(host.tempCelsius), host.tempCelsiusAlert, HOST_ALERT_DEFAULTS.tempCelsius),
|
|
812
|
+
tempCelsius: present(host.tempCelsius),
|
|
813
|
+
disks: host.disks.map((disk) => ({
|
|
814
|
+
...disk,
|
|
815
|
+
band: percentageBand(present(disk.usedPercent), host.diskUsedPercentAlert, HOST_ALERT_DEFAULTS.diskUsedPercent)
|
|
816
|
+
}))
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
var HOST_ALERT_DEFAULTS, NOTHING_SAMPLED;
|
|
820
|
+
var init_host_readings = __esmMin((() => {
|
|
821
|
+
HOST_ALERT_DEFAULTS = {
|
|
822
|
+
diskUsedPercent: 90,
|
|
823
|
+
memoryUsedPercent: 90,
|
|
824
|
+
swapUsedPercent: 50,
|
|
825
|
+
tempCelsius: 85
|
|
826
|
+
};
|
|
827
|
+
NOTHING_SAMPLED = {
|
|
828
|
+
sampled: false,
|
|
829
|
+
cpuUsedPercent: null,
|
|
830
|
+
memoryUsedPercent: null,
|
|
831
|
+
swapUsedPercent: null,
|
|
832
|
+
load1m: null,
|
|
833
|
+
load5m: null,
|
|
834
|
+
load15m: null,
|
|
835
|
+
loadPerCpu: null,
|
|
836
|
+
tempCelsius: null,
|
|
837
|
+
disks: [],
|
|
838
|
+
loadBand: null,
|
|
839
|
+
memoryBand: null,
|
|
840
|
+
swapBand: null,
|
|
841
|
+
tempBand: null
|
|
842
|
+
};
|
|
843
|
+
}));
|
|
844
|
+
//#endregion
|
|
745
845
|
//#region src/shared/contracts.ts
|
|
746
846
|
var contracts_exports = /* @__PURE__ */ __exportAll({
|
|
747
847
|
actionResultSchema: () => actionResultSchema,
|
|
@@ -755,15 +855,21 @@ var contracts_exports = /* @__PURE__ */ __exportAll({
|
|
|
755
855
|
backupFileSchema: () => backupFileSchema,
|
|
756
856
|
backupFilesResponseSchema: () => backupFilesResponseSchema,
|
|
757
857
|
backupHookOrNullSchema: () => backupHookOrNullSchema,
|
|
858
|
+
backupHookPatchOrNullSchema: () => backupHookPatchOrNullSchema,
|
|
859
|
+
backupHookPatchSchema: () => backupHookPatchSchema,
|
|
758
860
|
backupHookSchema: () => backupHookSchema,
|
|
759
861
|
backupScheduleSchema: () => backupScheduleSchema,
|
|
760
862
|
backupScheduleViewSchema: () => backupScheduleViewSchema,
|
|
761
863
|
backupScopeSchema: () => backupScopeSchema,
|
|
864
|
+
backupSelectionSchema: () => backupSelectionSchema,
|
|
762
865
|
backupsSchema: () => backupsSchema,
|
|
763
866
|
backupsViewSchema: () => backupsViewSchema,
|
|
764
867
|
bindSchema: () => bindSchema,
|
|
765
868
|
bootstrapOrNullSchema: () => bootstrapOrNullSchema,
|
|
869
|
+
bootstrapPatchOrNullSchema: () => bootstrapPatchOrNullSchema,
|
|
870
|
+
bootstrapPatchSchema: () => bootstrapPatchSchema,
|
|
766
871
|
bootstrapSchema: () => bootstrapSchema,
|
|
872
|
+
bufferedLogsResponseSchema: () => bufferedLogsResponseSchema,
|
|
767
873
|
controlSchema: () => controlSchema,
|
|
768
874
|
controlViewSchema: () => controlViewSchema,
|
|
769
875
|
ddnsAccountSchema: () => ddnsAccountSchema,
|
|
@@ -910,8 +1016,9 @@ function duplicateWebhookIds(targets) {
|
|
|
910
1016
|
}
|
|
911
1017
|
return [...duplicates];
|
|
912
1018
|
}
|
|
913
|
-
var bindSchema, workspaceIdSchema, workspaceSchema, workspaceCreateSchema, workspaceRenameSchema, portSchema, onPortConflictSchema, onPortConflictDefaultSchema, restartSchema, httpCheckSchema, resourcesSchema, healthSchema, stopSchema, bootstrapSchema, bootstrapOrNullSchema, backupHookSchema, backupHookOrNullSchema, labelOrNullSchema, logBufferLinesSchema, serverSchema, authSchema, notificationPolicyShape, notificationDefaultsSchema, notificationDefaultsViewSchema, useOwnSettingsSchema, telegramDestinationSchema, webhookTargetSchema, notificationTargetSchema, destinationListSchema, notificationsSchema, logsSchema, tlsSchema, hostSchema, ddnsRecordTypeSchema, ddnsAccountSchema, ddnsDomainSchema, ddnsIpv4Schema, ddnsIpv6Schema, ddnsConfigSchema, ddnsRecordStateSchema, ddnsRecordViewSchema, ddnsStatusSchema, ddnsProviderFieldSchema, ddnsProviderInfoSchema, ddnsViewSchema, ddnsCredentialsSchema, ddnsPatchSchema, backupScopeSchema, backupScheduleSchema, backupsSchema, controlSchema, defaultsSchema, restartPatchSchema, httpCheckPatchSchema, resourcesPatchSchema, healthPatchSchema, stopPatchSchema, authPatchSchema, notificationPolicyPatchShape, destinationPatchSchema, notificationsPatchSchema, hostPatchSchema, backupSchedulePatchSchema, backupsPatchSchema, logsPatchSchema, tlsPatchSchema, controlPatchSchema, defaultsPatchSchema, editableFields, serverPatchSchema, serverCreateSchema, nannySpecSchema, nannyExitSchema, nannyStateSchema, entryStateSchema, settingsPatchSchema, workspaceSettingsPatchSchema, authStatusSchema, tlsStatusSchema, proxyEngineSchema, proxyTargetSchema, proxyTlsModeSchema, proxyRouteSchema, proxyCertificateSchema, proxyCertificateStateSchema, proxyDns01Schema, proxyConfigSchema, proxyEngineSourceSchema, proxyEngineStatusSchema, proxyEngineInfoSchema, proxyRouteStatusSchema, proxyRouteViewSchema, proxyRunStateSchema, proxyStatusSchema, proxyCertificateViewSchema, proxyDnsAccountViewSchema, proxyViewSchema, proxyRoutePatchSchema, proxyPatchSchema, proxyCertificateUploadSchema, proxyEngineInstallSchema, notificationPolicyStatusShape, destinationStatusSchema, telegramChatsSchema, notificationViewSchema, sessionViewSchema, loginSchema, passwordValueSchema, passwordSchema, serverStatusSchema, healthStateSchema, portStateSchema, logStreamSchema, logLineSchema, historyActorSchema, historyEventSchema, serverHistorySchema, processResourcesSchema, hostDiskSchema, hostViewSchema, wslTemperatureSchema, backupFileSchema, backupEntrySchema, backupScheduleViewSchema, backupsViewSchema, restoreItemSchema, restoreSkipSchema, restorePlanSchema, backupCreateSchema, restoreRequestSchema, serverViewSchema, healthResponseSchema, controlViewSchema, uiMetaSchema, uiStatusSchema, serverOrphanSchema, workspaceViewSchema, appStateSchema, sseMessageSchema, logQuerySchema, actionResultSchema, deliveryResultSchema, passwordSetResponseSchema, tlsReviewResponseSchema, okResponseSchema, backupFilesResponseSchema, uiInstallResponseSchema, backupCreatedResponseSchema, logLinesResponseSchema, freePortResultSchema, logHistoryQuerySchema, logFileInfoSchema, logServerViewSchema, logServersViewSchema, logHistoryViewSchema, notificationActionSchema, destinationIdParamSchema, destinationTestSchema, telegramTokenSchema, apiErrorSchema, tlsUploadSchema, settingsViewSchema, settingsSavedSchema, workspaceSettingsViewSchema, workspaceSettingsSavedSchema;
|
|
1019
|
+
var bindSchema, workspaceIdSchema, workspaceSchema, workspaceCreateSchema, workspaceRenameSchema, portSchema, onPortConflictSchema, onPortConflictDefaultSchema, restartSchema, httpCheckSchema, resourcesSchema, healthSchema, stopSchema, bootstrapSchema, bootstrapOrNullSchema, bootstrapPatchSchema, bootstrapPatchOrNullSchema, backupHookSchema, backupHookOrNullSchema, backupHookPatchSchema, backupHookPatchOrNullSchema, labelOrNullSchema, logBufferLinesSchema, serverSchema, authSchema, notificationPolicyShape, notificationDefaultsSchema, notificationDefaultsViewSchema, useOwnSettingsSchema, telegramDestinationSchema, webhookTargetSchema, notificationTargetSchema, destinationListSchema, notificationsSchema, logsSchema, tlsSchema, hostSchema, ddnsRecordTypeSchema, ddnsAccountSchema, ddnsDomainSchema, ddnsIpv4Schema, ddnsIpv6Schema, ddnsConfigSchema, ddnsRecordStateSchema, ddnsRecordViewSchema, ddnsStatusSchema, ddnsProviderFieldSchema, ddnsProviderInfoSchema, ddnsViewSchema, ddnsCredentialsSchema, ddnsPatchSchema, backupScopeSchema, backupScheduleSchema, backupsSchema, controlSchema, defaultsSchema, restartPatchSchema, httpCheckPatchSchema, resourcesPatchSchema, healthPatchSchema, stopPatchSchema, authPatchSchema, notificationPolicyPatchShape, destinationPatchSchema, notificationsPatchSchema, hostPatchSchema, backupSchedulePatchSchema, backupsPatchSchema, logsPatchSchema, tlsPatchSchema, controlPatchSchema, defaultsPatchSchema, editableFields, serverPatchSchema, serverCreateSchema, nannySpecSchema, nannyExitSchema, nannyStateSchema, entryStateSchema, settingsPatchSchema, workspaceSettingsPatchSchema, authStatusSchema, tlsStatusSchema, proxyEngineSchema, proxyTargetSchema, proxyTlsModeSchema, proxyRouteSchema, proxyCertificateSchema, proxyCertificateStateSchema, proxyDns01Schema, proxyConfigSchema, proxyEngineSourceSchema, proxyEngineStatusSchema, proxyEngineInfoSchema, proxyRouteStatusSchema, proxyRouteViewSchema, proxyRunStateSchema, proxyStatusSchema, proxyCertificateViewSchema, proxyDnsAccountViewSchema, proxyViewSchema, proxyRoutePatchSchema, proxyPatchSchema, proxyCertificateUploadSchema, proxyEngineInstallSchema, notificationPolicyStatusShape, destinationStatusSchema, telegramChatsSchema, notificationViewSchema, sessionViewSchema, loginSchema, passwordValueSchema, passwordSchema, serverStatusSchema, healthStateSchema, portStateSchema, logStreamSchema, logLineSchema, historyActorSchema, historyEventSchema, serverHistorySchema, processResourcesSchema, hostDiskSchema, hostViewSchema, wslTemperatureSchema, backupFileSchema, backupEntrySchema, backupScheduleViewSchema, backupsViewSchema, backupSelectionSchema, restoreItemSchema, restoreSkipSchema, restorePlanSchema, backupCreateSchema, restoreRequestSchema, serverViewSchema, healthResponseSchema, controlViewSchema, uiMetaSchema, uiStatusSchema, serverOrphanSchema, workspaceViewSchema, appStateSchema, sseMessageSchema, logQuerySchema, actionResultSchema, deliveryResultSchema, passwordSetResponseSchema, tlsReviewResponseSchema, okResponseSchema, backupFilesResponseSchema, uiInstallResponseSchema, backupCreatedResponseSchema, bufferedLogsResponseSchema, logLinesResponseSchema, freePortResultSchema, logHistoryQuerySchema, logFileInfoSchema, logServerViewSchema, logServersViewSchema, logHistoryViewSchema, notificationActionSchema, destinationIdParamSchema, destinationTestSchema, telegramTokenSchema, apiErrorSchema, tlsUploadSchema, settingsViewSchema, settingsSavedSchema, workspaceSettingsViewSchema, workspaceSettingsSavedSchema;
|
|
914
1020
|
var init_contracts = __esmMin((() => {
|
|
1021
|
+
init_host_readings();
|
|
915
1022
|
bindSchema = type("\"local\" | \"lan\" | /^\\d{1,3}(?:\\.\\d{1,3}){3}$/");
|
|
916
1023
|
workspaceIdSchema = type("/^[a-z0-9][a-z0-9_-]*$/");
|
|
917
1024
|
workspaceSchema = type({
|
|
@@ -982,6 +1089,14 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
982
1089
|
runOnce: "boolean = true"
|
|
983
1090
|
}).onUndeclaredKey("reject");
|
|
984
1091
|
bootstrapOrNullSchema = bootstrapSchema.or(type("null"));
|
|
1092
|
+
bootstrapPatchSchema = type({
|
|
1093
|
+
command: "string >= 1?",
|
|
1094
|
+
args: "string[]?",
|
|
1095
|
+
env: "Record<string, string>?",
|
|
1096
|
+
timeoutMs: "number >= 1000?",
|
|
1097
|
+
runOnce: "boolean?"
|
|
1098
|
+
}).onUndeclaredKey("reject");
|
|
1099
|
+
bootstrapPatchOrNullSchema = bootstrapPatchSchema.or(type("null"));
|
|
985
1100
|
backupHookSchema = type({
|
|
986
1101
|
command: "string >= 1",
|
|
987
1102
|
args: type("string[]").default(() => []),
|
|
@@ -998,6 +1113,14 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
998
1113
|
waitMs: "number >= 0 = 2000"
|
|
999
1114
|
}).onUndeclaredKey("reject");
|
|
1000
1115
|
backupHookOrNullSchema = backupHookSchema.or(type("null"));
|
|
1116
|
+
backupHookPatchSchema = type({
|
|
1117
|
+
command: "string >= 1?",
|
|
1118
|
+
args: "string[]?",
|
|
1119
|
+
env: "Record<string, string>?",
|
|
1120
|
+
timeoutMs: "number >= 1000?",
|
|
1121
|
+
waitMs: "number >= 0?"
|
|
1122
|
+
}).onUndeclaredKey("reject");
|
|
1123
|
+
backupHookPatchOrNullSchema = backupHookPatchSchema.or(type("null"));
|
|
1001
1124
|
labelOrNullSchema = type("string | null");
|
|
1002
1125
|
logBufferLinesSchema = type("50 <= number.integer <= 100000");
|
|
1003
1126
|
serverSchema = type({
|
|
@@ -1124,12 +1247,20 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
1124
1247
|
intervalMs: "number >= 5000 = 15000",
|
|
1125
1248
|
/** Filesystems reported and alerted on; templates and `~` are expanded. */
|
|
1126
1249
|
diskPaths: type("string[]").default(() => ["."]),
|
|
1127
|
-
/**
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1250
|
+
/**
|
|
1251
|
+
* 0 disables an individual alert. Each default is written from `HOST_ALERT_DEFAULTS`, so the
|
|
1252
|
+
* number a fresh config gets and the number a surface bands against when a frame carries no
|
|
1253
|
+
* threshold are one value — the same one-home rule `loadPerCpu` follows below.
|
|
1254
|
+
*/
|
|
1255
|
+
diskUsedPercent: `number >= 0 = ${HOST_ALERT_DEFAULTS.diskUsedPercent}`,
|
|
1256
|
+
memoryUsedPercent: `number >= 0 = ${HOST_ALERT_DEFAULTS.memoryUsedPercent}`,
|
|
1257
|
+
swapUsedPercent: `number >= 0 = ${HOST_ALERT_DEFAULTS.swapUsedPercent}`,
|
|
1258
|
+
/**
|
|
1259
|
+
* The per-cpu load the panel notifies on. One home: the frame's `loadAlertPerCpu` is this value,
|
|
1260
|
+
* and `loadBand` reads it, so a surface cannot band the load against a number nobody configured.
|
|
1261
|
+
*/
|
|
1262
|
+
loadPerCpu: type("number >= 0").default(2),
|
|
1263
|
+
tempCelsius: `number >= 0 = ${HOST_ALERT_DEFAULTS.tempCelsius}`,
|
|
1133
1264
|
/**
|
|
1134
1265
|
* How to read the CPU temperature when the kernel exposes no sensor.
|
|
1135
1266
|
*
|
|
@@ -1227,7 +1358,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
1227
1358
|
providers: ddnsProviderInfoSchema.array(),
|
|
1228
1359
|
/** Account ids whose credentials are stored. */
|
|
1229
1360
|
credentials: type("string[]")
|
|
1230
|
-
});
|
|
1361
|
+
}).onDeepUndeclaredKey("ignore");
|
|
1231
1362
|
ddnsCredentialsSchema = type({
|
|
1232
1363
|
provider: "string >= 1",
|
|
1233
1364
|
credentials: type("Record<string, string>")
|
|
@@ -1441,9 +1572,9 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
1441
1572
|
cwd: "string?",
|
|
1442
1573
|
env: "Record<string, string>?",
|
|
1443
1574
|
dataEnvs: "Record<string, string>?",
|
|
1444
|
-
bootstrap:
|
|
1445
|
-
dump:
|
|
1446
|
-
load:
|
|
1575
|
+
bootstrap: bootstrapPatchOrNullSchema.optional(),
|
|
1576
|
+
dump: backupHookPatchOrNullSchema.optional(),
|
|
1577
|
+
load: backupHookPatchOrNullSchema.optional(),
|
|
1447
1578
|
port: portSchema.optional(),
|
|
1448
1579
|
bind: bindSchema.optional(),
|
|
1449
1580
|
onPortConflict: onPortConflictSchema.optional(),
|
|
@@ -1655,7 +1786,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
1655
1786
|
*/
|
|
1656
1787
|
"retryInMinutes?": "number"
|
|
1657
1788
|
})
|
|
1658
|
-
});
|
|
1789
|
+
}).onDeepUndeclaredKey("ignore");
|
|
1659
1790
|
proxyRunStateSchema = type.enumerated("off", "stopped", "starting", "running", "error", "unsupported");
|
|
1660
1791
|
proxyStatusSchema = type({
|
|
1661
1792
|
state: proxyRunStateSchema,
|
|
@@ -1702,7 +1833,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
1702
1833
|
"certificates": proxyCertificateViewSchema.array(),
|
|
1703
1834
|
/** Every DNS account a route may name. Optional: an older panel omits it. */
|
|
1704
1835
|
"dnsAccounts?": proxyDnsAccountViewSchema.array()
|
|
1705
|
-
});
|
|
1836
|
+
}).onDeepUndeclaredKey("ignore");
|
|
1706
1837
|
proxyRoutePatchSchema = type({
|
|
1707
1838
|
id: "string",
|
|
1708
1839
|
host: "string",
|
|
@@ -1860,7 +1991,38 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
1860
1991
|
"disks": hostDiskSchema.array(),
|
|
1861
1992
|
/** Human readable threshold breaches, for the banner and notifications. */
|
|
1862
1993
|
"alerts": type("string[]"),
|
|
1863
|
-
"sampledAt": "number | null"
|
|
1994
|
+
"sampledAt": "number | null",
|
|
1995
|
+
/**
|
|
1996
|
+
* The per-cpu load this panel notifies on — `host.loadPerCpu`, the number the alert fires at.
|
|
1997
|
+
*
|
|
1998
|
+
* Optional: a panel that predates this field alerts on the default, which is what the UI's band
|
|
1999
|
+
* assumes when the field is absent. It travels here because the frame is the only thing a host
|
|
2000
|
+
* surface reads, and a surface that cannot see the threshold hardcoded `2`/`1.4` — so raising
|
|
2001
|
+
* the threshold in Settings left the tile painting a healthy box `danger` while the alert the
|
|
2002
|
+
* threshold governs stayed silent. `0` disables the alert, so nothing can breach it.
|
|
2003
|
+
*/
|
|
2004
|
+
"loadAlertPerCpu?": "number",
|
|
2005
|
+
/**
|
|
2006
|
+
* The percentage alert thresholds — `host.diskUsedPercent`, `host.memoryUsedPercent`,
|
|
2007
|
+
* `host.swapUsedPercent` and `host.tempCelsius` — the numbers the panel notifies at.
|
|
2008
|
+
*
|
|
2009
|
+
* Optional for the same reason as `loadAlertPerCpu`, and carried for the same reason: a surface
|
|
2010
|
+
* that cannot see the threshold has to invent one, and the invented ones disagreed with the
|
|
2011
|
+
* panel's verdict. The swap bar called 50% `warn` while the alert fired there; raising
|
|
2012
|
+
* `host.tempCelsius` to 95 left a 90 °C box painted `danger` for a notification that never
|
|
2013
|
+
* arrives; and a disk threshold lowered to 80 notified at 82% while every disk bar called it
|
|
2014
|
+
* `warn`. `0` disables that alert, so nothing can breach it.
|
|
2015
|
+
*/
|
|
2016
|
+
"memoryUsedPercentAlert?": "number",
|
|
2017
|
+
"swapUsedPercentAlert?": "number",
|
|
2018
|
+
"tempCelsiusAlert?": "number",
|
|
2019
|
+
/**
|
|
2020
|
+
* `host.diskUsedPercent`, the threshold a filesystem is banded against.
|
|
2021
|
+
*
|
|
2022
|
+
* It travels once for the frame rather than per disk: the threshold is one config value that
|
|
2023
|
+
* applies to every configured path, which is why `hostReadings` copies it onto each disk's `band`.
|
|
2024
|
+
*/
|
|
2025
|
+
"diskUsedPercentAlert?": "number"
|
|
1864
2026
|
});
|
|
1865
2027
|
wslTemperatureSchema = type({
|
|
1866
2028
|
/** This process runs under WSL. */
|
|
@@ -1961,9 +2123,24 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
1961
2123
|
}),
|
|
1962
2124
|
/** Extra paths from the global config, in addition to each server's own. */
|
|
1963
2125
|
"includePaths": type("string[]"),
|
|
2126
|
+
/**
|
|
2127
|
+
* The selection model, carried here only by a panel older than this release.
|
|
2128
|
+
*
|
|
2129
|
+
* Reading it costs a `readFileSync` of the global and every workspace's `.secrets.json` plus a
|
|
2130
|
+
* `statSync` per archive, and the state frame is rebuilt ~13×/s — so it moved to
|
|
2131
|
+
* `GET /api/backups` (`backupSelectionSchema`), which a dialog fetches when it opens. Optional on
|
|
2132
|
+
* purpose: a newer UI reads a panel that still sends it, and a UI must never reject a payload for
|
|
2133
|
+
* a field it does not use. Absent means "ask the endpoint".
|
|
2134
|
+
*/
|
|
2135
|
+
"entries?": backupEntrySchema.array(),
|
|
2136
|
+
"files?": backupFileSchema.array()
|
|
2137
|
+
});
|
|
2138
|
+
backupSelectionSchema = type({
|
|
2139
|
+
/** The archive directory, so a dialog can print the path without a second read. */
|
|
2140
|
+
dir: "string",
|
|
1964
2141
|
/** Every selectable entry, global first, then each workspace. */
|
|
1965
|
-
|
|
1966
|
-
|
|
2142
|
+
entries: backupEntrySchema.array(),
|
|
2143
|
+
files: backupFileSchema.array()
|
|
1967
2144
|
});
|
|
1968
2145
|
restoreItemSchema = type({
|
|
1969
2146
|
/** A backup entry or leaf id (`workspace:<id>:servers`, `data:<path>`, ...). */
|
|
@@ -2117,7 +2294,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
2117
2294
|
/** Last health probe latency (TCP connect or HTTP request). */
|
|
2118
2295
|
"responseMs": "number | null",
|
|
2119
2296
|
"resources": processResourcesSchema.or(type("null"))
|
|
2120
|
-
});
|
|
2297
|
+
}).onDeepUndeclaredKey("ignore");
|
|
2121
2298
|
healthResponseSchema = type({
|
|
2122
2299
|
"status": "\"ok\" | \"degraded\"",
|
|
2123
2300
|
"uptimeMs": "number",
|
|
@@ -2206,7 +2383,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
2206
2383
|
*/
|
|
2207
2384
|
"orphans?": serverOrphanSchema.array(),
|
|
2208
2385
|
"servers": serverViewSchema.array()
|
|
2209
|
-
});
|
|
2386
|
+
}).onDeepUndeclaredKey("ignore");
|
|
2210
2387
|
appStateSchema = type({
|
|
2211
2388
|
"control": controlViewSchema,
|
|
2212
2389
|
"host": hostViewSchema,
|
|
@@ -2221,7 +2398,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
2221
2398
|
"dataRoot": "string",
|
|
2222
2399
|
/** The release this panel is running. Optional: an older panel does not send one. */
|
|
2223
2400
|
"version?": "string"
|
|
2224
|
-
});
|
|
2401
|
+
}).onDeepUndeclaredKey("ignore");
|
|
2225
2402
|
sseMessageSchema = type({
|
|
2226
2403
|
"type": "\"hello\" | \"state\" | \"log\" | \"server\"",
|
|
2227
2404
|
"ts": "number",
|
|
@@ -2230,7 +2407,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
2230
2407
|
"state": appStateSchema.optional(),
|
|
2231
2408
|
"server": serverViewSchema.optional(),
|
|
2232
2409
|
"lines": logLineSchema.array().optional()
|
|
2233
|
-
});
|
|
2410
|
+
}).onDeepUndeclaredKey("ignore");
|
|
2234
2411
|
logQuerySchema = type({ limit: "string?" });
|
|
2235
2412
|
actionResultSchema = type({
|
|
2236
2413
|
"ok": "boolean",
|
|
@@ -2267,14 +2444,15 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
2267
2444
|
file: backupFileSchema,
|
|
2268
2445
|
files: backupFileSchema.array()
|
|
2269
2446
|
});
|
|
2447
|
+
bufferedLogsResponseSchema = type({ lines: logLineSchema.array() });
|
|
2270
2448
|
logLinesResponseSchema = type({
|
|
2271
2449
|
serverId: "string",
|
|
2272
2450
|
enabled: "boolean",
|
|
2273
2451
|
sizeBytes: "number",
|
|
2274
2452
|
/** The rotated files this entry has, newest first. */
|
|
2275
2453
|
files: "string[]",
|
|
2276
|
-
/**
|
|
2277
|
-
searched:
|
|
2454
|
+
/** How many lines the search looked at, or null when the request carried no `search`. */
|
|
2455
|
+
searched: "number | null",
|
|
2278
2456
|
lines: logLineSchema.array()
|
|
2279
2457
|
});
|
|
2280
2458
|
freePortResultSchema = type({
|
|
@@ -2352,7 +2530,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
2352
2530
|
host: hostSchema,
|
|
2353
2531
|
backups: backupsViewSchema,
|
|
2354
2532
|
ui: uiStatusSchema
|
|
2355
|
-
});
|
|
2533
|
+
}).onDeepUndeclaredKey("ignore");
|
|
2356
2534
|
settingsSavedSchema = settingsViewSchema.and(type({
|
|
2357
2535
|
/** The listener is moving; reconnect at `targetUrl` when it stops being null. */
|
|
2358
2536
|
rebinding: "boolean",
|
|
@@ -2367,7 +2545,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
2367
2545
|
defaults: defaultsSchema,
|
|
2368
2546
|
logs: logsSchema,
|
|
2369
2547
|
notifications: notificationViewSchema
|
|
2370
|
-
});
|
|
2548
|
+
}).onDeepUndeclaredKey("ignore");
|
|
2371
2549
|
workspaceSettingsSavedSchema = workspaceSettingsViewSchema;
|
|
2372
2550
|
}));
|
|
2373
2551
|
//#endregion
|
|
@@ -2452,17 +2630,18 @@ var init_atomic = __esmMin((() => {}));
|
|
|
2452
2630
|
/**
|
|
2453
2631
|
* Decodes a hand-editable state file the way the editors that write them save it.
|
|
2454
2632
|
*
|
|
2455
|
-
*
|
|
2456
|
-
* **byte-order mark**: PowerShell's
|
|
2457
|
-
* (UTF-16LE) both
|
|
2458
|
-
* refusal is a parse error naming an invisible character
|
|
2459
|
-
* person is told their JSON is broken when it is not
|
|
2460
|
-
*
|
|
2633
|
+
* A file the panel invites a person to hand-edit arrives the way their editor saved it, and the
|
|
2634
|
+
* editors that write one on Windows prepend a **byte-order mark**: PowerShell's
|
|
2635
|
+
* `Set-Content -Encoding UTF8` (5.1) and `Out-File`/`>` (UTF-16LE) both do, and Notepad writes one
|
|
2636
|
+
* for a "UTF-8 with BOM" save. For JSON the refusal is a parse error naming an invisible character
|
|
2637
|
+
* — `Unexpected token '\uFEFF'` — so the person is told their JSON is broken when it is not. For a
|
|
2638
|
+
* `KEY=value` file it is quieter: every key carries a NUL and is dropped, so the process starts
|
|
2639
|
+
* without the secrets the file exists to hold.
|
|
2461
2640
|
*
|
|
2462
2641
|
* Stripping the mark is not a silent coercion: a BOM is not content, and a file whose real
|
|
2463
2642
|
* content is unchanged parses to the same object with or without it. UTF-16 is decoded rather
|
|
2464
|
-
* than refused because that is what `>` produces on Windows, and it is recognisable from its
|
|
2465
|
-
*
|
|
2643
|
+
* than refused because that is what `>` produces on Windows, and it is recognisable from its own
|
|
2644
|
+
* prefix — a file in neither encoding still fails loudly in the reader above.
|
|
2466
2645
|
*
|
|
2467
2646
|
* Read as a `Buffer`, never with `'utf8'`: a `'utf8'` read of UTF-16LE text has already lost
|
|
2468
2647
|
* the information this needs to tell them apart.
|
|
@@ -3665,212 +3844,6 @@ function parseOrThrow(schema, input, label) {
|
|
|
3665
3844
|
}
|
|
3666
3845
|
var init_validate = __esmMin((() => {}));
|
|
3667
3846
|
//#endregion
|
|
3668
|
-
//#region src/helpers/paths.ts
|
|
3669
|
-
var paths_exports = /* @__PURE__ */ __exportAll({
|
|
3670
|
-
DEFAULT_WORKSPACE_ID: () => DEFAULT_WORKSPACE_ID,
|
|
3671
|
-
daemonLogPath: () => daemonLogPath,
|
|
3672
|
-
dataRoot: () => dataRoot,
|
|
3673
|
-
globalSecretsPath: () => globalSecretsPath,
|
|
3674
|
-
globalSettingsPath: () => globalSettingsPath,
|
|
3675
|
-
hasLegacyLayout: () => hasLegacyLayout,
|
|
3676
|
-
hhDir: () => hhDir,
|
|
3677
|
-
legacy: () => legacy,
|
|
3678
|
-
projectDir: () => projectDir,
|
|
3679
|
-
proxyAdminPath: () => proxyAdminPath,
|
|
3680
|
-
proxyBinDir: () => proxyBinDir,
|
|
3681
|
-
proxyChallengeAuthPath: () => proxyChallengeAuthPath,
|
|
3682
|
-
proxyConfigPath: () => proxyConfigPath,
|
|
3683
|
-
proxyDir: () => proxyDir,
|
|
3684
|
-
proxyEngineDir: () => proxyEngineDir,
|
|
3685
|
-
proxyPreviousConfigPath: () => proxyPreviousConfigPath,
|
|
3686
|
-
proxyStateDir: () => proxyStateDir,
|
|
3687
|
-
proxyTlsDir: () => proxyTlsDir,
|
|
3688
|
-
resolveDataRoot: () => resolveDataRoot,
|
|
3689
|
-
resolveProjectDir: () => resolveProjectDir,
|
|
3690
|
-
resolveUserPath: () => resolveUserPath,
|
|
3691
|
-
runtimePath: () => runtimePath,
|
|
3692
|
-
tlsDir: () => tlsDir,
|
|
3693
|
-
uiDir: () => uiDir,
|
|
3694
|
-
workspaceDdnsStatePath: () => workspaceDdnsStatePath,
|
|
3695
|
-
workspaceDir: () => workspaceDir,
|
|
3696
|
-
workspaceHistoryPath: () => workspaceHistoryPath,
|
|
3697
|
-
workspaceLogsDir: () => workspaceLogsDir,
|
|
3698
|
-
workspaceSecretsPath: () => workspaceSecretsPath,
|
|
3699
|
-
workspaceServersPath: () => workspaceServersPath,
|
|
3700
|
-
workspaceSettingsPath: () => workspaceSettingsPath,
|
|
3701
|
-
workspaceStateDir: () => workspaceStateDir,
|
|
3702
|
-
workspacesPath: () => workspacesPath
|
|
3703
|
-
});
|
|
3704
|
-
/**
|
|
3705
|
-
* Where home-hosted keeps everything it owns. `HHOSTED_HOME` overrides it —
|
|
3706
|
-
* which is how a project repo keeps its own state directory while the package
|
|
3707
|
-
* itself ships no configuration at all.
|
|
3708
|
-
*
|
|
3709
|
-
* Everything below `dataRoot/.hh`: the global panel state at its top level, and
|
|
3710
|
-
* one directory per workspace. A workspace owns its settings, servers, secrets,
|
|
3711
|
-
* logs and nanny state; only what is genuinely panel-wide (listener, auth,
|
|
3712
|
-
* host vitals, backups, TLS, UI, run.json) stays global.
|
|
3713
|
-
*/
|
|
3714
|
-
function resolveDataRoot() {
|
|
3715
|
-
const override = process.env.HHOSTED_HOME;
|
|
3716
|
-
if (override !== void 0 && override.length > 0) return path.resolve(override);
|
|
3717
|
-
return path.join(os.homedir(), ".home-hosted");
|
|
3718
|
-
}
|
|
3719
|
-
/**
|
|
3720
|
-
* The directory home-hosted was started from. Relative entry paths (`cwd`,
|
|
3721
|
-
* declared data directories) resolve against it, so the project's own launcher
|
|
3722
|
-
* decides the base instead of wherever the package happens to be installed.
|
|
3723
|
-
* `HHOSTED_PROJECT` pins it explicitly.
|
|
3724
|
-
*/
|
|
3725
|
-
function resolveProjectDir() {
|
|
3726
|
-
const override = process.env.HHOSTED_PROJECT;
|
|
3727
|
-
if (override !== void 0 && override.length > 0) return path.resolve(override);
|
|
3728
|
-
return process.cwd();
|
|
3729
|
-
}
|
|
3730
|
-
function workspaceDir(id) {
|
|
3731
|
-
return path.join(hhDir, id);
|
|
3732
|
-
}
|
|
3733
|
-
/** Workspace-scoped settings: server defaults, logs, notifications, DDNS. */
|
|
3734
|
-
function workspaceSettingsPath(id) {
|
|
3735
|
-
return path.join(workspaceDir(id), "settings.json");
|
|
3736
|
-
}
|
|
3737
|
-
/** The servers a workspace supervises. */
|
|
3738
|
-
function workspaceServersPath(id) {
|
|
3739
|
-
return path.join(workspaceDir(id), "servers.config.json");
|
|
3740
|
-
}
|
|
3741
|
-
/** Workspace secrets: Telegram bot token and DDNS credentials. Mode 0600. */
|
|
3742
|
-
function workspaceSecretsPath(id) {
|
|
3743
|
-
return path.join(workspaceDir(id), ".secrets.json");
|
|
3744
|
-
}
|
|
3745
|
-
/** Rotated per-server JSONL logs. */
|
|
3746
|
-
function workspaceLogsDir(id) {
|
|
3747
|
-
return path.join(workspaceDir(id), ".logs");
|
|
3748
|
-
}
|
|
3749
|
-
/** Persisted restart/crash history for one workspace. */
|
|
3750
|
-
function workspaceHistoryPath(id) {
|
|
3751
|
-
return path.join(workspaceLogsDir(id), "history.json");
|
|
3752
|
-
}
|
|
3753
|
-
/** Per-entry nanny state and spawn specs — how a persistent server survives a restart. */
|
|
3754
|
-
function workspaceStateDir(id) {
|
|
3755
|
-
return path.join(workspaceDir(id), ".state");
|
|
3756
|
-
}
|
|
3757
|
-
/** The last public address each DDNS target was confirmed to serve. */
|
|
3758
|
-
function workspaceDdnsStatePath(id) {
|
|
3759
|
-
return path.join(workspaceStateDir(id), "ddns.json");
|
|
3760
|
-
}
|
|
3761
|
-
/**
|
|
3762
|
-
* True when a pre-workspace instance left state at the old paths **and** never
|
|
3763
|
-
* crossed into `.hh`: `workspaces.json` means the layout is current, so a stray
|
|
3764
|
-
* root-level copy beside it is not an old instance.
|
|
3765
|
-
*/
|
|
3766
|
-
function hasLegacyLayout() {
|
|
3767
|
-
if (fs.existsSync(workspacesPath)) return false;
|
|
3768
|
-
return fs.existsSync(legacy.configPath) || fs.existsSync(legacy.secretsPath);
|
|
3769
|
-
}
|
|
3770
|
-
/** Expands `~` and resolves relative paths against `base`, for config-declared paths. */
|
|
3771
|
-
function resolveUserPath(target, base = projectDir) {
|
|
3772
|
-
let value = target;
|
|
3773
|
-
if (value === "~") value = os.homedir();
|
|
3774
|
-
else if (value.startsWith("~/") || value.startsWith("~\\")) value = path.join(os.homedir(), value.slice(2));
|
|
3775
|
-
return path.isAbsolute(value) ? value : path.resolve(base, value);
|
|
3776
|
-
}
|
|
3777
|
-
var dataRoot, projectDir, hhDir, DEFAULT_WORKSPACE_ID, globalSettingsPath, globalSecretsPath, workspacesPath, tlsDir, daemonLogPath, runtimePath, uiDir, proxyDir, proxyBinDir, proxyEngineDir, proxyConfigPath, proxyPreviousConfigPath, proxyStateDir, proxyAdminPath, proxyTlsDir, proxyChallengeAuthPath, legacy;
|
|
3778
|
-
var init_paths = __esmMin((() => {
|
|
3779
|
-
dataRoot = resolveDataRoot();
|
|
3780
|
-
projectDir = resolveProjectDir();
|
|
3781
|
-
hhDir = path.join(dataRoot, ".hh");
|
|
3782
|
-
DEFAULT_WORKSPACE_ID = "default";
|
|
3783
|
-
globalSettingsPath = path.join(hhDir, "settings.json");
|
|
3784
|
-
globalSecretsPath = path.join(hhDir, ".control-secrets.json");
|
|
3785
|
-
workspacesPath = path.join(hhDir, "workspaces.json");
|
|
3786
|
-
tlsDir = path.join(hhDir, ".tls");
|
|
3787
|
-
daemonLogPath = path.join(hhDir, ".logs", "home-hosted.log");
|
|
3788
|
-
runtimePath = path.join(hhDir, "run.json");
|
|
3789
|
-
uiDir = path.join(hhDir, ".ui");
|
|
3790
|
-
proxyDir = path.join(hhDir, ".proxy");
|
|
3791
|
-
proxyBinDir = path.join(proxyDir, "bin");
|
|
3792
|
-
proxyEngineDir = path.join(proxyDir, "engine");
|
|
3793
|
-
proxyConfigPath = path.join(proxyEngineDir, "current.json");
|
|
3794
|
-
proxyPreviousConfigPath = path.join(proxyEngineDir, "previous.json");
|
|
3795
|
-
proxyStateDir = path.join(proxyDir, "state");
|
|
3796
|
-
proxyAdminPath = path.join(proxyStateDir, "admin.json");
|
|
3797
|
-
proxyTlsDir = path.join(proxyDir, "tls");
|
|
3798
|
-
proxyChallengeAuthPath = path.join(proxyStateDir, "challenge.json");
|
|
3799
|
-
legacy = {
|
|
3800
|
-
configPath: path.join(dataRoot, "servers.config.json"),
|
|
3801
|
-
secretsPath: path.join(dataRoot, ".control-secrets.json")
|
|
3802
|
-
};
|
|
3803
|
-
}));
|
|
3804
|
-
//#endregion
|
|
3805
|
-
//#region src/services/state.ts
|
|
3806
|
-
/**
|
|
3807
|
-
* The panel's own settings are derived here — configured values from the store,
|
|
3808
|
-
* live values from the listener, security state from the auth service and the
|
|
3809
|
-
* certificate pair from disk — so the UI never has to reason about the
|
|
3810
|
-
* differences.
|
|
3811
|
-
*/
|
|
3812
|
-
function buildControlView(settings, auth, control, tls) {
|
|
3813
|
-
const config = settings.control;
|
|
3814
|
-
const exposure = checkExposure(config, auth.passwordSet, auth.usingDefaultPassword);
|
|
3815
|
-
return {
|
|
3816
|
-
label: config.label,
|
|
3817
|
-
port: config.port,
|
|
3818
|
-
host: config.host,
|
|
3819
|
-
bindHost: control.bindHost,
|
|
3820
|
-
url: control.url,
|
|
3821
|
-
protocol: control.protocol,
|
|
3822
|
-
openBrowser: config.openBrowser,
|
|
3823
|
-
restartRequired: control.port !== config.port || control.host !== config.host,
|
|
3824
|
-
auth: {
|
|
3825
|
-
enabled: config.auth.enabled,
|
|
3826
|
-
passwordSet: auth.passwordSet,
|
|
3827
|
-
passwordUpdatedAt: auth.passwordUpdatedAt,
|
|
3828
|
-
apiTokenSet: auth.apiTokenSet,
|
|
3829
|
-
usingDefaultPassword: auth.usingDefaultPassword,
|
|
3830
|
-
exposed: exposure.exposed,
|
|
3831
|
-
blockedReason: exposure.blockedReason,
|
|
3832
|
-
sessionTtlMs: config.auth.sessionTtlMs,
|
|
3833
|
-
cookieSecure: config.auth.cookieSecure,
|
|
3834
|
-
trustProxy: config.auth.trustProxy,
|
|
3835
|
-
maxLoginAttempts: config.auth.maxLoginAttempts,
|
|
3836
|
-
lockoutMs: config.auth.lockoutMs
|
|
3837
|
-
},
|
|
3838
|
-
tls: tls.status(config.tls.enabled)
|
|
3839
|
-
};
|
|
3840
|
-
}
|
|
3841
|
-
function buildBackupsView(backups) {
|
|
3842
|
-
return backups.view();
|
|
3843
|
-
}
|
|
3844
|
-
/** One workspace's subtree of the state frame. */
|
|
3845
|
-
function buildWorkspaceView(source) {
|
|
3846
|
-
const servers = source.supervisor.views();
|
|
3847
|
-
return {
|
|
3848
|
-
id: source.id,
|
|
3849
|
-
label: source.label,
|
|
3850
|
-
configPath: source.store.path,
|
|
3851
|
-
settingsPath: source.store.settingsPath,
|
|
3852
|
-
configError: source.store.configError,
|
|
3853
|
-
configWarnings: source.store.configWarnings,
|
|
3854
|
-
logsDir: source.logsDir,
|
|
3855
|
-
defaults: source.store.defaults,
|
|
3856
|
-
logs: source.store.logs,
|
|
3857
|
-
notifications: {
|
|
3858
|
-
defaults: source.notifications.defaults(),
|
|
3859
|
-
destinations: source.notifications.destinations()
|
|
3860
|
-
},
|
|
3861
|
-
ddns: source.ddns.view,
|
|
3862
|
-
serverCount: servers.length,
|
|
3863
|
-
runningCount: servers.filter((server) => server.status === "running").length,
|
|
3864
|
-
crashedCount: servers.filter((server) => server.status === "crashed").length,
|
|
3865
|
-
orphans: source.supervisor.orphans?.() ?? [],
|
|
3866
|
-
servers
|
|
3867
|
-
};
|
|
3868
|
-
}
|
|
3869
|
-
var init_state$1 = __esmMin((() => {
|
|
3870
|
-
init_paths();
|
|
3871
|
-
init_exposure();
|
|
3872
|
-
}));
|
|
3873
|
-
//#endregion
|
|
3874
3847
|
//#region src/shared/backup-scope.ts
|
|
3875
3848
|
/**
|
|
3876
3849
|
* What a configured automatic scope asks a `create` for.
|
|
@@ -3955,9 +3928,9 @@ function createBackupsRoute(deps) {
|
|
|
3955
3928
|
summary: "Archives on disk, and the paths a backup would capture",
|
|
3956
3929
|
responses: { 200: {
|
|
3957
3930
|
description: "Backups",
|
|
3958
|
-
content: jsonBody(
|
|
3931
|
+
content: jsonBody(backupSelectionSchema)
|
|
3959
3932
|
} }
|
|
3960
|
-
}), (c) => c.json(
|
|
3933
|
+
}), (c) => c.json(deps.backups.selection())).post("/backups", describeRoute({
|
|
3961
3934
|
tags: ["backups"],
|
|
3962
3935
|
summary: "Create a backup (optionally password-protected)",
|
|
3963
3936
|
responses: {
|
|
@@ -4154,7 +4127,6 @@ var init_backups$1 = __esmMin((() => {
|
|
|
4154
4127
|
init_validate();
|
|
4155
4128
|
init_validator();
|
|
4156
4129
|
init_auth();
|
|
4157
|
-
init_state$1();
|
|
4158
4130
|
init_backup_scope();
|
|
4159
4131
|
init_contracts();
|
|
4160
4132
|
MAX_UPLOAD_BYTES = 268435456;
|
|
@@ -4320,6 +4292,143 @@ var init_schema = __esmMin((() => {
|
|
|
4320
4292
|
];
|
|
4321
4293
|
}));
|
|
4322
4294
|
//#endregion
|
|
4295
|
+
//#region src/helpers/paths.ts
|
|
4296
|
+
var paths_exports = /* @__PURE__ */ __exportAll({
|
|
4297
|
+
DEFAULT_WORKSPACE_ID: () => DEFAULT_WORKSPACE_ID,
|
|
4298
|
+
daemonLogPath: () => daemonLogPath,
|
|
4299
|
+
dataRoot: () => dataRoot,
|
|
4300
|
+
globalSecretsPath: () => globalSecretsPath,
|
|
4301
|
+
globalSettingsPath: () => globalSettingsPath,
|
|
4302
|
+
hasLegacyLayout: () => hasLegacyLayout,
|
|
4303
|
+
hhDir: () => hhDir,
|
|
4304
|
+
legacy: () => legacy,
|
|
4305
|
+
projectDir: () => projectDir,
|
|
4306
|
+
proxyAdminPath: () => proxyAdminPath,
|
|
4307
|
+
proxyBinDir: () => proxyBinDir,
|
|
4308
|
+
proxyChallengeAuthPath: () => proxyChallengeAuthPath,
|
|
4309
|
+
proxyConfigPath: () => proxyConfigPath,
|
|
4310
|
+
proxyDir: () => proxyDir,
|
|
4311
|
+
proxyEngineDir: () => proxyEngineDir,
|
|
4312
|
+
proxyPreviousConfigPath: () => proxyPreviousConfigPath,
|
|
4313
|
+
proxyStateDir: () => proxyStateDir,
|
|
4314
|
+
proxyTlsDir: () => proxyTlsDir,
|
|
4315
|
+
resolveDataRoot: () => resolveDataRoot,
|
|
4316
|
+
resolveProjectDir: () => resolveProjectDir,
|
|
4317
|
+
resolveUserPath: () => resolveUserPath,
|
|
4318
|
+
runtimePath: () => runtimePath,
|
|
4319
|
+
tlsDir: () => tlsDir,
|
|
4320
|
+
uiDir: () => uiDir,
|
|
4321
|
+
workspaceDdnsStatePath: () => workspaceDdnsStatePath,
|
|
4322
|
+
workspaceDir: () => workspaceDir,
|
|
4323
|
+
workspaceHistoryPath: () => workspaceHistoryPath,
|
|
4324
|
+
workspaceLogsDir: () => workspaceLogsDir,
|
|
4325
|
+
workspaceSecretsPath: () => workspaceSecretsPath,
|
|
4326
|
+
workspaceServersPath: () => workspaceServersPath,
|
|
4327
|
+
workspaceSettingsPath: () => workspaceSettingsPath,
|
|
4328
|
+
workspaceStateDir: () => workspaceStateDir,
|
|
4329
|
+
workspacesPath: () => workspacesPath
|
|
4330
|
+
});
|
|
4331
|
+
/**
|
|
4332
|
+
* Where home-hosted keeps everything it owns. `HHOSTED_HOME` overrides it —
|
|
4333
|
+
* which is how a project repo keeps its own state directory while the package
|
|
4334
|
+
* itself ships no configuration at all.
|
|
4335
|
+
*
|
|
4336
|
+
* Everything below `dataRoot/.hh`: the global panel state at its top level, and
|
|
4337
|
+
* one directory per workspace. A workspace owns its settings, servers, secrets,
|
|
4338
|
+
* logs and nanny state; only what is genuinely panel-wide (listener, auth,
|
|
4339
|
+
* host vitals, backups, TLS, UI, run.json) stays global.
|
|
4340
|
+
*/
|
|
4341
|
+
function resolveDataRoot() {
|
|
4342
|
+
const override = process.env.HHOSTED_HOME;
|
|
4343
|
+
if (override !== void 0 && override.length > 0) return path.resolve(override);
|
|
4344
|
+
return path.join(os.homedir(), ".home-hosted");
|
|
4345
|
+
}
|
|
4346
|
+
/**
|
|
4347
|
+
* The directory home-hosted was started from. Relative entry paths (`cwd`,
|
|
4348
|
+
* declared data directories) resolve against it, so the project's own launcher
|
|
4349
|
+
* decides the base instead of wherever the package happens to be installed.
|
|
4350
|
+
* `HHOSTED_PROJECT` pins it explicitly.
|
|
4351
|
+
*/
|
|
4352
|
+
function resolveProjectDir() {
|
|
4353
|
+
const override = process.env.HHOSTED_PROJECT;
|
|
4354
|
+
if (override !== void 0 && override.length > 0) return path.resolve(override);
|
|
4355
|
+
return process.cwd();
|
|
4356
|
+
}
|
|
4357
|
+
function workspaceDir(id) {
|
|
4358
|
+
return path.join(hhDir, id);
|
|
4359
|
+
}
|
|
4360
|
+
/** Workspace-scoped settings: server defaults, logs, notifications, DDNS. */
|
|
4361
|
+
function workspaceSettingsPath(id) {
|
|
4362
|
+
return path.join(workspaceDir(id), "settings.json");
|
|
4363
|
+
}
|
|
4364
|
+
/** The servers a workspace supervises. */
|
|
4365
|
+
function workspaceServersPath(id) {
|
|
4366
|
+
return path.join(workspaceDir(id), "servers.config.json");
|
|
4367
|
+
}
|
|
4368
|
+
/** Workspace secrets: Telegram bot token and DDNS credentials. Mode 0600. */
|
|
4369
|
+
function workspaceSecretsPath(id) {
|
|
4370
|
+
return path.join(workspaceDir(id), ".secrets.json");
|
|
4371
|
+
}
|
|
4372
|
+
/** Rotated per-server JSONL logs. */
|
|
4373
|
+
function workspaceLogsDir(id) {
|
|
4374
|
+
return path.join(workspaceDir(id), ".logs");
|
|
4375
|
+
}
|
|
4376
|
+
/** Persisted restart/crash history for one workspace. */
|
|
4377
|
+
function workspaceHistoryPath(id) {
|
|
4378
|
+
return path.join(workspaceLogsDir(id), "history.json");
|
|
4379
|
+
}
|
|
4380
|
+
/** Per-entry nanny state and spawn specs — how a persistent server survives a restart. */
|
|
4381
|
+
function workspaceStateDir(id) {
|
|
4382
|
+
return path.join(workspaceDir(id), ".state");
|
|
4383
|
+
}
|
|
4384
|
+
/** The last public address each DDNS target was confirmed to serve. */
|
|
4385
|
+
function workspaceDdnsStatePath(id) {
|
|
4386
|
+
return path.join(workspaceStateDir(id), "ddns.json");
|
|
4387
|
+
}
|
|
4388
|
+
/**
|
|
4389
|
+
* True when a pre-workspace instance left state at the old paths **and** never
|
|
4390
|
+
* crossed into `.hh`: `workspaces.json` means the layout is current, so a stray
|
|
4391
|
+
* root-level copy beside it is not an old instance.
|
|
4392
|
+
*/
|
|
4393
|
+
function hasLegacyLayout() {
|
|
4394
|
+
if (fs.existsSync(workspacesPath)) return false;
|
|
4395
|
+
return fs.existsSync(legacy.configPath) || fs.existsSync(legacy.secretsPath);
|
|
4396
|
+
}
|
|
4397
|
+
/** Expands `~` and resolves relative paths against `base`, for config-declared paths. */
|
|
4398
|
+
function resolveUserPath(target, base = projectDir) {
|
|
4399
|
+
let value = target;
|
|
4400
|
+
if (value === "~") value = os.homedir();
|
|
4401
|
+
else if (value.startsWith("~/") || value.startsWith("~\\")) value = path.join(os.homedir(), value.slice(2));
|
|
4402
|
+
return path.isAbsolute(value) ? value : path.resolve(base, value);
|
|
4403
|
+
}
|
|
4404
|
+
var dataRoot, projectDir, hhDir, DEFAULT_WORKSPACE_ID, globalSettingsPath, globalSecretsPath, workspacesPath, tlsDir, daemonLogPath, runtimePath, uiDir, proxyDir, proxyBinDir, proxyEngineDir, proxyConfigPath, proxyPreviousConfigPath, proxyStateDir, proxyAdminPath, proxyTlsDir, proxyChallengeAuthPath, legacy;
|
|
4405
|
+
var init_paths = __esmMin((() => {
|
|
4406
|
+
dataRoot = resolveDataRoot();
|
|
4407
|
+
projectDir = resolveProjectDir();
|
|
4408
|
+
hhDir = path.join(dataRoot, ".hh");
|
|
4409
|
+
DEFAULT_WORKSPACE_ID = "default";
|
|
4410
|
+
globalSettingsPath = path.join(hhDir, "settings.json");
|
|
4411
|
+
globalSecretsPath = path.join(hhDir, ".control-secrets.json");
|
|
4412
|
+
workspacesPath = path.join(hhDir, "workspaces.json");
|
|
4413
|
+
tlsDir = path.join(hhDir, ".tls");
|
|
4414
|
+
daemonLogPath = path.join(hhDir, ".logs", "home-hosted.log");
|
|
4415
|
+
runtimePath = path.join(hhDir, "run.json");
|
|
4416
|
+
uiDir = path.join(hhDir, ".ui");
|
|
4417
|
+
proxyDir = path.join(hhDir, ".proxy");
|
|
4418
|
+
proxyBinDir = path.join(proxyDir, "bin");
|
|
4419
|
+
proxyEngineDir = path.join(proxyDir, "engine");
|
|
4420
|
+
proxyConfigPath = path.join(proxyEngineDir, "current.json");
|
|
4421
|
+
proxyPreviousConfigPath = path.join(proxyEngineDir, "previous.json");
|
|
4422
|
+
proxyStateDir = path.join(proxyDir, "state");
|
|
4423
|
+
proxyAdminPath = path.join(proxyStateDir, "admin.json");
|
|
4424
|
+
proxyTlsDir = path.join(proxyDir, "tls");
|
|
4425
|
+
proxyChallengeAuthPath = path.join(proxyStateDir, "challenge.json");
|
|
4426
|
+
legacy = {
|
|
4427
|
+
configPath: path.join(dataRoot, "servers.config.json"),
|
|
4428
|
+
secretsPath: path.join(dataRoot, ".control-secrets.json")
|
|
4429
|
+
};
|
|
4430
|
+
}));
|
|
4431
|
+
//#endregion
|
|
4323
4432
|
//#region src/config/workspaces.ts
|
|
4324
4433
|
/** `My Project AB!` -> `my-project-ab`, and never an empty id. */
|
|
4325
4434
|
function slugifyWorkspaceId(label, taken = []) {
|
|
@@ -4595,13 +4704,13 @@ function createControlRoute(deps) {
|
|
|
4595
4704
|
responses: {
|
|
4596
4705
|
200: {
|
|
4597
4706
|
description: "The archives",
|
|
4598
|
-
content: jsonBody(
|
|
4707
|
+
content: jsonBody(backupSelectionSchema)
|
|
4599
4708
|
},
|
|
4600
4709
|
403: { description: "Bad token, or not a local caller" }
|
|
4601
4710
|
}
|
|
4602
4711
|
}), (c) => {
|
|
4603
4712
|
assertLocalCall(c, "list backups");
|
|
4604
|
-
return c.json(
|
|
4713
|
+
return c.json(deps.backups.selection());
|
|
4605
4714
|
}).post("/backups", describeRoute({
|
|
4606
4715
|
tags: ["panel"],
|
|
4607
4716
|
summary: "Create a backup archive (local token required)",
|
|
@@ -4619,7 +4728,8 @@ function createControlRoute(deps) {
|
|
|
4619
4728
|
const include = c.req.query("include")?.split(",").filter((part) => part.length > 0);
|
|
4620
4729
|
const exclude = c.req.query("exclude")?.split(",").filter((part) => part.length > 0);
|
|
4621
4730
|
if (c.req.query("confirm") !== "true") {
|
|
4622
|
-
const view =
|
|
4731
|
+
const view = deps.backups.selection();
|
|
4732
|
+
const includePaths = deps.backups.view().includePaths;
|
|
4623
4733
|
const selects = selectionOf({
|
|
4624
4734
|
include,
|
|
4625
4735
|
exclude
|
|
@@ -4632,7 +4742,7 @@ function createControlRoute(deps) {
|
|
|
4632
4742
|
return c.json({
|
|
4633
4743
|
apply: false,
|
|
4634
4744
|
entries,
|
|
4635
|
-
includePaths
|
|
4745
|
+
includePaths
|
|
4636
4746
|
});
|
|
4637
4747
|
}
|
|
4638
4748
|
const result = await deps.backups.create({
|
|
@@ -4712,7 +4822,6 @@ var init_control = __esmMin((() => {
|
|
|
4712
4822
|
init_validator();
|
|
4713
4823
|
init_workspace();
|
|
4714
4824
|
init_loopback();
|
|
4715
|
-
init_state$1();
|
|
4716
4825
|
init_backup_scope();
|
|
4717
4826
|
init_contracts();
|
|
4718
4827
|
}));
|
|
@@ -6913,11 +7022,18 @@ function parseEnvFile(text) {
|
|
|
6913
7022
|
}
|
|
6914
7023
|
return env;
|
|
6915
7024
|
}
|
|
6916
|
-
/**
|
|
7025
|
+
/**
|
|
7026
|
+
* Missing files are not an error: an env file is an optional override layer.
|
|
7027
|
+
*
|
|
7028
|
+
* Read through `readStateFile`: an entry's `envFile` is written by a person, not by this panel, so a
|
|
7029
|
+
* Windows editor's byte-order mark or UTF-16 save is the normal state of it. A `'utf8'` read made
|
|
7030
|
+
* every key carry a NUL — dropped by `resolveSpawn` as "an environment key containing a null byte" —
|
|
7031
|
+
* so the process started without the secret the file exists to keep out of the config.
|
|
7032
|
+
*/
|
|
6917
7033
|
function loadEnvFile(file) {
|
|
6918
7034
|
try {
|
|
6919
7035
|
return {
|
|
6920
|
-
env: parseEnvFile(
|
|
7036
|
+
env: parseEnvFile(readStateFile(file)),
|
|
6921
7037
|
path: file,
|
|
6922
7038
|
error: null
|
|
6923
7039
|
};
|
|
@@ -6950,6 +7066,7 @@ function resolveEnvFilePath(file, cwd) {
|
|
|
6950
7066
|
}
|
|
6951
7067
|
var VARIABLE;
|
|
6952
7068
|
var init_env_file = __esmMin((() => {
|
|
7069
|
+
init_config_text();
|
|
6953
7070
|
init_error_message();
|
|
6954
7071
|
VARIABLE = /\$\{([A-Z_]\w*)\}/gi;
|
|
6955
7072
|
}));
|
|
@@ -8000,7 +8117,7 @@ function createMetricsRoute(deps) {
|
|
|
8000
8117
|
responses: { 200: { description: "text/plain; version=0.0.4" } }
|
|
8001
8118
|
}), (c) => {
|
|
8002
8119
|
const servers = deps.panel.serverViews();
|
|
8003
|
-
const host = deps.panel.getState().host;
|
|
8120
|
+
const host = hostReadings(deps.panel.getState().host);
|
|
8004
8121
|
const lines = [];
|
|
8005
8122
|
const metric = (name, help, samples) => {
|
|
8006
8123
|
if (samples.length === 0) return;
|
|
@@ -8015,18 +8132,17 @@ function createMetricsRoute(deps) {
|
|
|
8015
8132
|
metric("hh_server_response_ms", "Last health probe latency in milliseconds", servers.filter((server) => server.responseMs !== null).map((server) => `hh_server_response_ms{${labels(server)}} ${server.responseMs}`));
|
|
8016
8133
|
metric("hh_server_rss_bytes", "RSS of the server process tree, or the summed containers of a compose entry", servers.filter((server) => server.resources?.rssBytes != null).map((server) => `hh_server_rss_bytes{${labels(server)}} ${server.resources.rssBytes}`));
|
|
8017
8134
|
metric("hh_server_cpu_percent", "CPU percent of the server process tree, or the summed containers of a compose entry", servers.filter((server) => server.resources?.cpuPercent != null).map((server) => `hh_server_cpu_percent{${labels(server)}} ${server.resources.cpuPercent}`));
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
metric("hh_host_load1_per_cpu", "1 minute load average per cpu", [`hh_host_load1_per_cpu ${((host.loadAvg[0] ?? 0) / Math.max(1, host.cpus)).toFixed(3)}`]);
|
|
8024
|
-
}
|
|
8135
|
+
metric("hh_host_disk_used_percent", "Disk usage percent per configured path", host.disks.map((disk) => `hh_host_disk_used_percent{mount="${labelValue(disk.path)}"} ${disk.usedPercent.toFixed(2)}`));
|
|
8136
|
+
metric("hh_host_cpu_used_percent", "Share of this machine's CPU capacity in use, 0-100", host.cpuUsedPercent === null ? [] : [`hh_host_cpu_used_percent ${host.cpuUsedPercent.toFixed(2)}`]);
|
|
8137
|
+
metric("hh_host_memory_used_percent", "Memory usage percent", host.memoryUsedPercent === null ? [] : [`hh_host_memory_used_percent ${host.memoryUsedPercent.toFixed(2)}`]);
|
|
8138
|
+
metric("hh_host_swap_used_percent", "Swap usage percent", host.swapUsedPercent === null ? [] : [`hh_host_swap_used_percent ${host.swapUsedPercent.toFixed(2)}`]);
|
|
8139
|
+
metric("hh_host_load1_per_cpu", "1 minute load average per cpu", host.loadPerCpu === null ? [] : [`hh_host_load1_per_cpu ${host.loadPerCpu.toFixed(3)}`]);
|
|
8025
8140
|
return c.text(`${lines.join("\n")}\n`, 200, { "Content-Type": "text/plain; version=0.0.4; charset=utf-8" });
|
|
8026
8141
|
});
|
|
8027
8142
|
}
|
|
8028
8143
|
var init_metrics = __esmMin((() => {
|
|
8029
8144
|
init_factory();
|
|
8145
|
+
init_host_readings();
|
|
8030
8146
|
}));
|
|
8031
8147
|
//#endregion
|
|
8032
8148
|
//#region src/providers/telegram.ts
|
|
@@ -8723,8 +8839,9 @@ function matchesSpawn(info, spawn) {
|
|
|
8723
8839
|
async function processArgv(pid) {
|
|
8724
8840
|
if (process.platform === "win32") return null;
|
|
8725
8841
|
if (process.platform === "linux") try {
|
|
8726
|
-
const
|
|
8727
|
-
|
|
8842
|
+
const words = (await fs.promises.readFile(`/proc/${pid}/cmdline`)).toString("utf8").split("\0");
|
|
8843
|
+
if (words.at(-1) === "") words.pop();
|
|
8844
|
+
return words.length > 0 ? words : null;
|
|
8728
8845
|
} catch {
|
|
8729
8846
|
return null;
|
|
8730
8847
|
}
|
|
@@ -9331,6 +9448,7 @@ var init_process = __esmMin((() => {
|
|
|
9331
9448
|
var nanny_exports$2 = /* @__PURE__ */ __exportAll({
|
|
9332
9449
|
HEARTBEAT_STALE_MS: () => HEARTBEAT_STALE_MS,
|
|
9333
9450
|
NANNY_HEARTBEAT_MS: () => NANNY_HEARTBEAT_MS,
|
|
9451
|
+
NANNY_TRAPPED_SIGNALS: () => NANNY_TRAPPED_SIGNALS,
|
|
9334
9452
|
SPEC_SUFFIX: () => SPEC_SUFFIX,
|
|
9335
9453
|
clearNannySpec: () => clearNannySpec,
|
|
9336
9454
|
clearNannyState: () => clearNannyState,
|
|
@@ -9511,18 +9629,23 @@ function signalName(number) {
|
|
|
9511
9629
|
}
|
|
9512
9630
|
/**
|
|
9513
9631
|
* Is the nanny this state describes still ours? A live pid proves nothing on its
|
|
9514
|
-
* own — pids are reused
|
|
9515
|
-
*
|
|
9516
|
-
*
|
|
9632
|
+
* own — pids are reused, and the heartbeat is written *into the file*, not by the
|
|
9633
|
+
* process the file names, so a recycled pid with a recent write reads as running.
|
|
9634
|
+
* `startedAt` settles that first (`processLiveness`), exactly as `run.json` uses it:
|
|
9635
|
+
* the nanny stamps its record during its own boot, so its process is always born
|
|
9636
|
+
* before the stamp. The environment marker (Linux, macOS) or the argv we spawned it
|
|
9637
|
+
* with answers the rest, Windows included.
|
|
9517
9638
|
*/
|
|
9518
|
-
async function nannyIsAlive(state, id) {
|
|
9519
|
-
if (state.nannyPid <= 0
|
|
9639
|
+
async function nannyIsAlive(state, id, options = {}) {
|
|
9640
|
+
if (state.nannyPid <= 0) return false;
|
|
9641
|
+
const liveness = await processLiveness(state.nannyPid, state.startedAt, options);
|
|
9642
|
+
if (liveness === "gone" || liveness === "recycled") return false;
|
|
9520
9643
|
if (Date.now() - state.heartbeatAt <= 3e4) return true;
|
|
9521
9644
|
if (await processCarriesServerId(state.nannyPid, id)) return true;
|
|
9522
9645
|
const words = await processArgv(state.nannyPid);
|
|
9523
9646
|
return words !== null && words.includes("__nanny") && words.some((word) => word.endsWith(`${id}.spec.json`));
|
|
9524
9647
|
}
|
|
9525
|
-
var SPEC_MODE, SPEC_SUFFIX, NANNY_HEARTBEAT_MS, HEARTBEAT_STALE_MS;
|
|
9648
|
+
var SPEC_MODE, SPEC_SUFFIX, NANNY_TRAPPED_SIGNALS, NANNY_HEARTBEAT_MS, HEARTBEAT_STALE_MS;
|
|
9526
9649
|
var init_nanny$2 = __esmMin((() => {
|
|
9527
9650
|
init_atomic();
|
|
9528
9651
|
init_runtime();
|
|
@@ -9533,6 +9656,7 @@ var init_nanny$2 = __esmMin((() => {
|
|
|
9533
9656
|
init_contracts();
|
|
9534
9657
|
SPEC_MODE = 384;
|
|
9535
9658
|
SPEC_SUFFIX = ".spec.json";
|
|
9659
|
+
NANNY_TRAPPED_SIGNALS = /* @__PURE__ */ new Set(["SIGTERM", "SIGINT"]);
|
|
9536
9660
|
NANNY_HEARTBEAT_MS = 5e3;
|
|
9537
9661
|
HEARTBEAT_STALE_MS = 3e4;
|
|
9538
9662
|
}));
|
|
@@ -12242,7 +12366,7 @@ function createServersRoute(deps) {
|
|
|
12242
12366
|
responses: {
|
|
12243
12367
|
200: {
|
|
12244
12368
|
description: "Lines",
|
|
12245
|
-
content: jsonBody(
|
|
12369
|
+
content: jsonBody(bufferedLogsResponseSchema)
|
|
12246
12370
|
},
|
|
12247
12371
|
404: ERROR_RESPONSES[404]
|
|
12248
12372
|
}
|
|
@@ -12455,6 +12579,72 @@ var init_$_routes$1 = __esmMin((() => {
|
|
|
12455
12579
|
bufferedLogsQuery = logQuerySchema.merge(workspaceQuerySchema);
|
|
12456
12580
|
}));
|
|
12457
12581
|
//#endregion
|
|
12582
|
+
//#region src/services/state.ts
|
|
12583
|
+
/**
|
|
12584
|
+
* The panel's own settings are derived here — configured values from the store,
|
|
12585
|
+
* live values from the listener, security state from the auth service and the
|
|
12586
|
+
* certificate pair from disk — so the UI never has to reason about the
|
|
12587
|
+
* differences.
|
|
12588
|
+
*/
|
|
12589
|
+
function buildControlView(settings, auth, control, tls) {
|
|
12590
|
+
const config = settings.control;
|
|
12591
|
+
const exposure = checkExposure(config, auth.passwordSet, auth.usingDefaultPassword);
|
|
12592
|
+
return {
|
|
12593
|
+
label: config.label,
|
|
12594
|
+
port: config.port,
|
|
12595
|
+
host: config.host,
|
|
12596
|
+
bindHost: control.bindHost,
|
|
12597
|
+
url: control.url,
|
|
12598
|
+
protocol: control.protocol,
|
|
12599
|
+
openBrowser: config.openBrowser,
|
|
12600
|
+
restartRequired: control.port !== config.port || control.host !== config.host,
|
|
12601
|
+
auth: {
|
|
12602
|
+
enabled: config.auth.enabled,
|
|
12603
|
+
passwordSet: auth.passwordSet,
|
|
12604
|
+
passwordUpdatedAt: auth.passwordUpdatedAt,
|
|
12605
|
+
apiTokenSet: auth.apiTokenSet,
|
|
12606
|
+
usingDefaultPassword: auth.usingDefaultPassword,
|
|
12607
|
+
exposed: exposure.exposed,
|
|
12608
|
+
blockedReason: exposure.blockedReason,
|
|
12609
|
+
sessionTtlMs: config.auth.sessionTtlMs,
|
|
12610
|
+
cookieSecure: config.auth.cookieSecure,
|
|
12611
|
+
trustProxy: config.auth.trustProxy,
|
|
12612
|
+
maxLoginAttempts: config.auth.maxLoginAttempts,
|
|
12613
|
+
lockoutMs: config.auth.lockoutMs
|
|
12614
|
+
},
|
|
12615
|
+
tls: tls.status(config.tls.enabled)
|
|
12616
|
+
};
|
|
12617
|
+
}
|
|
12618
|
+
/** One workspace's subtree of the state frame. */
|
|
12619
|
+
function buildWorkspaceView(source) {
|
|
12620
|
+
const servers = source.supervisor.views();
|
|
12621
|
+
return {
|
|
12622
|
+
id: source.id,
|
|
12623
|
+
label: source.label,
|
|
12624
|
+
configPath: source.store.path,
|
|
12625
|
+
settingsPath: source.store.settingsPath,
|
|
12626
|
+
configError: source.store.configError,
|
|
12627
|
+
configWarnings: source.store.configWarnings,
|
|
12628
|
+
logsDir: source.logsDir,
|
|
12629
|
+
defaults: source.store.defaults,
|
|
12630
|
+
logs: source.store.logs,
|
|
12631
|
+
notifications: {
|
|
12632
|
+
defaults: source.notifications.defaults(),
|
|
12633
|
+
destinations: source.notifications.destinations()
|
|
12634
|
+
},
|
|
12635
|
+
ddns: source.ddns.view,
|
|
12636
|
+
serverCount: servers.length,
|
|
12637
|
+
runningCount: servers.filter((server) => server.status === "running").length,
|
|
12638
|
+
crashedCount: servers.filter((server) => server.status === "crashed").length,
|
|
12639
|
+
orphans: source.supervisor.orphans?.() ?? [],
|
|
12640
|
+
servers
|
|
12641
|
+
};
|
|
12642
|
+
}
|
|
12643
|
+
var init_state$1 = __esmMin((() => {
|
|
12644
|
+
init_paths();
|
|
12645
|
+
init_exposure();
|
|
12646
|
+
}));
|
|
12647
|
+
//#endregion
|
|
12458
12648
|
//#region src/api/settings.ts
|
|
12459
12649
|
/** The archive's name is only a label, so it never reaches the filesystem. */
|
|
12460
12650
|
function sanitizeName(name) {
|
|
@@ -12527,7 +12717,7 @@ function createSettingsRoute(deps) {
|
|
|
12527
12717
|
});
|
|
12528
12718
|
const scope = patch.backups?.schedule?.scope;
|
|
12529
12719
|
if (scope !== void 0 && scope !== null) {
|
|
12530
|
-
const unknown = unknownBackupIds(scope.ids, deps.backups.
|
|
12720
|
+
const unknown = unknownBackupIds(scope.ids, deps.backups.selection().entries);
|
|
12531
12721
|
if (unknown.length > 0) throw new DetailedError(`the automatic backup scope names ${unknown.map((id) => `"${id}"`).join(", ")}, which this panel cannot capture`, {
|
|
12532
12722
|
statusCode: 400,
|
|
12533
12723
|
code: "INVALID_SETTINGS"
|
|
@@ -12993,12 +13183,14 @@ var init_$_routes = __esmMin((() => {
|
|
|
12993
13183
|
var wsl_temperature_exports = /* @__PURE__ */ __exportAll({
|
|
12994
13184
|
LHM_RELEASE: () => LHM_RELEASE,
|
|
12995
13185
|
LHM_SUBDIR: () => LHM_SUBDIR,
|
|
13186
|
+
forgetWslPaths: () => forgetWslPaths,
|
|
12996
13187
|
installLibreHardwareMonitor: () => installLibreHardwareMonitor,
|
|
12997
13188
|
isWsl: () => isWsl,
|
|
12998
13189
|
lhmDirectory: () => lhmDirectory,
|
|
12999
13190
|
lhmDirectoryWindows: () => lhmDirectoryWindows,
|
|
13000
13191
|
lhmInstalled: () => lhmInstalled,
|
|
13001
13192
|
probeWslTemperature: () => probeWslTemperature,
|
|
13193
|
+
removeWslTemperatureScript: () => removeWslTemperatureScript,
|
|
13002
13194
|
tempCommandFor: () => tempCommandFor,
|
|
13003
13195
|
tempCommandForWindows: () => tempCommandForWindows,
|
|
13004
13196
|
toGuestPath: () => toGuestPath,
|
|
@@ -13008,10 +13200,20 @@ var wsl_temperature_exports = /* @__PURE__ */ __exportAll({
|
|
|
13008
13200
|
wslScriptPathWindows: () => wslScriptPathWindows,
|
|
13009
13201
|
wslTemperatureStatus: () => wslTemperatureStatus
|
|
13010
13202
|
});
|
|
13011
|
-
/**
|
|
13012
|
-
|
|
13203
|
+
/**
|
|
13204
|
+
* `$env:ProgramData` from the Windows side, read **once**.
|
|
13205
|
+
*
|
|
13206
|
+
* `powershell.exe` across the 9p mount measured ~360 ms here, and this is a **synchronous** spawn: it
|
|
13207
|
+
* stops the whole event loop, so the tick, the SSE hub and every in-flight request wait behind it.
|
|
13208
|
+
* Every bridge-state read did it twice — once for the install directory, once for the library — which
|
|
13209
|
+
* made `GET /api/host/temperature` block the panel for ~720 ms, on a route the settings page calls
|
|
13210
|
+
* whenever it opens. Same rule as `lanAddress()`: a host read on a request path is cached, never
|
|
13211
|
+
* paid per call.
|
|
13212
|
+
*/
|
|
13213
|
+
function windowsProgramData() {
|
|
13214
|
+
if (windowsBase !== null) return windowsBase;
|
|
13013
13215
|
try {
|
|
13014
|
-
const base = execFileSync("powershell.exe", [
|
|
13216
|
+
const base = cp.execFileSync("powershell.exe", [
|
|
13015
13217
|
"-NoProfile",
|
|
13016
13218
|
"-NonInteractive",
|
|
13017
13219
|
"-Command",
|
|
@@ -13021,10 +13223,18 @@ function lhmDirectoryWindows() {
|
|
|
13021
13223
|
windowsHide: true,
|
|
13022
13224
|
encoding: "utf8"
|
|
13023
13225
|
}).trim();
|
|
13024
|
-
|
|
13025
|
-
} catch {
|
|
13026
|
-
|
|
13027
|
-
|
|
13226
|
+
if (base.length > 0) windowsBase = base;
|
|
13227
|
+
} catch {}
|
|
13228
|
+
return windowsBase;
|
|
13229
|
+
}
|
|
13230
|
+
/** The install directory in Windows terms, read from the environment (the system drive may not be `C:`). */
|
|
13231
|
+
function lhmDirectoryWindows() {
|
|
13232
|
+
const base = windowsProgramData();
|
|
13233
|
+
return base === null ? null : path.win32.join(base, LHM_SUBDIR);
|
|
13234
|
+
}
|
|
13235
|
+
/** Forgets the cached Windows path. A test that simulates the Windows side calls this first. */
|
|
13236
|
+
function forgetWslPaths() {
|
|
13237
|
+
windowsBase = null;
|
|
13028
13238
|
}
|
|
13029
13239
|
/** A Windows path as a path this process can read: `C:\x` -> `/mnt/c/x`. */
|
|
13030
13240
|
function toGuestPath(windowsPath) {
|
|
@@ -13129,6 +13339,20 @@ function writeWslTemperatureScript(scriptPath) {
|
|
|
13129
13339
|
fs.mkdirSync(path.dirname(scriptPath), { recursive: true });
|
|
13130
13340
|
fs.writeFileSync(scriptPath, scriptBody(), { mode: 384 });
|
|
13131
13341
|
}
|
|
13342
|
+
/**
|
|
13343
|
+
* Delete the helper script, best-effort: a file someone already removed is the outcome they wanted.
|
|
13344
|
+
*
|
|
13345
|
+
* The one home for it, because `--clear` promises it in the CLI help and in `docs/SERVERS.md` — and
|
|
13346
|
+
* the CLI cleared `host.tempCommand` without ever removing the file, so the helper outlived the
|
|
13347
|
+
* setting that pointed at it. A command nothing names any more is left for the next person to
|
|
13348
|
+
* wonder about, and the route that *did* delete it was the only caller.
|
|
13349
|
+
*/
|
|
13350
|
+
function removeWslTemperatureScript(scriptPath) {
|
|
13351
|
+
if (scriptPath === null) return;
|
|
13352
|
+
try {
|
|
13353
|
+
fs.rmSync(scriptPath, { force: true });
|
|
13354
|
+
} catch {}
|
|
13355
|
+
}
|
|
13132
13356
|
/** Whether the DLL the helper loads is installed where the helper expects it. */
|
|
13133
13357
|
function lhmInstalled() {
|
|
13134
13358
|
const dir = lhmDirectory();
|
|
@@ -13246,12 +13470,13 @@ async function probeWslTemperature(tempCommand, timeoutMs) {
|
|
|
13246
13470
|
};
|
|
13247
13471
|
}
|
|
13248
13472
|
}
|
|
13249
|
-
var execFileAsync$2, SCRIPT_NAME, LHM_SUBDIR, LHM_RELEASE;
|
|
13473
|
+
var execFileAsync$2, SCRIPT_NAME, LHM_SUBDIR, windowsBase, LHM_RELEASE;
|
|
13250
13474
|
var init_wsl_temperature$1 = __esmMin((() => {
|
|
13251
13475
|
init_logger();
|
|
13252
|
-
execFileAsync$2 = promisify(execFile);
|
|
13476
|
+
execFileAsync$2 = promisify(cp.execFile);
|
|
13253
13477
|
SCRIPT_NAME = "cpu-temp.ps1";
|
|
13254
13478
|
LHM_SUBDIR = "home-hosted\\LibreHardwareMonitor";
|
|
13479
|
+
windowsBase = null;
|
|
13255
13480
|
LHM_RELEASE = {
|
|
13256
13481
|
version: "0.9.6",
|
|
13257
13482
|
asset: "LibreHardwareMonitor.zip",
|
|
@@ -13364,11 +13589,8 @@ function createWslTemperatureRoute(deps) {
|
|
|
13364
13589
|
400: ERROR_RESPONSES[400]
|
|
13365
13590
|
}
|
|
13366
13591
|
}), async (c) => {
|
|
13367
|
-
const target = scriptPath();
|
|
13368
13592
|
deps.panel.settings.updateHost({ tempCommand: "" });
|
|
13369
|
-
|
|
13370
|
-
if (target !== null) fs.rmSync(target, { force: true });
|
|
13371
|
-
} catch {}
|
|
13593
|
+
removeWslTemperatureScript(scriptPath());
|
|
13372
13594
|
return c.json(status(deps));
|
|
13373
13595
|
});
|
|
13374
13596
|
}
|
|
@@ -13555,78 +13777,108 @@ var init_openapi_reference = __esmMin((() => {
|
|
|
13555
13777
|
*/
|
|
13556
13778
|
/** The version the package was built with, so the spec never drifts from it. */
|
|
13557
13779
|
function setupOpenAPI(app) {
|
|
13558
|
-
return appFactory.createApp().get(`${PREFIX}/spec.json`, openAPIRouteHandler(app, {
|
|
13559
|
-
info: {
|
|
13560
|
-
title: "home-hosted",
|
|
13561
|
-
version: appVersion(),
|
|
13562
|
-
description: "Control plane for the processes you host at home: servers, logs, vitals, backups and settings."
|
|
13563
|
-
},
|
|
13564
|
-
tags: [
|
|
13565
|
-
{
|
|
13566
|
-
name: "panel",
|
|
13567
|
-
description: "Snapshot, health and the local shutdown channel"
|
|
13568
|
-
},
|
|
13569
|
-
{
|
|
13570
|
-
name: "servers",
|
|
13571
|
-
description: "The processes being supervised"
|
|
13572
|
-
},
|
|
13573
|
-
{
|
|
13574
|
-
name: "logs",
|
|
13575
|
-
description: "Live and persisted logs"
|
|
13576
|
-
},
|
|
13577
|
-
{
|
|
13578
|
-
name: "workspaces",
|
|
13579
|
-
description: "The ownership boundary: one scope per setup"
|
|
13580
|
-
},
|
|
13581
|
-
{
|
|
13582
|
-
name: "backups",
|
|
13583
|
-
description: "Archives of config, secrets, TLS and data paths"
|
|
13584
|
-
},
|
|
13585
|
-
{
|
|
13586
|
-
name: "auth",
|
|
13587
|
-
description: "Sessions and the panel password"
|
|
13588
|
-
},
|
|
13589
|
-
{
|
|
13590
|
-
name: "notifications",
|
|
13591
|
-
description: "Telegram delivery and webhook destinations"
|
|
13592
|
-
},
|
|
13593
|
-
{
|
|
13594
|
-
name: "ddns",
|
|
13595
|
-
description: "Dynamic DNS accounts and hostnames"
|
|
13596
|
-
},
|
|
13597
|
-
{
|
|
13598
|
-
name: "proxy",
|
|
13599
|
-
description: "The reverse proxy: engine, routes and certificates"
|
|
13600
|
-
},
|
|
13601
|
-
{
|
|
13602
|
-
name: "tls",
|
|
13603
|
-
description: "The panel certificate"
|
|
13604
|
-
}
|
|
13605
|
-
],
|
|
13780
|
+
return appFactory.createApp().get(`${PREFIX}/spec.json`, openAPIRouteHandler(app, {
|
|
13606
13781
|
/**
|
|
13607
|
-
* The
|
|
13782
|
+
* The `400` every validated route gets, written as this server's own envelope.
|
|
13608
13783
|
*
|
|
13609
|
-
*
|
|
13610
|
-
*
|
|
13611
|
-
*
|
|
13612
|
-
*
|
|
13613
|
-
*
|
|
13784
|
+
* hono-openapi injects its own default on any operation that has a validator and does not
|
|
13785
|
+
* name a `400`: `{ success: false, error: [], data }`. This API has never sent that shape —
|
|
13786
|
+
* `src/helpers/error.ts` maps every failure through one `DetailedError` envelope,
|
|
13787
|
+
* `{ message, code, detail }`, which is what AGENTS.md promises and what a client parses.
|
|
13788
|
+
* Measured on 29 operations: `GET /api/servers`, `POST /api/servers/{id}/start`, every
|
|
13789
|
+
* `/_hh` lifecycle route, `GET /api/logs/{id}`. The document described a body no successful
|
|
13790
|
+
* client would ever see, and every generated client was typed against it.
|
|
13791
|
+
*
|
|
13792
|
+
* Spelled as a resolved JSON schema rather than `ERROR_RESPONSES[400]`: this option takes
|
|
13793
|
+
* an OpenAPI response object, not a Standard Schema, and `apiErrorSchema` is what that
|
|
13794
|
+
* envelope is defined by (`test/api/panel.test.ts` pins the two together).
|
|
13614
13795
|
*/
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13796
|
+
defaultValidationErrorResponse: {
|
|
13797
|
+
description: ERROR_RESPONSES[400].description,
|
|
13798
|
+
content: { "application/json": { schema: {
|
|
13799
|
+
type: "object",
|
|
13800
|
+
properties: {
|
|
13801
|
+
message: { type: "string" },
|
|
13802
|
+
code: { type: "string" },
|
|
13803
|
+
detail: {}
|
|
13804
|
+
},
|
|
13805
|
+
required: ["message", "code"]
|
|
13806
|
+
} } }
|
|
13807
|
+
},
|
|
13808
|
+
documentation: {
|
|
13809
|
+
info: {
|
|
13810
|
+
title: "home-hosted",
|
|
13811
|
+
version: appVersion(),
|
|
13812
|
+
description: "Control plane for the processes you host at home: servers, logs, vitals, backups and settings."
|
|
13813
|
+
},
|
|
13814
|
+
tags: [
|
|
13815
|
+
{
|
|
13816
|
+
name: "panel",
|
|
13817
|
+
description: "Snapshot, health and the local shutdown channel"
|
|
13818
|
+
},
|
|
13819
|
+
{
|
|
13820
|
+
name: "servers",
|
|
13821
|
+
description: "The processes being supervised"
|
|
13822
|
+
},
|
|
13823
|
+
{
|
|
13824
|
+
name: "logs",
|
|
13825
|
+
description: "Live and persisted logs"
|
|
13826
|
+
},
|
|
13827
|
+
{
|
|
13828
|
+
name: "workspaces",
|
|
13829
|
+
description: "The ownership boundary: one scope per setup"
|
|
13830
|
+
},
|
|
13831
|
+
{
|
|
13832
|
+
name: "backups",
|
|
13833
|
+
description: "Archives of config, secrets, TLS and data paths"
|
|
13834
|
+
},
|
|
13835
|
+
{
|
|
13836
|
+
name: "auth",
|
|
13837
|
+
description: "Sessions and the panel password"
|
|
13838
|
+
},
|
|
13839
|
+
{
|
|
13840
|
+
name: "notifications",
|
|
13841
|
+
description: "Telegram delivery and webhook destinations"
|
|
13842
|
+
},
|
|
13843
|
+
{
|
|
13844
|
+
name: "ddns",
|
|
13845
|
+
description: "Dynamic DNS accounts and hostnames"
|
|
13846
|
+
},
|
|
13847
|
+
{
|
|
13848
|
+
name: "proxy",
|
|
13849
|
+
description: "The reverse proxy: engine, routes and certificates"
|
|
13850
|
+
},
|
|
13851
|
+
{
|
|
13852
|
+
name: "tls",
|
|
13853
|
+
description: "The panel certificate"
|
|
13854
|
+
}
|
|
13855
|
+
],
|
|
13856
|
+
/**
|
|
13857
|
+
* The auth scheme, so a generated client can be told how to send a credential.
|
|
13858
|
+
*
|
|
13859
|
+
* Every `/api` route takes `Authorization: Bearer hh_…`, and the spec said nothing
|
|
13860
|
+
* about it: openapi-typescript, openapi-generator and Scalar's "try it" all produced
|
|
13861
|
+
* clients with no auth hook, and the README tells an agent this document *is* the API
|
|
13862
|
+
* it may call. Two lines here are the difference between generating a client and
|
|
13863
|
+
* hand-writing one.
|
|
13864
|
+
*/
|
|
13865
|
+
components: { securitySchemes: { bearerAuth: {
|
|
13866
|
+
type: "http",
|
|
13867
|
+
scheme: "bearer",
|
|
13868
|
+
description: "An API token from `home-hosted set-token --generate`. A cookie session works too, but is not part of this scheme."
|
|
13869
|
+
} } },
|
|
13870
|
+
security: [{ bearerAuth: [] }],
|
|
13871
|
+
servers: [{
|
|
13872
|
+
url: "/",
|
|
13873
|
+
description: "This panel"
|
|
13874
|
+
}]
|
|
13875
|
+
}
|
|
13876
|
+
})).get(`${PREFIX}/ui`, (c) => c.html(openApiReferencePage(`${PREFIX}/spec.json`)));
|
|
13626
13877
|
}
|
|
13627
13878
|
var PREFIX;
|
|
13628
13879
|
var init_openapi = __esmMin((() => {
|
|
13629
13880
|
init_factory();
|
|
13881
|
+
init_openapi$1();
|
|
13630
13882
|
init_version();
|
|
13631
13883
|
init_openapi_reference();
|
|
13632
13884
|
PREFIX = "/openapi";
|
|
@@ -15106,7 +15358,7 @@ function dependenciesOf(server, servers) {
|
|
|
15106
15358
|
if (seen.has(dependency)) continue;
|
|
15107
15359
|
seen.add(dependency);
|
|
15108
15360
|
const target = byId.get(dependency);
|
|
15109
|
-
if (!target) continue;
|
|
15361
|
+
if (!target || target.id === server.id) continue;
|
|
15110
15362
|
walk(target);
|
|
15111
15363
|
found.push(target);
|
|
15112
15364
|
}
|
|
@@ -17850,7 +18102,13 @@ var init_backups = __esmMin((() => {
|
|
|
17850
18102
|
get directory() {
|
|
17851
18103
|
return this.resolveDir();
|
|
17852
18104
|
}
|
|
17853
|
-
/**
|
|
18105
|
+
/**
|
|
18106
|
+
* The policy and the status: what the settings page shows, and what the state frame carries.
|
|
18107
|
+
*
|
|
18108
|
+
* Deliberately **not** the selection model. `entries()` reads every workspace's `.secrets.json` and
|
|
18109
|
+
* `list()` stats every archive on disk, so including them here made the frame's cost scale with
|
|
18110
|
+
* workspaces × archives on a path rebuilt ~13×/s. A dialog asks `selection()` instead.
|
|
18111
|
+
*/
|
|
17854
18112
|
view() {
|
|
17855
18113
|
const config = this.options.getConfig();
|
|
17856
18114
|
const sources = this.options.getSources();
|
|
@@ -17861,8 +18119,18 @@ var init_backups = __esmMin((() => {
|
|
|
17861
18119
|
schedule: { ...config.schedule },
|
|
17862
18120
|
lastAutomaticAt: this.lastAutomatic(),
|
|
17863
18121
|
...this.scheduleError === null ? {} : { scheduleError: { ...this.scheduleError } },
|
|
17864
|
-
includePaths: [...sources.includePaths]
|
|
17865
|
-
|
|
18122
|
+
includePaths: [...sources.includePaths]
|
|
18123
|
+
};
|
|
18124
|
+
}
|
|
18125
|
+
/**
|
|
18126
|
+
* The selection model: every entry a capture could include, and every archive already on disk.
|
|
18127
|
+
*
|
|
18128
|
+
* Served by `GET /api/backups` and fetched when a dialog opens, never on a per-frame path.
|
|
18129
|
+
*/
|
|
18130
|
+
selection() {
|
|
18131
|
+
return {
|
|
18132
|
+
dir: this.directory,
|
|
18133
|
+
entries: this.entries(this.options.getSources()),
|
|
17866
18134
|
files: this.list()
|
|
17867
18135
|
};
|
|
17868
18136
|
}
|
|
@@ -19434,7 +19702,12 @@ async function sampleHost(config, resolvePath) {
|
|
|
19434
19702
|
tempCelsius,
|
|
19435
19703
|
disks,
|
|
19436
19704
|
alerts,
|
|
19437
|
-
sampledAt: Date.now()
|
|
19705
|
+
sampledAt: Date.now(),
|
|
19706
|
+
loadAlertPerCpu: config.loadPerCpu,
|
|
19707
|
+
memoryUsedPercentAlert: config.memoryUsedPercent,
|
|
19708
|
+
swapUsedPercentAlert: config.swapUsedPercent,
|
|
19709
|
+
tempCelsiusAlert: config.tempCelsius,
|
|
19710
|
+
diskUsedPercentAlert: config.diskUsedPercent
|
|
19438
19711
|
};
|
|
19439
19712
|
}
|
|
19440
19713
|
function emptyHostView(config) {
|
|
@@ -19453,7 +19726,12 @@ function emptyHostView(config) {
|
|
|
19453
19726
|
tempCelsius: null,
|
|
19454
19727
|
disks: [],
|
|
19455
19728
|
alerts: [],
|
|
19456
|
-
sampledAt: null
|
|
19729
|
+
sampledAt: null,
|
|
19730
|
+
loadAlertPerCpu: config.loadPerCpu,
|
|
19731
|
+
memoryUsedPercentAlert: config.memoryUsedPercent,
|
|
19732
|
+
swapUsedPercentAlert: config.swapUsedPercent,
|
|
19733
|
+
tempCelsiusAlert: config.tempCelsius,
|
|
19734
|
+
diskUsedPercentAlert: config.diskUsedPercent
|
|
19457
19735
|
};
|
|
19458
19736
|
}
|
|
19459
19737
|
var execFileAsync, SWAP_CACHE_MS, swapCache, previousCpuTimes, CPU_SENSOR, ACPI_SENSOR;
|
|
@@ -20616,10 +20894,9 @@ function stateSignature(state) {
|
|
|
20616
20894
|
state.control.auth.exposed,
|
|
20617
20895
|
state.control.restartRequired,
|
|
20618
20896
|
state.control.tls.enabled,
|
|
20619
|
-
state.host
|
|
20620
|
-
state.
|
|
20621
|
-
state.backups.
|
|
20622
|
-
state.backups.entries.length,
|
|
20897
|
+
JSON.stringify(state.host),
|
|
20898
|
+
state.backups.lastAutomaticAt,
|
|
20899
|
+
state.backups.scheduleError?.at ?? 0,
|
|
20623
20900
|
`${state.ui.custom}:${state.ui.meta?.name ?? ""}:${state.ui.meta?.version ?? ""}`,
|
|
20624
20901
|
state.proxy === void 0 ? "" : [
|
|
20625
20902
|
state.proxy.config.enabled,
|
|
@@ -21247,7 +21524,7 @@ function resolveRoot(staging) {
|
|
|
21247
21524
|
}
|
|
21248
21525
|
function readManifest(root) {
|
|
21249
21526
|
try {
|
|
21250
|
-
const parsed = manifestSchema(JSON.parse(
|
|
21527
|
+
const parsed = manifestSchema(JSON.parse(readStateFile(path.join(root, META))));
|
|
21251
21528
|
return parsed instanceof type.errors ? null : parsed;
|
|
21252
21529
|
} catch {
|
|
21253
21530
|
return null;
|
|
@@ -21264,6 +21541,7 @@ function countFiles(root) {
|
|
|
21264
21541
|
var META, MAX_ENTRIES, MAX_BYTES, MAX_NAME, manifestSchema, UiService, installLocks;
|
|
21265
21542
|
var init_ui = __esmMin((() => {
|
|
21266
21543
|
init_atomic();
|
|
21544
|
+
init_config_text();
|
|
21267
21545
|
init_archive();
|
|
21268
21546
|
init_contracts();
|
|
21269
21547
|
init_error_message();
|
|
@@ -21306,7 +21584,7 @@ var init_ui = __esmMin((() => {
|
|
|
21306
21584
|
}
|
|
21307
21585
|
readMeta() {
|
|
21308
21586
|
try {
|
|
21309
|
-
const parsed = uiMetaSchema(JSON.parse(
|
|
21587
|
+
const parsed = uiMetaSchema(JSON.parse(readStateFile(path.join(this.directory, META))));
|
|
21310
21588
|
return parsed instanceof type.errors ? null : parsed;
|
|
21311
21589
|
} catch {
|
|
21312
21590
|
return null;
|
|
@@ -22127,7 +22405,7 @@ function printEffectiveConfig(settings, registry) {
|
|
|
22127
22405
|
const dir = path.join(hhDir, workspace.id);
|
|
22128
22406
|
const read = (name) => {
|
|
22129
22407
|
try {
|
|
22130
|
-
return JSON.parse(
|
|
22408
|
+
return JSON.parse(readStateFile(path.join(dir, name)));
|
|
22131
22409
|
} catch {
|
|
22132
22410
|
return null;
|
|
22133
22411
|
}
|
|
@@ -22151,6 +22429,7 @@ var init_src = __esmMin((() => {
|
|
|
22151
22429
|
init_secrets();
|
|
22152
22430
|
init_settings$1();
|
|
22153
22431
|
init_workspaces();
|
|
22432
|
+
init_config_text();
|
|
22154
22433
|
init_daemon();
|
|
22155
22434
|
init_logger();
|
|
22156
22435
|
init_open();
|
|
@@ -22418,7 +22697,7 @@ async function stopPersistentEntries(handles, options = {}) {
|
|
|
22418
22697
|
});
|
|
22419
22698
|
continue;
|
|
22420
22699
|
}
|
|
22421
|
-
if (
|
|
22700
|
+
if (state.childPid !== null && state.childPid > 0 && !stop.killGroup && (!NANNY_TRAPPED_SIGNALS.has(stop.signal) || nanny === "force-killed")) await terminate(state.childPid, {
|
|
22422
22701
|
signal: "SIGKILL",
|
|
22423
22702
|
killGroup: false,
|
|
22424
22703
|
graceMs: 0
|
|
@@ -22502,7 +22781,12 @@ async function runDown(options = {}) {
|
|
|
22502
22781
|
}
|
|
22503
22782
|
process.stdout.write(`${dim("it did not stop in time — forcing")}\n`);
|
|
22504
22783
|
forceStop(runtime.pid);
|
|
22505
|
-
await waitForExit(runtime.pid, 5e3)
|
|
22784
|
+
if (!await waitForExit(runtime.pid, 5e3)) {
|
|
22785
|
+
process.stdout.write(`${paint("31", "error")} could not stop pid ${runtime.pid} — it is still running, and its record was kept\n`);
|
|
22786
|
+
process.stdout.write(`${dim(`stop it yourself with \`kill -9 ${runtime.pid}\` (Windows: \`taskkill /PID ${runtime.pid} /T /F\`), then run \`down\` again`)}\n`);
|
|
22787
|
+
process.exitCode = 1;
|
|
22788
|
+
return finish();
|
|
22789
|
+
}
|
|
22506
22790
|
clearRuntime();
|
|
22507
22791
|
reportStopped(true);
|
|
22508
22792
|
return finish();
|
|
@@ -22808,13 +23092,19 @@ var init_server = __esmMin((() => {
|
|
|
22808
23092
|
//#region src/cli/restart.ts
|
|
22809
23093
|
var restart_exports = /* @__PURE__ */ __exportAll({ restartCommand: () => restartCommand });
|
|
22810
23094
|
/**
|
|
22811
|
-
*
|
|
23095
|
+
* Whether argv names one of these flags, in either the `--flag value` or `--flag=value` form.
|
|
22812
23096
|
*
|
|
22813
|
-
*
|
|
22814
|
-
*
|
|
22815
|
-
*
|
|
22816
|
-
* what the UI's Restart button has always done and the shell could not.
|
|
23097
|
+
* Read from `rawArgs` rather than the parsed args: citty fills a default in for the boolean flags
|
|
23098
|
+
* (`autostart` defaults to true), so the parsed object cannot tell "the caller said `--no-autostart`"
|
|
23099
|
+
* from "the caller said nothing".
|
|
22817
23100
|
*/
|
|
23101
|
+
function mentions(rawArgs, spellings) {
|
|
23102
|
+
return rawArgs.some((token) => {
|
|
23103
|
+
if (!token.startsWith("-")) return false;
|
|
23104
|
+
const name = token.includes("=") ? token.slice(0, token.indexOf("=")) : token;
|
|
23105
|
+
return spellings.includes(name);
|
|
23106
|
+
});
|
|
23107
|
+
}
|
|
22818
23108
|
function restartCommand(entry) {
|
|
22819
23109
|
return defineCommand({
|
|
22820
23110
|
meta: { name: "restart" },
|
|
@@ -22835,10 +23125,12 @@ function restartCommand(entry) {
|
|
|
22835
23125
|
description: "the workspace to act in (default: the panel's default workspace)"
|
|
22836
23126
|
}
|
|
22837
23127
|
},
|
|
22838
|
-
run: async ({ args }) => {
|
|
23128
|
+
run: async ({ args, rawArgs }) => {
|
|
22839
23129
|
const id = typeof args.id === "string" ? args.id.trim() : "";
|
|
22840
23130
|
if (id.length > 0) {
|
|
22841
23131
|
if (args.withPersistent === true) fail("restart <id> restarts one server — drop --with-persistent, or use it on a bare `restart`");
|
|
23132
|
+
const panelFlag = PANEL_ONLY_FLAGS.find((flag) => mentions(rawArgs, flag.spellings));
|
|
23133
|
+
if (panelFlag !== void 0) fail(`restart <id> restarts one server and takes no panel option — drop ${panelFlag.name}, or use it on a bare \`restart\``);
|
|
22842
23134
|
await runServerAction("restart", id, typeof args.workspace === "string" ? args.workspace.trim() : void 0);
|
|
22843
23135
|
return;
|
|
22844
23136
|
}
|
|
@@ -22867,11 +23159,38 @@ async function startPersistentBack(stopped) {
|
|
|
22867
23159
|
if (body.ok !== true) process.stderr.write(`${paint("31", "error")} ${workspaceId}/${serverId} did not come back: ${body.error ?? `the panel answered ${answer?.status}`}\n`);
|
|
22868
23160
|
}
|
|
22869
23161
|
}
|
|
23162
|
+
var PANEL_ONLY_FLAGS;
|
|
22870
23163
|
var init_restart = __esmMin((() => {
|
|
22871
23164
|
init_down();
|
|
22872
23165
|
init_io();
|
|
22873
23166
|
init_server();
|
|
22874
23167
|
init_up();
|
|
23168
|
+
PANEL_ONLY_FLAGS = [
|
|
23169
|
+
{
|
|
23170
|
+
name: "--port",
|
|
23171
|
+
spellings: ["--port", "-p"]
|
|
23172
|
+
},
|
|
23173
|
+
{
|
|
23174
|
+
name: "--host",
|
|
23175
|
+
spellings: ["--host"]
|
|
23176
|
+
},
|
|
23177
|
+
{
|
|
23178
|
+
name: "--no-autostart",
|
|
23179
|
+
spellings: ["--no-autostart", "--autostart"]
|
|
23180
|
+
},
|
|
23181
|
+
{
|
|
23182
|
+
name: "--open",
|
|
23183
|
+
spellings: ["--open"]
|
|
23184
|
+
},
|
|
23185
|
+
{
|
|
23186
|
+
name: "--foreground",
|
|
23187
|
+
spellings: ["--foreground"]
|
|
23188
|
+
},
|
|
23189
|
+
{
|
|
23190
|
+
name: "--print-config",
|
|
23191
|
+
spellings: ["--print-config"]
|
|
23192
|
+
}
|
|
23193
|
+
];
|
|
22875
23194
|
}));
|
|
22876
23195
|
//#endregion
|
|
22877
23196
|
//#region src/cli/status.ts
|
|
@@ -23016,9 +23335,8 @@ async function runLogs(input) {
|
|
|
23016
23335
|
const lines = parseLines(input.lines);
|
|
23017
23336
|
if (input.follow === true) {
|
|
23018
23337
|
const { followLog } = await Promise.resolve().then(() => (init_daemon_log(), daemon_log_exports));
|
|
23019
|
-
const count = lines === 0 ? DEFAULT_LINES : lines;
|
|
23020
23338
|
if (input.json !== true) {
|
|
23021
|
-
await followLog(daemonLogPath,
|
|
23339
|
+
await followLog(daemonLogPath, lines, (chunk) => process.stdout.write(chunk));
|
|
23022
23340
|
return;
|
|
23023
23341
|
}
|
|
23024
23342
|
const emit = (line) => {
|
|
@@ -23028,7 +23346,7 @@ async function runLogs(input) {
|
|
|
23028
23346
|
})}\n`);
|
|
23029
23347
|
};
|
|
23030
23348
|
let pending = "";
|
|
23031
|
-
await followLog(daemonLogPath,
|
|
23349
|
+
await followLog(daemonLogPath, lines, (chunk) => {
|
|
23032
23350
|
pending += chunk;
|
|
23033
23351
|
const parts = pending.split("\n");
|
|
23034
23352
|
pending = parts.pop() ?? "";
|
|
@@ -23224,6 +23542,7 @@ var init_set_token = __esmMin((() => {
|
|
|
23224
23542
|
//#endregion
|
|
23225
23543
|
//#region src/cli/setup-temp.ts
|
|
23226
23544
|
var setup_temp_exports = /* @__PURE__ */ __exportAll({
|
|
23545
|
+
flagProblem: () => flagProblem,
|
|
23227
23546
|
runSetupTemp: () => runSetupTemp,
|
|
23228
23547
|
setupTempArgs: () => setupTempArgs,
|
|
23229
23548
|
setupTempCommand: () => setupTempCommand,
|
|
@@ -23235,18 +23554,49 @@ function sourceFromFlags(flags) {
|
|
|
23235
23554
|
if (flags.wsl === true) return "wsl";
|
|
23236
23555
|
return null;
|
|
23237
23556
|
}
|
|
23557
|
+
/**
|
|
23558
|
+
* The refusal for a flag set that cannot mean what it says, or `null`.
|
|
23559
|
+
*
|
|
23560
|
+
* `download` is a **modifier of `--wsl`**, not a command of its own: only the WSL2 branch fetches
|
|
23561
|
+
* anything, and the no-flag branch ends before a source is chosen. Left unreachable it was silently
|
|
23562
|
+
* dropped — `setup-temp --download` exited 0 having done nothing, which a script reads as
|
|
23563
|
+
* "installed" — so the flag is refused instead, naming the one it belongs to.
|
|
23564
|
+
*
|
|
23565
|
+
* `--clear` is the opposite request, so pairing it with either is refused rather than letting one
|
|
23566
|
+
* quietly win.
|
|
23567
|
+
*/
|
|
23568
|
+
function flagProblem(flags) {
|
|
23569
|
+
const download = flags.download === void 0 ? null : flags.download === true ? "--download" : "--no-download";
|
|
23570
|
+
if (flags.clear === true) {
|
|
23571
|
+
if (download !== null) return `\`--clear\` and \`${download}\` ask for opposite things — clear the source, or set one up, not both`;
|
|
23572
|
+
if (flags.wsl === true) return "`--clear` and `--wsl` ask for opposite things — clear the source, or set one up, not both";
|
|
23573
|
+
return null;
|
|
23574
|
+
}
|
|
23575
|
+
if (download !== null && flags.wsl !== true) return `\`${download}\` only means something with \`--wsl\` — pass \`setup-temp --wsl ${download}\`, or drop it to read the state`;
|
|
23576
|
+
return null;
|
|
23577
|
+
}
|
|
23238
23578
|
async function runSetupTemp(flags) {
|
|
23579
|
+
const problem = flagProblem(flags);
|
|
23580
|
+
if (problem !== null) fail(problem);
|
|
23239
23581
|
const store = new GlobalSettingsStore(globalSettingsPath);
|
|
23240
23582
|
store.load();
|
|
23241
23583
|
const host = store.host;
|
|
23242
23584
|
const configured = host.tempCommand.trim().length > 0;
|
|
23243
23585
|
if (flags.clear === true) {
|
|
23244
|
-
|
|
23586
|
+
const helper = wslScriptPath();
|
|
23587
|
+
const hadHelper = helper !== null && fs.existsSync(helper);
|
|
23588
|
+
if (configured) store.updateHost({ tempCommand: "" });
|
|
23589
|
+
removeWslTemperatureScript(helper);
|
|
23590
|
+
if (!configured && !hadHelper) {
|
|
23245
23591
|
process.stdout.write("no temperature command is set — nothing to clear\n");
|
|
23246
23592
|
return;
|
|
23247
23593
|
}
|
|
23248
|
-
|
|
23594
|
+
if (!configured) {
|
|
23595
|
+
process.stdout.write(`no temperature command is set — removed the leftover helper at ${dim(helper)}\n`);
|
|
23596
|
+
return;
|
|
23597
|
+
}
|
|
23249
23598
|
process.stdout.write(`${green("temperature command cleared")} — the tile uses the built-in probe again\n`);
|
|
23599
|
+
if (hadHelper) process.stdout.write(` ${dim(`helper ${helper} deleted`)}\n`);
|
|
23250
23600
|
return;
|
|
23251
23601
|
}
|
|
23252
23602
|
const source = sourceFromFlags(flags);
|
|
@@ -23273,11 +23623,7 @@ async function runSetupTemp(flags) {
|
|
|
23273
23623
|
const command = tempCommandFor(scriptPath);
|
|
23274
23624
|
process.stdout.write(` helper ${dim(`${scriptPath} (${windowsScriptPath(scriptPath)} on Windows)`)}\n`);
|
|
23275
23625
|
const probe = await probeWslTemperature(command, 5e3);
|
|
23276
|
-
if (probe.celsius === null) {
|
|
23277
|
-
process.stdout.write(`${fail("not set up")} — the helper did not answer: ${probe.error ?? "unknown reason"}\n`);
|
|
23278
|
-
process.stdout.write(`${dim(`the script is at ${scriptPath}; the config was left unchanged`)}\n`);
|
|
23279
|
-
return;
|
|
23280
|
-
}
|
|
23626
|
+
if (probe.celsius === null) fail(`not set up — the helper did not answer: ${probe.error ?? "unknown reason"}\n the script is at ${scriptPath}; the config was left unchanged`);
|
|
23281
23627
|
store.updateHost({
|
|
23282
23628
|
tempCommand: command,
|
|
23283
23629
|
tempCommandTimeoutMs: 5e3
|
|
@@ -23305,10 +23651,7 @@ async function offerLibreHardwareMonitor(flags) {
|
|
|
23305
23651
|
}
|
|
23306
23652
|
}
|
|
23307
23653
|
const result = await installLibreHardwareMonitor({ onProgress: (message) => process.stdout.write(` ${dim(message)}\n`) });
|
|
23308
|
-
if (result.error !== null) {
|
|
23309
|
-
process.stdout.write(`${fail("the download did not install")} — ${result.error}\n`);
|
|
23310
|
-
return;
|
|
23311
|
-
}
|
|
23654
|
+
if (result.error !== null) fail(`the download did not install — ${result.error}`);
|
|
23312
23655
|
process.stdout.write(` library ${green("installed")} in ${result.dir}\n`);
|
|
23313
23656
|
}
|
|
23314
23657
|
var setupTempArgs, setupTempCommand;
|
|
@@ -23983,9 +24326,17 @@ async function uiUpdate(argv, io) {
|
|
|
23983
24326
|
if (repo === null) throw new Error(`invalid --repo "${values.repo}" — expected an "owner/name" slug, e.g. ${DEFAULT_REPO}`);
|
|
23984
24327
|
installed.repo = repoSlug(repo);
|
|
23985
24328
|
}
|
|
24329
|
+
if (values.asset !== void 0) {
|
|
24330
|
+
const named = values.asset.trim();
|
|
24331
|
+
if (named.length === 0) throw new Error("--asset is empty — name the release asset to install, or drop the flag");
|
|
24332
|
+
installed.asset = named;
|
|
24333
|
+
}
|
|
23986
24334
|
const order = values.old === true ? "older" : "newer";
|
|
23987
24335
|
const repo = installed.repo === null ? null : parseRepoSlug(installed.repo);
|
|
23988
|
-
if (values.tag !== void 0
|
|
24336
|
+
if ((values.tag !== void 0 || values.asset !== void 0) && repo === null) {
|
|
24337
|
+
const flag = values.tag !== void 0 ? "--tag" : "--asset";
|
|
24338
|
+
throw new Error([`${flag} needs a repository to fetch from, and this UI does not declare one`, ` pass it: home-hosted ui-update --repo ${DEFAULT_REPO} ${flag} ${values[values.tag !== void 0 ? "tag" : "asset"]}`].join("\n"));
|
|
24339
|
+
}
|
|
23989
24340
|
if (values.check === true && repo !== null) {
|
|
23990
24341
|
if (isOwnRepo(repo)) {
|
|
23991
24342
|
printCheck(io, installed, values.tag ?? `v${context.version}`);
|
|
@@ -23997,7 +24348,7 @@ async function uiUpdate(argv, io) {
|
|
|
23997
24348
|
return;
|
|
23998
24349
|
}
|
|
23999
24350
|
if (values.tag !== void 0 && repo !== null) {
|
|
24000
|
-
await installTag(repo,
|
|
24351
|
+
await installTag(repo, installed.asset, values.tag, context);
|
|
24001
24352
|
return;
|
|
24002
24353
|
}
|
|
24003
24354
|
let releases = [];
|
|
@@ -24015,7 +24366,7 @@ async function uiUpdate(argv, io) {
|
|
|
24015
24366
|
return;
|
|
24016
24367
|
}
|
|
24017
24368
|
io.write(`${io.style.bold(`${plan.identity.name} ${plan.identity.version ?? ""}`.trim())} is on ${plan.identity.tag ?? "an unknown tag"}; this panel is ${plan.target} — updating\n`);
|
|
24018
|
-
await installTag(repo,
|
|
24369
|
+
await installTag(repo, installed.asset, plan.target, context);
|
|
24019
24370
|
return;
|
|
24020
24371
|
}
|
|
24021
24372
|
if (plan.kind !== "choice") return;
|
|
@@ -24162,6 +24513,7 @@ var init_ui_revert = __esmMin((() => {
|
|
|
24162
24513
|
init_ui();
|
|
24163
24514
|
uiRevertCommand = defineCommand({
|
|
24164
24515
|
meta: { name: "ui-revert" },
|
|
24516
|
+
args: {},
|
|
24165
24517
|
run: async () => {
|
|
24166
24518
|
await runUiRevert();
|
|
24167
24519
|
}
|
|
@@ -24497,7 +24849,7 @@ async function availableRowsFromDisk(action, suffix) {
|
|
|
24497
24849
|
try {
|
|
24498
24850
|
const { service } = await offlineBackup();
|
|
24499
24851
|
await service.warm();
|
|
24500
|
-
if (action === "create") return service.
|
|
24852
|
+
if (action === "create") return service.selection().entries;
|
|
24501
24853
|
const query = new URLSearchParams(suffix.startsWith("?") ? suffix.slice(1) : suffix);
|
|
24502
24854
|
const from = query.get("from");
|
|
24503
24855
|
const name = query.get("name");
|
|
@@ -24572,7 +24924,7 @@ async function runBackupList(json) {
|
|
|
24572
24924
|
}
|
|
24573
24925
|
const { service } = await offlineBackup();
|
|
24574
24926
|
await service.warm();
|
|
24575
|
-
printList(service.
|
|
24927
|
+
printList(service.selection(), json);
|
|
24576
24928
|
}
|
|
24577
24929
|
function printList(view, json) {
|
|
24578
24930
|
const files = view?.files ?? [];
|
|
@@ -24619,7 +24971,7 @@ async function runBackupCreate(options) {
|
|
|
24619
24971
|
}
|
|
24620
24972
|
const { service } = await offlineBackup();
|
|
24621
24973
|
await service.warm();
|
|
24622
|
-
return service.
|
|
24974
|
+
return service.selection().entries;
|
|
24623
24975
|
})();
|
|
24624
24976
|
assertKnown(options.exclude, entries, "--exclude", "create");
|
|
24625
24977
|
assertKnown(scope.kind === "include" ? scope.ids : void 0, entries, "--include", "create");
|
|
@@ -24706,14 +25058,18 @@ function planRefusal(plan) {
|
|
|
24706
25058
|
return null;
|
|
24707
25059
|
}
|
|
24708
25060
|
/**
|
|
24709
|
-
*
|
|
25061
|
+
* A restore's per-item skips, as lines a person can act on.
|
|
24710
25062
|
*
|
|
24711
25063
|
* `skipped` is the same list the UI draws, and it is the only thing that says a piece of an
|
|
24712
25064
|
* otherwise successful restore was left behind — an unreadable `servers.config.json`, a data path
|
|
24713
|
-
* whose declaration changed
|
|
25065
|
+
* whose declaration changed, a dump staged for an entry with no `load` hook. Printing only the
|
|
25066
|
+
* applied count reported such a restore as complete.
|
|
25067
|
+
*
|
|
25068
|
+
* Read from the outcome of the run that is being reported: the plan and the apply answer different
|
|
25069
|
+
* lists, because a skip such as a missing load hook is only known once the files have landed.
|
|
24714
25070
|
*/
|
|
24715
|
-
function restoreNotes(
|
|
24716
|
-
return
|
|
25071
|
+
function restoreNotes(outcome) {
|
|
25072
|
+
return outcome?.skipped ?? [];
|
|
24717
25073
|
}
|
|
24718
25074
|
async function runBackupRestore(options) {
|
|
24719
25075
|
const scope = options.scope;
|
|
@@ -24843,7 +25199,7 @@ async function runBackupRestore(options) {
|
|
|
24843
25199
|
}
|
|
24844
25200
|
const applied = (outcome.items ?? []).filter((item) => item.selected !== false);
|
|
24845
25201
|
const hooks = (outcome.hooks ?? []).filter((hook) => hook.action === "load");
|
|
24846
|
-
const notes = restoreNotes(
|
|
25202
|
+
const notes = restoreNotes(outcome);
|
|
24847
25203
|
if (options.json) {
|
|
24848
25204
|
process.stdout.write(`${JSON.stringify({
|
|
24849
25205
|
action: "restore",
|
|
@@ -25031,8 +25387,7 @@ async function runNanny(spec, statePath) {
|
|
|
25031
25387
|
if (spawned === null) pending = signal;
|
|
25032
25388
|
else stopChild(spawned, signal);
|
|
25033
25389
|
};
|
|
25034
|
-
process.on(
|
|
25035
|
-
process.on("SIGINT", () => onSignal("SIGINT"));
|
|
25390
|
+
for (const signal of NANNY_TRAPPED_SIGNALS) process.on(signal, () => onSignal(signal));
|
|
25036
25391
|
const child = spawnManaged({
|
|
25037
25392
|
command: spec.command,
|
|
25038
25393
|
args: spec.args,
|
|
@@ -25263,8 +25618,8 @@ var SETUP_TEMP_SECTION = {
|
|
|
25263
25618
|
heading: "Options for setup-temp",
|
|
25264
25619
|
lines: [
|
|
25265
25620
|
["--wsl", "read the temperature through the Windows host (WSL2)"],
|
|
25266
|
-
["--download", "fetch LibreHardwareMonitor without asking (for a script)"],
|
|
25267
|
-
["--no-download", "never fetch it; report what is missing"],
|
|
25621
|
+
["--download", "with --wsl: fetch LibreHardwareMonitor without asking (for a script)"],
|
|
25622
|
+
["--no-download", "with --wsl: never fetch it; report what is missing"],
|
|
25268
25623
|
["--clear", "stop using the command and delete the helper"]
|
|
25269
25624
|
]
|
|
25270
25625
|
};
|