home-hosted 0.10.0 → 0.10.2
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/AGENTS.md +78 -0
- package/README.md +39 -13
- package/dist/cli.js +1870 -253
- package/dist/cli.js.map +1 -1
- package/docs/NOTIFICATIONS.md +19 -0
- package/docs/REVERSE_PROXY.md +23 -4
- package/docs/SERVERS.md +70 -3
- package/docs/UI_CREATION.md +13 -3
- package/package.json +1 -2
- package/uis/stock/dist/assets/de-DqCaD5Wo.js +1 -0
- package/uis/stock/dist/assets/es-C9BCeLRB.js +1 -0
- package/uis/stock/dist/assets/fr-DSqr4dJR.js +1 -0
- package/uis/stock/dist/assets/{index-ZrOADDZx.css → index-Cok5msAO.css} +1 -1
- package/uis/stock/dist/assets/{index-aK_CRIGL.js → index-D7Wv0Ecd.js} +12 -12
- package/uis/stock/dist/assets/ja-BXh5KQLu.js +1 -0
- package/uis/stock/dist/assets/ko-CaUuJamy.js +1 -0
- package/uis/stock/dist/assets/ru-DqMXLbiM.js +1 -0
- package/uis/stock/dist/assets/vi-B4JcXw2N.js +1 -0
- package/uis/stock/dist/assets/zh-CN-Bb8pDaqj.js +1 -0
- package/uis/stock/dist/index.html +2 -2
- package/uis/stock/dist/ui.json +3 -3
- package/uis/stock/dist/assets/de-pnMS_erQ.js +0 -1
- package/uis/stock/dist/assets/es-BaIbld2Z.js +0 -1
- package/uis/stock/dist/assets/fr-B2gy4ynV.js +0 -1
- package/uis/stock/dist/assets/ja-DFH5Ol5b.js +0 -1
- package/uis/stock/dist/assets/ko-C3LcaLoa.js +0 -1
- package/uis/stock/dist/assets/ru-B7nB7X1y.js +0 -1
- package/uis/stock/dist/assets/vi-CzXGueBM.js +0 -1
- package/uis/stock/dist/assets/zh-CN-Du_sQUjJ.js +0 -1
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import { LogLevels, createConsola } from "consola";
|
|
|
13
13
|
import { isDevelopment } from "std-env";
|
|
14
14
|
import { DetailedError } from "@namesmt/utils";
|
|
15
15
|
import { type } from "arktype";
|
|
16
|
-
import crypto, { X509Certificate, createPrivateKey, createPublicKey, randomBytes } from "node:crypto";
|
|
16
|
+
import crypto, { X509Certificate, createHash, createPrivateKey, createPublicKey, randomBytes } from "node:crypto";
|
|
17
17
|
import { Readable, Writable } from "node:stream";
|
|
18
18
|
import { bodyLimit } from "hono/body-limit";
|
|
19
19
|
import { streamSSE } from "hono/streaming";
|
|
@@ -24,7 +24,6 @@ import { parseArgs, promisify } from "node:util";
|
|
|
24
24
|
import net, { isIP } from "node:net";
|
|
25
25
|
import { Hono } from "hono";
|
|
26
26
|
import { HTTPException } from "hono/http-exception";
|
|
27
|
-
import { Scalar } from "@scalar/hono-api-reference";
|
|
28
27
|
import https from "node:https";
|
|
29
28
|
import { finished } from "node:stream/promises";
|
|
30
29
|
import { BlobReader, ZipReader, ZipWriter, configure } from "@zip.js/zip.js";
|
|
@@ -292,6 +291,18 @@ function invocation() {
|
|
|
292
291
|
if (/[\\/]cli\.ts$/.test(entry)) return "pnpm exec tsx src/cli.ts";
|
|
293
292
|
return "home-hosted";
|
|
294
293
|
}
|
|
294
|
+
function isClosedReaderError(error) {
|
|
295
|
+
const code = error?.code;
|
|
296
|
+
if (typeof code === "string" && READER_GONE.test(code)) return true;
|
|
297
|
+
const message = error?.message ?? "";
|
|
298
|
+
return /^(?:closed|write after end|premature close)$/i.test(message);
|
|
299
|
+
}
|
|
300
|
+
function treatClosedReaderAsDone() {
|
|
301
|
+
process.stdout.on("error", (error) => {
|
|
302
|
+
if (isClosedReaderError(error)) process.exit(0);
|
|
303
|
+
throw error;
|
|
304
|
+
});
|
|
305
|
+
}
|
|
295
306
|
/** One shape for every failure: a red `error <message>` on stderr and exit 1. */
|
|
296
307
|
function fail(message) {
|
|
297
308
|
process.stderr.write(`${paint("31", "error")} ${message}\n`);
|
|
@@ -341,7 +352,7 @@ async function confirm(question, fallback) {
|
|
|
341
352
|
if (answer.length === 0) return fallback;
|
|
342
353
|
return answer === "y" || answer === "yes";
|
|
343
354
|
}
|
|
344
|
-
var isTty, paint, dim, bold, cyan, green, heading, style;
|
|
355
|
+
var isTty, paint, dim, bold, cyan, green, heading, style, READER_GONE;
|
|
345
356
|
var init_io = __esmMin((() => {
|
|
346
357
|
isTty = () => process.stdout.isTTY === true;
|
|
347
358
|
paint = (code, text) => isTty() ? `\x1B[${code}m${text}\x1B[0m` : text;
|
|
@@ -355,6 +366,7 @@ var init_io = __esmMin((() => {
|
|
|
355
366
|
dim,
|
|
356
367
|
green
|
|
357
368
|
};
|
|
369
|
+
READER_GONE = /^(?:EPIPE|ERR_STREAM_DESTROYED|ERR_STREAM_WRITE_AFTER_END|ECONNRESET)$/;
|
|
358
370
|
}));
|
|
359
371
|
//#endregion
|
|
360
372
|
//#region src/helpers/runtime.ts
|
|
@@ -411,22 +423,22 @@ var version_exports = /* @__PURE__ */ __exportAll({
|
|
|
411
423
|
* import there would pull the daemon graph in before citty is even asked anything.
|
|
412
424
|
*/
|
|
413
425
|
function appVersion() {
|
|
414
|
-
if (cached !== null) return cached;
|
|
426
|
+
if (cached$1 !== null) return cached$1;
|
|
415
427
|
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
416
428
|
for (let depth = 0; depth < 4; depth++) {
|
|
417
429
|
try {
|
|
418
430
|
const manifest = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
|
|
419
431
|
if (manifest.name === "home-hosted" && typeof manifest.version === "string") {
|
|
420
|
-
cached = manifest.version;
|
|
421
|
-
return cached;
|
|
432
|
+
cached$1 = manifest.version;
|
|
433
|
+
return cached$1;
|
|
422
434
|
}
|
|
423
435
|
} catch {}
|
|
424
436
|
const parent = path.dirname(dir);
|
|
425
437
|
if (parent === dir) break;
|
|
426
438
|
dir = parent;
|
|
427
439
|
}
|
|
428
|
-
cached = "0.0.0";
|
|
429
|
-
return cached;
|
|
440
|
+
cached$1 = "0.0.0";
|
|
441
|
+
return cached$1;
|
|
430
442
|
}
|
|
431
443
|
/**
|
|
432
444
|
* The one line to add when this CLI and the panel it is talking to are not the same
|
|
@@ -437,9 +449,9 @@ function versionMismatchNote(panelVersion) {
|
|
|
437
449
|
const cli = appVersion();
|
|
438
450
|
return cli === panelVersion ? null : `note: this CLI is ${cli}, the panel is ${panelVersion}`;
|
|
439
451
|
}
|
|
440
|
-
var cached;
|
|
452
|
+
var cached$1;
|
|
441
453
|
var init_version = __esmMin((() => {
|
|
442
|
-
cached = null;
|
|
454
|
+
cached$1 = null;
|
|
443
455
|
}));
|
|
444
456
|
//#endregion
|
|
445
457
|
//#region src/helpers/daemon-log.ts
|
|
@@ -731,6 +743,153 @@ function secureCookieFor(mode, protocol) {
|
|
|
731
743
|
var init_cookies = __esmMin((() => {}));
|
|
732
744
|
//#endregion
|
|
733
745
|
//#region src/shared/contracts.ts
|
|
746
|
+
var contracts_exports = /* @__PURE__ */ __exportAll({
|
|
747
|
+
actionResultSchema: () => actionResultSchema,
|
|
748
|
+
apiErrorSchema: () => apiErrorSchema,
|
|
749
|
+
appStateSchema: () => appStateSchema,
|
|
750
|
+
authSchema: () => authSchema,
|
|
751
|
+
authStatusSchema: () => authStatusSchema,
|
|
752
|
+
backupCreateSchema: () => backupCreateSchema,
|
|
753
|
+
backupCreatedResponseSchema: () => backupCreatedResponseSchema,
|
|
754
|
+
backupEntrySchema: () => backupEntrySchema,
|
|
755
|
+
backupFileSchema: () => backupFileSchema,
|
|
756
|
+
backupFilesResponseSchema: () => backupFilesResponseSchema,
|
|
757
|
+
backupHookOrNullSchema: () => backupHookOrNullSchema,
|
|
758
|
+
backupHookSchema: () => backupHookSchema,
|
|
759
|
+
backupScheduleSchema: () => backupScheduleSchema,
|
|
760
|
+
backupScheduleViewSchema: () => backupScheduleViewSchema,
|
|
761
|
+
backupScopeSchema: () => backupScopeSchema,
|
|
762
|
+
backupsSchema: () => backupsSchema,
|
|
763
|
+
backupsViewSchema: () => backupsViewSchema,
|
|
764
|
+
bindSchema: () => bindSchema,
|
|
765
|
+
bootstrapOrNullSchema: () => bootstrapOrNullSchema,
|
|
766
|
+
bootstrapSchema: () => bootstrapSchema,
|
|
767
|
+
controlSchema: () => controlSchema,
|
|
768
|
+
controlViewSchema: () => controlViewSchema,
|
|
769
|
+
ddnsAccountSchema: () => ddnsAccountSchema,
|
|
770
|
+
ddnsConfigSchema: () => ddnsConfigSchema,
|
|
771
|
+
ddnsCredentialsSchema: () => ddnsCredentialsSchema,
|
|
772
|
+
ddnsDomainSchema: () => ddnsDomainSchema,
|
|
773
|
+
ddnsIpv4Schema: () => ddnsIpv4Schema,
|
|
774
|
+
ddnsIpv6Schema: () => ddnsIpv6Schema,
|
|
775
|
+
ddnsPatchSchema: () => ddnsPatchSchema,
|
|
776
|
+
ddnsProviderFieldSchema: () => ddnsProviderFieldSchema,
|
|
777
|
+
ddnsProviderInfoSchema: () => ddnsProviderInfoSchema,
|
|
778
|
+
ddnsRecordStateSchema: () => ddnsRecordStateSchema,
|
|
779
|
+
ddnsRecordTypeSchema: () => ddnsRecordTypeSchema,
|
|
780
|
+
ddnsRecordViewSchema: () => ddnsRecordViewSchema,
|
|
781
|
+
ddnsStatusSchema: () => ddnsStatusSchema,
|
|
782
|
+
ddnsViewSchema: () => ddnsViewSchema,
|
|
783
|
+
defaultsSchema: () => defaultsSchema,
|
|
784
|
+
deliveryResultSchema: () => deliveryResultSchema,
|
|
785
|
+
destinationIdParamSchema: () => destinationIdParamSchema,
|
|
786
|
+
destinationStatusSchema: () => destinationStatusSchema,
|
|
787
|
+
destinationTestSchema: () => destinationTestSchema,
|
|
788
|
+
duplicateWebhookIds: () => duplicateWebhookIds,
|
|
789
|
+
entryStateSchema: () => entryStateSchema,
|
|
790
|
+
freePortResultSchema: () => freePortResultSchema,
|
|
791
|
+
healthResponseSchema: () => healthResponseSchema,
|
|
792
|
+
healthSchema: () => healthSchema,
|
|
793
|
+
healthStateSchema: () => healthStateSchema,
|
|
794
|
+
historyActorSchema: () => historyActorSchema,
|
|
795
|
+
historyEventSchema: () => historyEventSchema,
|
|
796
|
+
hostDiskSchema: () => hostDiskSchema,
|
|
797
|
+
hostSchema: () => hostSchema,
|
|
798
|
+
hostViewSchema: () => hostViewSchema,
|
|
799
|
+
httpCheckSchema: () => httpCheckSchema,
|
|
800
|
+
labelOrNullSchema: () => labelOrNullSchema,
|
|
801
|
+
logBufferLinesSchema: () => logBufferLinesSchema,
|
|
802
|
+
logFileInfoSchema: () => logFileInfoSchema,
|
|
803
|
+
logHistoryQuerySchema: () => logHistoryQuerySchema,
|
|
804
|
+
logHistoryViewSchema: () => logHistoryViewSchema,
|
|
805
|
+
logLineSchema: () => logLineSchema,
|
|
806
|
+
logLinesResponseSchema: () => logLinesResponseSchema,
|
|
807
|
+
logQuerySchema: () => logQuerySchema,
|
|
808
|
+
logServerViewSchema: () => logServerViewSchema,
|
|
809
|
+
logServersViewSchema: () => logServersViewSchema,
|
|
810
|
+
logStreamSchema: () => logStreamSchema,
|
|
811
|
+
loginSchema: () => loginSchema,
|
|
812
|
+
logsSchema: () => logsSchema,
|
|
813
|
+
nannyExitSchema: () => nannyExitSchema,
|
|
814
|
+
nannySpecSchema: () => nannySpecSchema,
|
|
815
|
+
nannyStateSchema: () => nannyStateSchema,
|
|
816
|
+
notificationActionSchema: () => notificationActionSchema,
|
|
817
|
+
notificationDefaultsSchema: () => notificationDefaultsSchema,
|
|
818
|
+
notificationDefaultsViewSchema: () => notificationDefaultsViewSchema,
|
|
819
|
+
notificationTargetSchema: () => notificationTargetSchema,
|
|
820
|
+
notificationViewSchema: () => notificationViewSchema,
|
|
821
|
+
notificationsSchema: () => notificationsSchema,
|
|
822
|
+
okResponseSchema: () => okResponseSchema,
|
|
823
|
+
onPortConflictDefaultSchema: () => onPortConflictDefaultSchema,
|
|
824
|
+
onPortConflictSchema: () => onPortConflictSchema,
|
|
825
|
+
parseBind: () => parseBind,
|
|
826
|
+
passwordSchema: () => passwordSchema,
|
|
827
|
+
passwordSetResponseSchema: () => passwordSetResponseSchema,
|
|
828
|
+
passwordValueSchema: () => passwordValueSchema,
|
|
829
|
+
portSchema: () => portSchema,
|
|
830
|
+
portStateSchema: () => portStateSchema,
|
|
831
|
+
processResourcesSchema: () => processResourcesSchema,
|
|
832
|
+
proxyCertificateSchema: () => proxyCertificateSchema,
|
|
833
|
+
proxyCertificateStateSchema: () => proxyCertificateStateSchema,
|
|
834
|
+
proxyCertificateUploadSchema: () => proxyCertificateUploadSchema,
|
|
835
|
+
proxyCertificateViewSchema: () => proxyCertificateViewSchema,
|
|
836
|
+
proxyConfigSchema: () => proxyConfigSchema,
|
|
837
|
+
proxyDns01Schema: () => proxyDns01Schema,
|
|
838
|
+
proxyDnsAccountViewSchema: () => proxyDnsAccountViewSchema,
|
|
839
|
+
proxyEngineInfoSchema: () => proxyEngineInfoSchema,
|
|
840
|
+
proxyEngineInstallSchema: () => proxyEngineInstallSchema,
|
|
841
|
+
proxyEngineSchema: () => proxyEngineSchema,
|
|
842
|
+
proxyEngineSourceSchema: () => proxyEngineSourceSchema,
|
|
843
|
+
proxyEngineStatusSchema: () => proxyEngineStatusSchema,
|
|
844
|
+
proxyPatchSchema: () => proxyPatchSchema,
|
|
845
|
+
proxyRoutePatchSchema: () => proxyRoutePatchSchema,
|
|
846
|
+
proxyRouteSchema: () => proxyRouteSchema,
|
|
847
|
+
proxyRouteStatusSchema: () => proxyRouteStatusSchema,
|
|
848
|
+
proxyRouteViewSchema: () => proxyRouteViewSchema,
|
|
849
|
+
proxyRunStateSchema: () => proxyRunStateSchema,
|
|
850
|
+
proxyStatusSchema: () => proxyStatusSchema,
|
|
851
|
+
proxyTargetSchema: () => proxyTargetSchema,
|
|
852
|
+
proxyTlsModeSchema: () => proxyTlsModeSchema,
|
|
853
|
+
proxyViewSchema: () => proxyViewSchema,
|
|
854
|
+
resourcesSchema: () => resourcesSchema,
|
|
855
|
+
restartSchema: () => restartSchema,
|
|
856
|
+
restoreItemSchema: () => restoreItemSchema,
|
|
857
|
+
restorePlanSchema: () => restorePlanSchema,
|
|
858
|
+
restoreRequestSchema: () => restoreRequestSchema,
|
|
859
|
+
restoreSkipSchema: () => restoreSkipSchema,
|
|
860
|
+
serverCreateSchema: () => serverCreateSchema,
|
|
861
|
+
serverHistorySchema: () => serverHistorySchema,
|
|
862
|
+
serverOrphanSchema: () => serverOrphanSchema,
|
|
863
|
+
serverPatchSchema: () => serverPatchSchema,
|
|
864
|
+
serverSchema: () => serverSchema,
|
|
865
|
+
serverStatusSchema: () => serverStatusSchema,
|
|
866
|
+
serverViewSchema: () => serverViewSchema,
|
|
867
|
+
sessionViewSchema: () => sessionViewSchema,
|
|
868
|
+
settingsPatchSchema: () => settingsPatchSchema,
|
|
869
|
+
settingsSavedSchema: () => settingsSavedSchema,
|
|
870
|
+
settingsViewSchema: () => settingsViewSchema,
|
|
871
|
+
sseMessageSchema: () => sseMessageSchema,
|
|
872
|
+
stopSchema: () => stopSchema,
|
|
873
|
+
telegramChatsSchema: () => telegramChatsSchema,
|
|
874
|
+
telegramTokenSchema: () => telegramTokenSchema,
|
|
875
|
+
tlsReviewResponseSchema: () => tlsReviewResponseSchema,
|
|
876
|
+
tlsSchema: () => tlsSchema,
|
|
877
|
+
tlsStatusSchema: () => tlsStatusSchema,
|
|
878
|
+
tlsUploadSchema: () => tlsUploadSchema,
|
|
879
|
+
uiInstallResponseSchema: () => uiInstallResponseSchema,
|
|
880
|
+
uiMetaSchema: () => uiMetaSchema,
|
|
881
|
+
uiStatusSchema: () => uiStatusSchema,
|
|
882
|
+
webhookTargetSchema: () => webhookTargetSchema,
|
|
883
|
+
workspaceCreateSchema: () => workspaceCreateSchema,
|
|
884
|
+
workspaceIdSchema: () => workspaceIdSchema,
|
|
885
|
+
workspaceRenameSchema: () => workspaceRenameSchema,
|
|
886
|
+
workspaceSchema: () => workspaceSchema,
|
|
887
|
+
workspaceSettingsPatchSchema: () => workspaceSettingsPatchSchema,
|
|
888
|
+
workspaceSettingsSavedSchema: () => workspaceSettingsSavedSchema,
|
|
889
|
+
workspaceSettingsViewSchema: () => workspaceSettingsViewSchema,
|
|
890
|
+
workspaceViewSchema: () => workspaceViewSchema,
|
|
891
|
+
wslTemperatureSchema: () => wslTemperatureSchema
|
|
892
|
+
});
|
|
734
893
|
/** Parses a bind value (`local` | `lan` | ipv4); null when it is not one. */
|
|
735
894
|
function parseBind(value) {
|
|
736
895
|
const parsed = bindSchema(value);
|
|
@@ -751,7 +910,7 @@ function duplicateWebhookIds(targets) {
|
|
|
751
910
|
}
|
|
752
911
|
return [...duplicates];
|
|
753
912
|
}
|
|
754
|
-
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, 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, backupFileSchema, backupEntrySchema, backupScheduleViewSchema, backupsViewSchema, restoreItemSchema, restoreSkipSchema, restorePlanSchema, backupCreateSchema, restoreRequestSchema, serverViewSchema, healthResponseSchema, controlViewSchema, uiMetaSchema, uiStatusSchema, serverOrphanSchema, workspaceViewSchema, appStateSchema, logQuerySchema, actionResultSchema, deliveryResultSchema, passwordSetResponseSchema, tlsReviewResponseSchema, okResponseSchema, backupFilesResponseSchema, uiInstallResponseSchema, backupCreatedResponseSchema, logLinesResponseSchema, freePortResultSchema, logHistoryQuerySchema, logFileInfoSchema, logServerViewSchema, logServersViewSchema, notificationActionSchema, destinationIdParamSchema, destinationTestSchema, telegramTokenSchema, apiErrorSchema, tlsUploadSchema, settingsViewSchema, settingsSavedSchema, workspaceSettingsViewSchema, workspaceSettingsSavedSchema;
|
|
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;
|
|
755
914
|
var init_contracts = __esmMin((() => {
|
|
756
915
|
bindSchema = type("\"local\" | \"lan\" | /^\\d{1,3}(?:\\.\\d{1,3}){3}$/");
|
|
757
916
|
workspaceIdSchema = type("/^[a-z0-9][a-z0-9_-]*$/");
|
|
@@ -970,7 +1129,18 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
970
1129
|
memoryUsedPercent: "number >= 0 = 90",
|
|
971
1130
|
swapUsedPercent: "number >= 0 = 50",
|
|
972
1131
|
loadPerCpu: "number >= 0 = 2",
|
|
973
|
-
tempCelsius: "number >= 0 = 85"
|
|
1132
|
+
tempCelsius: "number >= 0 = 85",
|
|
1133
|
+
/**
|
|
1134
|
+
* How to read the CPU temperature when the kernel exposes no sensor.
|
|
1135
|
+
*
|
|
1136
|
+
* A command whose stdout is a number in °C — the escape hatch for a machine this panel cannot read
|
|
1137
|
+
* for itself (a WSL2 guest, a VM, a board whose hwmon chip is unsupported). Empty means "use the
|
|
1138
|
+
* built-in probe". It runs on the sampling interval, so it must be cheap; `docs/SERVERS.md` carries
|
|
1139
|
+
* the WSL2 setup.
|
|
1140
|
+
*/
|
|
1141
|
+
tempCommand: "string <= 512 = \"\"",
|
|
1142
|
+
/** How long that command may run before it is killed, so a hung helper cannot stall a sample. */
|
|
1143
|
+
tempCommandTimeoutMs: "100 <= number <= 30000 = 5000"
|
|
974
1144
|
}).onUndeclaredKey("reject");
|
|
975
1145
|
ddnsRecordTypeSchema = type.enumerated("A", "AAAA");
|
|
976
1146
|
ddnsAccountSchema = type({
|
|
@@ -1062,7 +1232,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
1062
1232
|
provider: "string >= 1",
|
|
1063
1233
|
credentials: type("Record<string, string>")
|
|
1064
1234
|
}).onUndeclaredKey("reject");
|
|
1065
|
-
type({
|
|
1235
|
+
ddnsPatchSchema = type({
|
|
1066
1236
|
enabled: "boolean?",
|
|
1067
1237
|
intervalMs: "number >= 60000?",
|
|
1068
1238
|
ipv4: type({
|
|
@@ -1210,7 +1380,9 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
1210
1380
|
memoryUsedPercent: "number >= 0?",
|
|
1211
1381
|
swapUsedPercent: "number >= 0?",
|
|
1212
1382
|
loadPerCpu: "number >= 0?",
|
|
1213
|
-
tempCelsius: "number >= 0?"
|
|
1383
|
+
tempCelsius: "number >= 0?",
|
|
1384
|
+
tempCommand: "string <= 512?",
|
|
1385
|
+
tempCommandTimeoutMs: "100 <= number <= 30000?"
|
|
1214
1386
|
}).onUndeclaredKey("reject");
|
|
1215
1387
|
backupSchedulePatchSchema = type({
|
|
1216
1388
|
intervalMs: "number.integer >= 0?",
|
|
@@ -1690,6 +1862,26 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
1690
1862
|
"alerts": type("string[]"),
|
|
1691
1863
|
"sampledAt": "number | null"
|
|
1692
1864
|
});
|
|
1865
|
+
wslTemperatureSchema = type({
|
|
1866
|
+
/** This process runs under WSL. */
|
|
1867
|
+
"wsl": "boolean",
|
|
1868
|
+
/** The setup can work here — the same as `wsl` today, separate so a future bridge can differ. */
|
|
1869
|
+
"supported": "boolean",
|
|
1870
|
+
/** `host.tempCommand` already names a command. */
|
|
1871
|
+
"configured": "boolean",
|
|
1872
|
+
/** The helper script exists on disk. */
|
|
1873
|
+
"scriptWritten": "boolean",
|
|
1874
|
+
/** LibreHardwareMonitor was found on the Windows side. */
|
|
1875
|
+
"libraryPresent": "boolean",
|
|
1876
|
+
/** Where the helper was written, for the sentence that tells a person what to delete. */
|
|
1877
|
+
"scriptPath": "string | null",
|
|
1878
|
+
/** The command the panel would run, absent until it is configured. */
|
|
1879
|
+
"tempCommand?": "string | null",
|
|
1880
|
+
/** The last probe's reading, so the page can say "this works" without running it again. */
|
|
1881
|
+
"lastReadingCelsius?": "number | null",
|
|
1882
|
+
/** Why the last probe failed, if it did — a missing library and no sensor read differently. */
|
|
1883
|
+
"lastError?": "string | null"
|
|
1884
|
+
});
|
|
1693
1885
|
backupFileSchema = type({
|
|
1694
1886
|
name: "string",
|
|
1695
1887
|
sizeBytes: "number",
|
|
@@ -2023,7 +2215,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
2023
2215
|
/** The release this panel is running. Optional: an older panel does not send one. */
|
|
2024
2216
|
"version?": "string"
|
|
2025
2217
|
});
|
|
2026
|
-
type({
|
|
2218
|
+
sseMessageSchema = type({
|
|
2027
2219
|
"type": "\"hello\" | \"state\" | \"log\" | \"server\"",
|
|
2028
2220
|
"ts": "number",
|
|
2029
2221
|
"workspaceId?": "string",
|
|
@@ -2113,7 +2305,7 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
2113
2305
|
files: logFileInfoSchema.array()
|
|
2114
2306
|
});
|
|
2115
2307
|
logServersViewSchema = type({ servers: logServerViewSchema.array() });
|
|
2116
|
-
type({
|
|
2308
|
+
logHistoryViewSchema = type({
|
|
2117
2309
|
serverId: "string",
|
|
2118
2310
|
enabled: "boolean",
|
|
2119
2311
|
sizeBytes: "number",
|
|
@@ -3177,9 +3369,29 @@ var init_auth = __esmMin((() => {
|
|
|
3177
3369
|
}));
|
|
3178
3370
|
//#endregion
|
|
3179
3371
|
//#region src/helpers/bind.ts
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3372
|
+
/**
|
|
3373
|
+
* This machine's first non-internal IPv4 address, or null when it has none.
|
|
3374
|
+
*
|
|
3375
|
+
* Cached for `LAN_ADDRESS_TTL_MS`: the call is expensive and its answer is read per server per
|
|
3376
|
+
* state frame. The cache is module state, which is acceptable here for the same reason
|
|
3377
|
+
* `appVersion()`'s is — the answer is a property of the host, not of a workspace, and nothing in
|
|
3378
|
+
* a test changes the interfaces it observes.
|
|
3379
|
+
*/
|
|
3380
|
+
function lanAddress(now = Date.now()) {
|
|
3381
|
+
if (cached !== null && now - cached.at < LAN_ADDRESS_TTL_MS) return cached.value;
|
|
3382
|
+
let value = null;
|
|
3383
|
+
for (const entries of Object.values(os.networkInterfaces())) {
|
|
3384
|
+
for (const entry of entries ?? []) if (entry.family === "IPv4" && !entry.internal) {
|
|
3385
|
+
value = entry.address;
|
|
3386
|
+
break;
|
|
3387
|
+
}
|
|
3388
|
+
if (value !== null) break;
|
|
3389
|
+
}
|
|
3390
|
+
cached = {
|
|
3391
|
+
value,
|
|
3392
|
+
at: now
|
|
3393
|
+
};
|
|
3394
|
+
return value;
|
|
3183
3395
|
}
|
|
3184
3396
|
function bindHost(bind) {
|
|
3185
3397
|
if (bind === "local") return "127.0.0.1";
|
|
@@ -3196,7 +3408,11 @@ function displayHost(bind) {
|
|
|
3196
3408
|
function isExposed(bind) {
|
|
3197
3409
|
return bindHost(bind) !== "127.0.0.1";
|
|
3198
3410
|
}
|
|
3199
|
-
var
|
|
3411
|
+
var LAN_ADDRESS_TTL_MS, cached;
|
|
3412
|
+
var init_bind = __esmMin((() => {
|
|
3413
|
+
LAN_ADDRESS_TTL_MS = 3e4;
|
|
3414
|
+
cached = null;
|
|
3415
|
+
}));
|
|
3200
3416
|
//#endregion
|
|
3201
3417
|
//#region src/services/exposure.ts
|
|
3202
3418
|
/**
|
|
@@ -3471,7 +3687,6 @@ var paths_exports = /* @__PURE__ */ __exportAll({
|
|
|
3471
3687
|
workspaceDdnsStatePath: () => workspaceDdnsStatePath,
|
|
3472
3688
|
workspaceDir: () => workspaceDir,
|
|
3473
3689
|
workspaceHistoryPath: () => workspaceHistoryPath,
|
|
3474
|
-
workspaceIdsOnDisk: () => workspaceIdsOnDisk,
|
|
3475
3690
|
workspaceLogsDir: () => workspaceLogsDir,
|
|
3476
3691
|
workspaceSecretsPath: () => workspaceSecretsPath,
|
|
3477
3692
|
workspaceServersPath: () => workspaceServersPath,
|
|
@@ -3536,14 +3751,6 @@ function workspaceStateDir(id) {
|
|
|
3536
3751
|
function workspaceDdnsStatePath(id) {
|
|
3537
3752
|
return path.join(workspaceStateDir(id), "ddns.json");
|
|
3538
3753
|
}
|
|
3539
|
-
/** Every directory a nanny state file may sit in, across all workspaces. */
|
|
3540
|
-
function workspaceIdsOnDisk() {
|
|
3541
|
-
try {
|
|
3542
|
-
return fs.readdirSync(hhDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).filter((id) => /^[a-z0-9][a-z0-9_-]*$/.test(id));
|
|
3543
|
-
} catch {
|
|
3544
|
-
return [];
|
|
3545
|
-
}
|
|
3546
|
-
}
|
|
3547
3754
|
/**
|
|
3548
3755
|
* True when a pre-workspace instance left state at the old paths **and** never
|
|
3549
3756
|
* crossed into `.hh`: `workspaces.json` means the layout is current, so a stray
|
|
@@ -4311,7 +4518,8 @@ function createControlRoute(deps) {
|
|
|
4311
4518
|
}
|
|
4312
4519
|
}), (c) => {
|
|
4313
4520
|
assertLocalCall(c, "stop the control panel");
|
|
4314
|
-
|
|
4521
|
+
const withPersistent = c.req.query("withPersistent") === "true";
|
|
4522
|
+
afterResponse(() => deps.onShutdown({ withPersistent }), (error) => logger.error("shutdown failed", error));
|
|
4315
4523
|
return c.json({ ok: true });
|
|
4316
4524
|
}).post("/servers/:id/start", describeRoute({
|
|
4317
4525
|
tags: ["panel"],
|
|
@@ -4955,6 +5163,10 @@ var init_seed = __esmMin((() => {
|
|
|
4955
5163
|
}));
|
|
4956
5164
|
//#endregion
|
|
4957
5165
|
//#region src/config/settings.ts
|
|
5166
|
+
var settings_exports = /* @__PURE__ */ __exportAll({
|
|
5167
|
+
ConfigError: () => ConfigError,
|
|
5168
|
+
GlobalSettingsStore: () => GlobalSettingsStore
|
|
5169
|
+
});
|
|
4958
5170
|
var ConfigError, GlobalSettingsStore;
|
|
4959
5171
|
var init_settings$1 = __esmMin((() => {
|
|
4960
5172
|
init_migrations();
|
|
@@ -6751,6 +6963,22 @@ function webhookPayload(event, now = Date.now()) {
|
|
|
6751
6963
|
};
|
|
6752
6964
|
}
|
|
6753
6965
|
/**
|
|
6966
|
+
* What `Headers` will refuse, decided here so the refusal names the line.
|
|
6967
|
+
*
|
|
6968
|
+
* This is not a second opinion about validity: `Headers` (and Node's own `http`) throw on a name
|
|
6969
|
+
* holding a space or a non-ASCII letter, and on a value holding a character above `0xFF` — so
|
|
6970
|
+
* `Title: 🔴 server down` fails at the request with `Cannot convert argument to a ByteString …
|
|
6971
|
+
* value of 55357`, beside a `lastResult` a person reads as the receiver's fault. HTTP header values
|
|
6972
|
+
* are bytes, not text: ntfy's own answer for an emoji title is `=?UTF-8?B?…?=`. Naming both here
|
|
6973
|
+
* means the save is refused with the line quoted, and a config that already holds one says which
|
|
6974
|
+
* header it is instead of surfacing a JS engine message.
|
|
6975
|
+
*/
|
|
6976
|
+
function headerProblem(name, value) {
|
|
6977
|
+
if (!/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(name)) return `"${name}" is not a valid header name`;
|
|
6978
|
+
for (const char of value) if (char.codePointAt(0) > 255) return `the "${name}" value holds a character a header cannot carry (${char}) — headers are bytes, so encode it (ntfy reads \`=?UTF-8?B?…?=\`) or use format: json, which carries text in the body`;
|
|
6979
|
+
return null;
|
|
6980
|
+
}
|
|
6981
|
+
/**
|
|
6754
6982
|
* `Name: value` lines into a header map.
|
|
6755
6983
|
*
|
|
6756
6984
|
* The format is line-based rather than a JSON object because it is edited in a textarea, and
|
|
@@ -6777,6 +7005,13 @@ function parseHeaders(text, vars = process.env) {
|
|
|
6777
7005
|
const name = trimmed.slice(0, at).trim();
|
|
6778
7006
|
const value = expandEnv(trimmed.slice(at + 1).trim(), vars);
|
|
6779
7007
|
if (value.includes("${")) unexpanded.push(name);
|
|
7008
|
+
else {
|
|
7009
|
+
const problem = headerProblem(name, value);
|
|
7010
|
+
if (problem !== null) {
|
|
7011
|
+
errors.push(problem);
|
|
7012
|
+
continue;
|
|
7013
|
+
}
|
|
7014
|
+
}
|
|
6780
7015
|
headers[name] = value;
|
|
6781
7016
|
}
|
|
6782
7017
|
return {
|
|
@@ -6819,13 +7054,16 @@ async function sendWebhook(target, event, fetchImpl) {
|
|
|
6819
7054
|
ok: false,
|
|
6820
7055
|
error: `the URL still holds an unexpanded placeholder: ${url}`
|
|
6821
7056
|
};
|
|
7057
|
+
const sent = { "content-type": asText ? "text/plain; charset=utf-8" : "application/json" };
|
|
7058
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
7059
|
+
const key = name.toLowerCase();
|
|
7060
|
+
for (const existing of Object.keys(sent)) if (existing.toLowerCase() === key) delete sent[existing];
|
|
7061
|
+
sent[name] = value;
|
|
7062
|
+
}
|
|
6822
7063
|
try {
|
|
6823
7064
|
const response = await (fetchImpl ?? fetch)(url, {
|
|
6824
7065
|
method: target.method,
|
|
6825
|
-
headers:
|
|
6826
|
-
"content-type": asText ? "text/plain; charset=utf-8" : "application/json",
|
|
6827
|
-
...headers
|
|
6828
|
-
},
|
|
7066
|
+
headers: sent,
|
|
6829
7067
|
body,
|
|
6830
7068
|
signal: AbortSignal.timeout(1e4)
|
|
6831
7069
|
});
|
|
@@ -6850,6 +7088,10 @@ var init_webhook = __esmMin((() => {
|
|
|
6850
7088
|
}));
|
|
6851
7089
|
//#endregion
|
|
6852
7090
|
//#region src/config/store.ts
|
|
7091
|
+
var store_exports = /* @__PURE__ */ __exportAll({
|
|
7092
|
+
ConfigError: () => ConfigError,
|
|
7093
|
+
WorkspaceStore: () => WorkspaceStore
|
|
7094
|
+
});
|
|
6853
7095
|
function readFile(file) {
|
|
6854
7096
|
let text;
|
|
6855
7097
|
try {
|
|
@@ -7660,7 +7902,7 @@ function createLogsRoute(deps) {
|
|
|
7660
7902
|
200: { description: "application/x-ndjson" },
|
|
7661
7903
|
404: ERROR_RESPONSES[404]
|
|
7662
7904
|
}
|
|
7663
|
-
}), validate("query", downloadQuery), validate("param", idParam$2), (c) => {
|
|
7905
|
+
}), validate("query", downloadQuery), validate("param", idParam$2), async (c) => {
|
|
7664
7906
|
const runtime = requireWorkspace(deps.panel.requireWorkspace.bind(deps.panel), c.req.valid("query").workspace);
|
|
7665
7907
|
const { id } = c.req.valid("param");
|
|
7666
7908
|
if (!runtime.store.getServer(id)) throw unknownServerError(id);
|
|
@@ -7670,10 +7912,21 @@ function createLogsRoute(deps) {
|
|
|
7670
7912
|
code: "UNKNOWN_LOG_FILE"
|
|
7671
7913
|
});
|
|
7672
7914
|
const file = path.join(runtime.logFiles.directory, requested);
|
|
7673
|
-
|
|
7674
|
-
|
|
7915
|
+
/**
|
|
7916
|
+
* Streamed, not read into memory. This is the same class the archive download answers, and the
|
|
7917
|
+
* logs are the *bigger* case in practice: `logs.maxBytes` bounds one rotation at up to 100 MB and
|
|
7918
|
+
* `keep` keeps 10 of them, and a person downloads exactly when a log is large.
|
|
7919
|
+
*
|
|
7920
|
+
* Measured on the built panel with a real 100 MB rotation: `readFileSync` cost **+199 MB RSS**
|
|
7921
|
+
* for one download and **+402 MB** for four arriving together, `/healthz` went from 4 ms to
|
|
7922
|
+
* p95 859 ms / max 898 ms, and the headers only arrived after the whole read (TTFB 272 ms). The
|
|
7923
|
+
* archive route with the same four downloads grew **+2 MB** and answered `/healthz` in p50 17 ms.
|
|
7924
|
+
* `stat` gives the same `Content-Length` a client needs for a progress bar without the buffer.
|
|
7925
|
+
*/
|
|
7926
|
+
const stats = await fs.promises.stat(file);
|
|
7927
|
+
return c.body(Readable.toWeb(createReadStream(file)), 200, {
|
|
7675
7928
|
"Content-Type": "application/x-ndjson; charset=utf-8",
|
|
7676
|
-
"Content-Length": String(
|
|
7929
|
+
"Content-Length": String(stats.size),
|
|
7677
7930
|
"Content-Disposition": `attachment; filename="${requested}"`
|
|
7678
7931
|
});
|
|
7679
7932
|
}).delete("/logs/:id", describeRoute({
|
|
@@ -8034,7 +8287,7 @@ function parseWindowsCsv(text) {
|
|
|
8034
8287
|
async function getClockTicks() {
|
|
8035
8288
|
if (clockTicks !== null) return clockTicks;
|
|
8036
8289
|
try {
|
|
8037
|
-
const { stdout } = await execFileAsync$
|
|
8290
|
+
const { stdout } = await execFileAsync$6("getconf", ["CLK_TCK"], { timeout: 2e3 });
|
|
8038
8291
|
const parsed = Number.parseInt(stdout.trim(), 10);
|
|
8039
8292
|
clockTicks = Number.isFinite(parsed) && parsed > 0 ? parsed : 100;
|
|
8040
8293
|
} catch {
|
|
@@ -8086,7 +8339,7 @@ async function readLinux() {
|
|
|
8086
8339
|
return rows;
|
|
8087
8340
|
}
|
|
8088
8341
|
async function readPosix() {
|
|
8089
|
-
const { stdout } = await execFileAsync$
|
|
8342
|
+
const { stdout } = await execFileAsync$6("ps", ["-Ao", "pid=,ppid=,rss=,%cpu="], {
|
|
8090
8343
|
timeout: 5e3,
|
|
8091
8344
|
maxBuffer: 16777216
|
|
8092
8345
|
});
|
|
@@ -8095,7 +8348,7 @@ async function readPosix() {
|
|
|
8095
8348
|
async function readWindows() {
|
|
8096
8349
|
const script = "Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,WorkingSetSize,KernelModeTime,UserModeTime | ConvertTo-Csv -NoTypeInformation";
|
|
8097
8350
|
try {
|
|
8098
|
-
const { stdout } = await execFileAsync$
|
|
8351
|
+
const { stdout } = await execFileAsync$6("powershell.exe", [
|
|
8099
8352
|
"-NoProfile",
|
|
8100
8353
|
"-NonInteractive",
|
|
8101
8354
|
"-Command",
|
|
@@ -8107,7 +8360,7 @@ async function readWindows() {
|
|
|
8107
8360
|
return parseWindowsCsv(stdout);
|
|
8108
8361
|
} catch {
|
|
8109
8362
|
try {
|
|
8110
|
-
const { stdout } = await execFileAsync$
|
|
8363
|
+
const { stdout } = await execFileAsync$6("wmic", [
|
|
8111
8364
|
"process",
|
|
8112
8365
|
"get",
|
|
8113
8366
|
"ProcessId,ParentProcessId,WorkingSetSize,KernelModeTime,UserModeTime",
|
|
@@ -8228,7 +8481,7 @@ async function processCarriesServerId(pid, serverId) {
|
|
|
8228
8481
|
return false;
|
|
8229
8482
|
}
|
|
8230
8483
|
if (process.platform === "darwin") try {
|
|
8231
|
-
const { stdout } = await execFileAsync$
|
|
8484
|
+
const { stdout } = await execFileAsync$6("ps", [
|
|
8232
8485
|
"-p",
|
|
8233
8486
|
String(pid),
|
|
8234
8487
|
"-E",
|
|
@@ -8242,9 +8495,9 @@ async function processCarriesServerId(pid, serverId) {
|
|
|
8242
8495
|
}
|
|
8243
8496
|
return false;
|
|
8244
8497
|
}
|
|
8245
|
-
var execFileAsync$
|
|
8498
|
+
var execFileAsync$6, clockTicks, ProcessSampler;
|
|
8246
8499
|
var init_proc = __esmMin((() => {
|
|
8247
|
-
execFileAsync$
|
|
8500
|
+
execFileAsync$6 = promisify(execFile);
|
|
8248
8501
|
clockTicks = null;
|
|
8249
8502
|
ProcessSampler = class {
|
|
8250
8503
|
/**
|
|
@@ -8469,7 +8722,7 @@ async function processArgv(pid) {
|
|
|
8469
8722
|
return null;
|
|
8470
8723
|
}
|
|
8471
8724
|
try {
|
|
8472
|
-
const { stdout } = await execFileAsync$
|
|
8725
|
+
const { stdout } = await execFileAsync$5("ps", [
|
|
8473
8726
|
"-p",
|
|
8474
8727
|
String(pid),
|
|
8475
8728
|
"-ww",
|
|
@@ -8540,7 +8793,7 @@ async function windowsProcessInfo(pid) {
|
|
|
8540
8793
|
if (!windowsFilter.test(String(pid))) return null;
|
|
8541
8794
|
try {
|
|
8542
8795
|
const script = `Get-CimInstance Win32_Process -Filter "ProcessId=${pid}" | Select-Object CommandLine,ExecutablePath | ConvertTo-Csv -NoTypeInformation`;
|
|
8543
|
-
const { stdout } = await execFileAsync$
|
|
8796
|
+
const { stdout } = await execFileAsync$5("powershell", [
|
|
8544
8797
|
"-NoProfile",
|
|
8545
8798
|
"-NonInteractive",
|
|
8546
8799
|
"-Command",
|
|
@@ -8591,10 +8844,10 @@ async function identifyHolders(serverId, spawn, pids) {
|
|
|
8591
8844
|
}
|
|
8592
8845
|
return found;
|
|
8593
8846
|
}
|
|
8594
|
-
var execFileAsync$
|
|
8847
|
+
var execFileAsync$5, windowsFilter;
|
|
8595
8848
|
var init_identity = __esmMin((() => {
|
|
8596
8849
|
init_proc();
|
|
8597
|
-
execFileAsync$
|
|
8850
|
+
execFileAsync$5 = promisify(execFile);
|
|
8598
8851
|
windowsFilter = /^\d+$/;
|
|
8599
8852
|
}));
|
|
8600
8853
|
//#endregion
|
|
@@ -8716,7 +8969,7 @@ async function processBirth(pid) {
|
|
|
8716
8969
|
}
|
|
8717
8970
|
if (process.platform === "win32") try {
|
|
8718
8971
|
const script = `$p = Get-CimInstance Win32_Process -Filter "ProcessId=${pid}"; if ($p) { $p.CreationDate.ToFileTimeUtc() }`;
|
|
8719
|
-
const { stdout } = await execFileAsync$
|
|
8972
|
+
const { stdout } = await execFileAsync$4("powershell", [
|
|
8720
8973
|
"-NoProfile",
|
|
8721
8974
|
"-NonInteractive",
|
|
8722
8975
|
"-Command",
|
|
@@ -8734,7 +8987,7 @@ async function processBirth(pid) {
|
|
|
8734
8987
|
return null;
|
|
8735
8988
|
}
|
|
8736
8989
|
try {
|
|
8737
|
-
const { stdout } = await execFileAsync$
|
|
8990
|
+
const { stdout } = await execFileAsync$4("ps", [
|
|
8738
8991
|
"-p",
|
|
8739
8992
|
String(pid),
|
|
8740
8993
|
"-o",
|
|
@@ -8816,19 +9069,20 @@ function parseNetstatListeners(output, port) {
|
|
|
8816
9069
|
}
|
|
8817
9070
|
async function findDockerPortHolder(port) {
|
|
8818
9071
|
try {
|
|
8819
|
-
const { stdout } = await execFileAsync$
|
|
9072
|
+
const { stdout } = await execFileAsync$4("docker", [
|
|
8820
9073
|
"ps",
|
|
8821
9074
|
"--filter",
|
|
8822
9075
|
`publish=${port}`,
|
|
8823
9076
|
"--format",
|
|
8824
|
-
"{{.Names}} {{.Label \"com.docker.compose.project.working_dir\"}}"
|
|
9077
|
+
"{{.Names}} {{.Label \"com.docker.compose.project\"}} {{.Label \"com.docker.compose.project.working_dir\"}}"
|
|
8825
9078
|
], { timeout: 3e3 });
|
|
8826
9079
|
const line = stdout.split("\n").find((entry) => entry.trim().length > 0);
|
|
8827
9080
|
if (line === void 0) return null;
|
|
8828
|
-
const [container = "", composeDir = ""] = line.split(" ");
|
|
9081
|
+
const [container = "", project = "", composeDir = ""] = line.split(" ");
|
|
8829
9082
|
if (container.trim().length === 0) return null;
|
|
8830
9083
|
return {
|
|
8831
9084
|
container: container.trim(),
|
|
9085
|
+
project: project.trim().length > 0 ? project.trim() : null,
|
|
8832
9086
|
composeDir: composeDir.trim().length > 0 ? composeDir.trim() : null,
|
|
8833
9087
|
port
|
|
8834
9088
|
};
|
|
@@ -8846,7 +9100,7 @@ async function findDockerPortHolder(port) {
|
|
|
8846
9100
|
*/
|
|
8847
9101
|
async function releaseDockerPort(holder, timeoutMs = 2e4) {
|
|
8848
9102
|
try {
|
|
8849
|
-
await execFileAsync$
|
|
9103
|
+
await execFileAsync$4("docker", ["stop", holder.container], { timeout: timeoutMs });
|
|
8850
9104
|
return true;
|
|
8851
9105
|
} catch {
|
|
8852
9106
|
return false;
|
|
@@ -8854,7 +9108,7 @@ async function releaseDockerPort(holder, timeoutMs = 2e4) {
|
|
|
8854
9108
|
}
|
|
8855
9109
|
async function listPortHolders(port) {
|
|
8856
9110
|
if (process.platform === "win32") try {
|
|
8857
|
-
const { stdout } = await execFileAsync$
|
|
9111
|
+
const { stdout } = await execFileAsync$4("netstat", [
|
|
8858
9112
|
"-ano",
|
|
8859
9113
|
"-p",
|
|
8860
9114
|
"tcp"
|
|
@@ -8864,7 +9118,7 @@ async function listPortHolders(port) {
|
|
|
8864
9118
|
return [];
|
|
8865
9119
|
}
|
|
8866
9120
|
try {
|
|
8867
|
-
const { stdout } = await execFileAsync$
|
|
9121
|
+
const { stdout } = await execFileAsync$4("lsof", [
|
|
8868
9122
|
"-ti",
|
|
8869
9123
|
`tcp:${port}`,
|
|
8870
9124
|
"-sTCP:LISTEN"
|
|
@@ -8872,7 +9126,7 @@ async function listPortHolders(port) {
|
|
|
8872
9126
|
return parsePids(stdout);
|
|
8873
9127
|
} catch {}
|
|
8874
9128
|
try {
|
|
8875
|
-
const { stdout } = await execFileAsync$
|
|
9129
|
+
const { stdout } = await execFileAsync$4("fuser", [`${port}/tcp`], { timeout: 3e3 });
|
|
8876
9130
|
return parsePids(stdout);
|
|
8877
9131
|
} catch {
|
|
8878
9132
|
return [];
|
|
@@ -8889,9 +9143,9 @@ async function listPortHolders(port) {
|
|
|
8889
9143
|
function parsePids(stdout) {
|
|
8890
9144
|
return [...new Set(stdout.split(/\s+/).map((entry) => Number.parseInt(entry, 10)).filter((pid) => Number.isInteger(pid) && pid > 0 && pid !== process.pid))];
|
|
8891
9145
|
}
|
|
8892
|
-
var execFileAsync$
|
|
9146
|
+
var execFileAsync$4, LINUX_HZ, FILETIME_UNIX_OFFSET_MS;
|
|
8893
9147
|
var init_port = __esmMin((() => {
|
|
8894
|
-
execFileAsync$
|
|
9148
|
+
execFileAsync$4 = promisify(execFile);
|
|
8895
9149
|
LINUX_HZ = 100;
|
|
8896
9150
|
FILETIME_UNIX_OFFSET_MS = 0xa9730b66800;
|
|
8897
9151
|
}));
|
|
@@ -8986,7 +9240,7 @@ async function terminate(child, options) {
|
|
|
8986
9240
|
*/
|
|
8987
9241
|
async function killTreeWindows(pid) {
|
|
8988
9242
|
try {
|
|
8989
|
-
await execFileAsync$
|
|
9243
|
+
await execFileAsync$3("taskkill", [
|
|
8990
9244
|
"/pid",
|
|
8991
9245
|
String(pid),
|
|
8992
9246
|
"/T",
|
|
@@ -9053,11 +9307,11 @@ function waitForExit$1(child, timeoutMs) {
|
|
|
9053
9307
|
child.once("exit", onExit);
|
|
9054
9308
|
});
|
|
9055
9309
|
}
|
|
9056
|
-
var execFileAsync$
|
|
9310
|
+
var execFileAsync$3, WINDOWS_SHIM_EXTENSIONS;
|
|
9057
9311
|
var init_process = __esmMin((() => {
|
|
9058
9312
|
init_paths();
|
|
9059
9313
|
init_port();
|
|
9060
|
-
execFileAsync$
|
|
9314
|
+
execFileAsync$3 = promisify(execFile);
|
|
9061
9315
|
WINDOWS_SHIM_EXTENSIONS = [
|
|
9062
9316
|
".exe",
|
|
9063
9317
|
".cmd",
|
|
@@ -9357,6 +9611,30 @@ var init_proxy$2 = __esmMin((() => {
|
|
|
9357
9611
|
BY_ID = new Map(PROXY_ENGINES.map((engine) => [engine.info.id, engine]));
|
|
9358
9612
|
}));
|
|
9359
9613
|
//#endregion
|
|
9614
|
+
//#region src/shared/proxy-form.ts
|
|
9615
|
+
/** A name an ACME CA could issue for; anything else gets the engine's own CA. */
|
|
9616
|
+
function isPublicHost(host) {
|
|
9617
|
+
const name = host.trim().toLowerCase();
|
|
9618
|
+
if (name.length === 0 || name === "localhost" || !name.includes(".")) return false;
|
|
9619
|
+
if (LOCAL_TLDS.some((tld) => name.endsWith(tld))) return false;
|
|
9620
|
+
return !/^\d{1,3}(?:\.\d{1,3}){3,}$/.test(name);
|
|
9621
|
+
}
|
|
9622
|
+
var LOCAL_TLDS;
|
|
9623
|
+
var init_proxy_form = __esmMin((() => {
|
|
9624
|
+
init_contracts();
|
|
9625
|
+
LOCAL_TLDS = [
|
|
9626
|
+
".localhost",
|
|
9627
|
+
".local",
|
|
9628
|
+
".internal",
|
|
9629
|
+
".home.arpa",
|
|
9630
|
+
".lan",
|
|
9631
|
+
".home",
|
|
9632
|
+
".test",
|
|
9633
|
+
".invalid",
|
|
9634
|
+
".example"
|
|
9635
|
+
];
|
|
9636
|
+
}));
|
|
9637
|
+
//#endregion
|
|
9360
9638
|
//#region src/services/proxy-config.ts
|
|
9361
9639
|
/**
|
|
9362
9640
|
* The DNS-01 challenge block, which names the panel as the one that answers it. The
|
|
@@ -9610,8 +9888,9 @@ function renderCaddyConfig(input) {
|
|
|
9610
9888
|
issuers: acmeIssuers(input.acme)
|
|
9611
9889
|
});
|
|
9612
9890
|
}
|
|
9891
|
+
const localNames = [...new Set(managed.filter((route) => route.tls === "auto" && !isPublicHost(route.host)).map((route) => route.host))];
|
|
9613
9892
|
if (managed.length > 0) policies.push({
|
|
9614
|
-
subjects: [FALLBACK_NAME],
|
|
9893
|
+
subjects: [FALLBACK_NAME, ...localNames],
|
|
9615
9894
|
issuers: [{ module: "internal" }]
|
|
9616
9895
|
});
|
|
9617
9896
|
if (policies.length > 0) tlsApp.automation = { policies };
|
|
@@ -9634,6 +9913,7 @@ function renderCaddyConfig(input) {
|
|
|
9634
9913
|
}
|
|
9635
9914
|
var ACME_STAGING, FALLBACK_NAME;
|
|
9636
9915
|
var init_proxy_config = __esmMin((() => {
|
|
9916
|
+
init_proxy_form();
|
|
9637
9917
|
ACME_STAGING = "https://acme-staging-v02.api.letsencrypt.org/directory";
|
|
9638
9918
|
FALLBACK_NAME = "hh-fallback.invalid";
|
|
9639
9919
|
}));
|
|
@@ -9824,30 +10104,6 @@ var init_tls$1 = __esmMin((() => {
|
|
|
9824
10104
|
};
|
|
9825
10105
|
}));
|
|
9826
10106
|
//#endregion
|
|
9827
|
-
//#region src/shared/proxy-form.ts
|
|
9828
|
-
/** A name an ACME CA could issue for; anything else gets the engine's own CA. */
|
|
9829
|
-
function isPublicHost(host) {
|
|
9830
|
-
const name = host.trim().toLowerCase();
|
|
9831
|
-
if (name.length === 0 || name === "localhost" || !name.includes(".")) return false;
|
|
9832
|
-
if (LOCAL_TLDS.some((tld) => name.endsWith(tld))) return false;
|
|
9833
|
-
return !/^\d{1,3}(?:\.\d{1,3}){3,}$/.test(name);
|
|
9834
|
-
}
|
|
9835
|
-
var LOCAL_TLDS;
|
|
9836
|
-
var init_proxy_form = __esmMin((() => {
|
|
9837
|
-
init_contracts();
|
|
9838
|
-
LOCAL_TLDS = [
|
|
9839
|
-
".localhost",
|
|
9840
|
-
".local",
|
|
9841
|
-
".internal",
|
|
9842
|
-
".home.arpa",
|
|
9843
|
-
".lan",
|
|
9844
|
-
".home",
|
|
9845
|
-
".test",
|
|
9846
|
-
".invalid",
|
|
9847
|
-
".example"
|
|
9848
|
-
];
|
|
9849
|
-
}));
|
|
9850
|
-
//#endregion
|
|
9851
10107
|
//#region src/services/proxy.ts
|
|
9852
10108
|
/** The DNS names a certificate covers, from its SANs (and its subject as a fallback). */
|
|
9853
10109
|
function namesOf(x509) {
|
|
@@ -10350,10 +10606,20 @@ var init_proxy$1 = __esmMin((() => {
|
|
|
10350
10606
|
message: covering === void 0 ? `no uploaded certificate covers ${route.host}` : `${covering.error ?? "the uploaded certificate cannot be used"} — upload a valid pair for ${route.host}`
|
|
10351
10607
|
};
|
|
10352
10608
|
}
|
|
10353
|
-
if (!isPublicHost(route.host))
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10609
|
+
if (!isPublicHost(route.host)) {
|
|
10610
|
+
if (this.localCertificates().has(route.host.toLowerCase())) return {
|
|
10611
|
+
state: "local",
|
|
10612
|
+
message: "signed by the engine's own CA"
|
|
10613
|
+
};
|
|
10614
|
+
const refusal = this.obtainFailures().get(route.host.toLowerCase());
|
|
10615
|
+
return refusal === void 0 ? {
|
|
10616
|
+
state: "pending",
|
|
10617
|
+
message: "the engine is issuing its own certificate"
|
|
10618
|
+
} : {
|
|
10619
|
+
state: "failed",
|
|
10620
|
+
message: refusal
|
|
10621
|
+
};
|
|
10622
|
+
}
|
|
10357
10623
|
const issued = this.issuedCertificates().get(route.host.toLowerCase());
|
|
10358
10624
|
if (issued !== void 0) return {
|
|
10359
10625
|
state: "issued",
|
|
@@ -11938,14 +12204,14 @@ function createServersRoute(deps) {
|
|
|
11938
12204
|
return c.json({ servers: runtime.supervisor.views() });
|
|
11939
12205
|
}).post("/stop-all", describeRoute({
|
|
11940
12206
|
tags: ["servers"],
|
|
11941
|
-
summary: "Stop every server in a workspace",
|
|
12207
|
+
summary: "Stop every server in a workspace, persistent entries included if asked",
|
|
11942
12208
|
responses: { 200: {
|
|
11943
12209
|
description: "The servers",
|
|
11944
12210
|
content: jsonBody(serversResponse)
|
|
11945
12211
|
} }
|
|
11946
12212
|
}), validate("query", workspaceQuerySchema), async (c) => {
|
|
11947
12213
|
const runtime = requireWorkspace(deps.panel.requireWorkspace.bind(deps.panel), c.req.valid("query").workspace);
|
|
11948
|
-
await runtime.supervisor.stopAll();
|
|
12214
|
+
await runtime.supervisor.stopAll({ withPersistent: c.req.query("withPersistent") === "true" });
|
|
11949
12215
|
return c.json({ servers: runtime.supervisor.views() });
|
|
11950
12216
|
}).get("/:id", describeRoute({
|
|
11951
12217
|
tags: ["servers"],
|
|
@@ -12410,7 +12676,10 @@ function createSettingsRoute(deps) {
|
|
|
12410
12676
|
const patch = c.req.valid("json");
|
|
12411
12677
|
try {
|
|
12412
12678
|
if (patch.defaults !== void 0) runtime.store.updateDefaults(patch.defaults);
|
|
12413
|
-
if (patch.logs !== void 0)
|
|
12679
|
+
if (patch.logs !== void 0) {
|
|
12680
|
+
runtime.store.updateLogs(patch.logs);
|
|
12681
|
+
runtime.logFiles.prune();
|
|
12682
|
+
}
|
|
12414
12683
|
if (patch.notifications !== void 0) {
|
|
12415
12684
|
const saved = runtime.store.updateNotifications(patch.notifications);
|
|
12416
12685
|
runtime.secrets.forgetTelegramTokens(saved.destinations.map((destination) => destination.id));
|
|
@@ -12713,6 +12982,391 @@ var init_$_routes = __esmMin((() => {
|
|
|
12713
12982
|
});
|
|
12714
12983
|
}));
|
|
12715
12984
|
//#endregion
|
|
12985
|
+
//#region src/providers/wsl-temperature.ts
|
|
12986
|
+
var wsl_temperature_exports = /* @__PURE__ */ __exportAll({
|
|
12987
|
+
LHM_RELEASE: () => LHM_RELEASE,
|
|
12988
|
+
LHM_SUBDIR: () => LHM_SUBDIR,
|
|
12989
|
+
installLibreHardwareMonitor: () => installLibreHardwareMonitor,
|
|
12990
|
+
isWsl: () => isWsl,
|
|
12991
|
+
lhmDirectory: () => lhmDirectory,
|
|
12992
|
+
lhmDirectoryWindows: () => lhmDirectoryWindows,
|
|
12993
|
+
lhmInstalled: () => lhmInstalled,
|
|
12994
|
+
probeWslTemperature: () => probeWslTemperature,
|
|
12995
|
+
tempCommandFor: () => tempCommandFor,
|
|
12996
|
+
tempCommandForWindows: () => tempCommandForWindows,
|
|
12997
|
+
toGuestPath: () => toGuestPath,
|
|
12998
|
+
windowsScriptPath: () => windowsScriptPath,
|
|
12999
|
+
writeWslTemperatureScript: () => writeWslTemperatureScript,
|
|
13000
|
+
wslScriptPath: () => wslScriptPath,
|
|
13001
|
+
wslScriptPathWindows: () => wslScriptPathWindows,
|
|
13002
|
+
wslTemperatureStatus: () => wslTemperatureStatus
|
|
13003
|
+
});
|
|
13004
|
+
/** The install directory in Windows terms, read from the environment (the system drive may not be `C:`). */
|
|
13005
|
+
function lhmDirectoryWindows() {
|
|
13006
|
+
try {
|
|
13007
|
+
const base = execFileSync("powershell.exe", [
|
|
13008
|
+
"-NoProfile",
|
|
13009
|
+
"-NonInteractive",
|
|
13010
|
+
"-Command",
|
|
13011
|
+
"$env:ProgramData"
|
|
13012
|
+
], {
|
|
13013
|
+
timeout: 1e4,
|
|
13014
|
+
windowsHide: true,
|
|
13015
|
+
encoding: "utf8"
|
|
13016
|
+
}).trim();
|
|
13017
|
+
return base.length === 0 ? null : path.win32.join(base, LHM_SUBDIR);
|
|
13018
|
+
} catch {
|
|
13019
|
+
return null;
|
|
13020
|
+
}
|
|
13021
|
+
}
|
|
13022
|
+
/** A Windows path as a path this process can read: `C:\x` -> `/mnt/c/x`. */
|
|
13023
|
+
function toGuestPath(windowsPath) {
|
|
13024
|
+
const match = /^([a-z]):\\(.*)$/i.exec(windowsPath);
|
|
13025
|
+
if (match === null) return null;
|
|
13026
|
+
return path.posix.join("/mnt", match[1].toLowerCase(), ...match[2].split("\\"));
|
|
13027
|
+
}
|
|
13028
|
+
/** The install directory as a guest path, or null when the Windows side cannot be reached. */
|
|
13029
|
+
function lhmDirectory() {
|
|
13030
|
+
const windows = lhmDirectoryWindows();
|
|
13031
|
+
return windows === null ? null : toGuestPath(windows);
|
|
13032
|
+
}
|
|
13033
|
+
/**
|
|
13034
|
+
* Whether this process is a WSL2 guest.
|
|
13035
|
+
*
|
|
13036
|
+
* `os.release()` carries `microsoft-standard-WSL2`, and `/proc/version` the same — checked on both
|
|
13037
|
+
* because a future WSL may rename the release while the version line keeps the vendor.
|
|
13038
|
+
*/
|
|
13039
|
+
function isWsl() {
|
|
13040
|
+
if (process.platform !== "linux") return false;
|
|
13041
|
+
try {
|
|
13042
|
+
return /microsoft/i.test(fs.readFileSync("/proc/version", "utf8"));
|
|
13043
|
+
} catch {
|
|
13044
|
+
return false;
|
|
13045
|
+
}
|
|
13046
|
+
}
|
|
13047
|
+
/** A `/mnt/c/...` path as the `C:\...` path `powershell.exe` needs. Untranslatable paths pass through. */
|
|
13048
|
+
function windowsScriptPath(scriptPath) {
|
|
13049
|
+
const match = /^\/mnt\/([a-z])\/(.*)$/i.exec(scriptPath);
|
|
13050
|
+
if (match === null) return scriptPath;
|
|
13051
|
+
return `${match[1].toUpperCase()}:\\${match[2].replaceAll("/", "\\")}`;
|
|
13052
|
+
}
|
|
13053
|
+
/** The helper script, written beside the library so every account resolves the same file. */
|
|
13054
|
+
function wslScriptPath() {
|
|
13055
|
+
if (!isWsl()) return null;
|
|
13056
|
+
const base = lhmDirectoryWindows();
|
|
13057
|
+
const guest = base === null ? null : toGuestPath(path.win32.dirname(base));
|
|
13058
|
+
if (guest === null) return null;
|
|
13059
|
+
return path.join(guest, SCRIPT_NAME);
|
|
13060
|
+
}
|
|
13061
|
+
/** Where the helper is, in Windows terms — what the command line has to say. */
|
|
13062
|
+
function wslScriptPathWindows() {
|
|
13063
|
+
const base = lhmDirectoryWindows();
|
|
13064
|
+
return base === null ? null : path.win32.join(path.win32.dirname(base), SCRIPT_NAME);
|
|
13065
|
+
}
|
|
13066
|
+
/** The `powershell.exe` invocation that runs `scriptPath` and prints the temperature. */
|
|
13067
|
+
function tempCommandFor(scriptPath) {
|
|
13068
|
+
return `powershell.exe -NoProfile -ExecutionPolicy Bypass -File "${windowsScriptPath(scriptPath)}"`;
|
|
13069
|
+
}
|
|
13070
|
+
/** The command for a path already expressed in Windows terms. */
|
|
13071
|
+
function tempCommandForWindows(windowsPath) {
|
|
13072
|
+
return `powershell.exe -NoProfile -ExecutionPolicy Bypass -File "${windowsPath}"`;
|
|
13073
|
+
}
|
|
13074
|
+
/** The script's body. Kept tiny: it runs on every host sample. */
|
|
13075
|
+
function scriptBody() {
|
|
13076
|
+
return `# CPU temperature for home-hosted. Written by \`home-hosted setup-temp --wsl\`; safe to delete.
|
|
13077
|
+
$dir = Join-Path $env:ProgramData 'home-hosted\\LibreHardwareMonitor'
|
|
13078
|
+
if (-not (Test-Path (Join-Path $dir 'LibreHardwareMonitorLib.dll'))) {
|
|
13079
|
+
[Console]::Error.WriteLine("LibreHardwareMonitor not found in $dir")
|
|
13080
|
+
exit 1
|
|
13081
|
+
}
|
|
13082
|
+
[System.Reflection.Assembly]::LoadFrom("$dir\\System.Memory.dll") | Out-Null
|
|
13083
|
+
[System.Reflection.Assembly]::LoadFrom("$dir\\System.Buffers.dll") | Out-Null
|
|
13084
|
+
[System.Reflection.Assembly]::LoadFrom("$dir\\Microsoft.Bcl.AsyncInterfaces.dll") | Out-Null
|
|
13085
|
+
Add-Type -Path "$dir\\LibreHardwareMonitorLib.dll"
|
|
13086
|
+
$c = New-Object LibreHardwareMonitor.Hardware.Computer
|
|
13087
|
+
$c.IsCpuEnabled = $true
|
|
13088
|
+
$c.Open()
|
|
13089
|
+
$out = $null
|
|
13090
|
+
foreach ($hw in $c.Hardware) {
|
|
13091
|
+
$hw.Update()
|
|
13092
|
+
foreach ($s in $hw.Sensors) {
|
|
13093
|
+
if ($s.SensorType -eq 'Temperature' -and $s.Name -match 'Tctl|Package|Core') {
|
|
13094
|
+
$out = [math]::Round($s.Value, 1)
|
|
13095
|
+
break
|
|
13096
|
+
}
|
|
13097
|
+
}
|
|
13098
|
+
if ($null -ne $out) { break }
|
|
13099
|
+
}
|
|
13100
|
+
$c.Close()
|
|
13101
|
+
if ($null -eq $out) { exit 2 }
|
|
13102
|
+
$out
|
|
13103
|
+
`;
|
|
13104
|
+
}
|
|
13105
|
+
/** `configured` (pointed at a command) and `libraryPresent` are separate, so the UI can say "set up, but the library is missing". */
|
|
13106
|
+
function wslTemperatureStatus(scriptPath, tempCommand) {
|
|
13107
|
+
const wsl = isWsl();
|
|
13108
|
+
const scriptWritten = scriptPath !== null && fs.existsSync(scriptPath);
|
|
13109
|
+
const configured = tempCommand.trim().length > 0;
|
|
13110
|
+
let libraryPresent = false;
|
|
13111
|
+
try {
|
|
13112
|
+
libraryPresent = fs.existsSync(path.join("/mnt", "c", "Tools", "LibreHardwareMonitor", "LibreHardwareMonitorLib.dll"));
|
|
13113
|
+
} catch {
|
|
13114
|
+
libraryPresent = false;
|
|
13115
|
+
}
|
|
13116
|
+
return {
|
|
13117
|
+
wsl,
|
|
13118
|
+
supported: wsl,
|
|
13119
|
+
configured,
|
|
13120
|
+
scriptWritten,
|
|
13121
|
+
libraryPresent,
|
|
13122
|
+
scriptPath: wsl ? scriptPath : null,
|
|
13123
|
+
tempCommand: configured ? tempCommand : null
|
|
13124
|
+
};
|
|
13125
|
+
}
|
|
13126
|
+
/** Write the helper script. Idempotent: re-running overwrites it with the current version. */
|
|
13127
|
+
function writeWslTemperatureScript(scriptPath) {
|
|
13128
|
+
fs.mkdirSync(path.dirname(scriptPath), { recursive: true });
|
|
13129
|
+
fs.writeFileSync(scriptPath, scriptBody(), { mode: 384 });
|
|
13130
|
+
}
|
|
13131
|
+
/** Whether the DLL the helper loads is installed where the helper expects it. */
|
|
13132
|
+
function lhmInstalled() {
|
|
13133
|
+
const dir = lhmDirectory();
|
|
13134
|
+
if (dir === null) return false;
|
|
13135
|
+
try {
|
|
13136
|
+
return fs.existsSync(path.join(dir, "LibreHardwareMonitorLib.dll"));
|
|
13137
|
+
} catch {
|
|
13138
|
+
return false;
|
|
13139
|
+
}
|
|
13140
|
+
}
|
|
13141
|
+
/** Download, verify and unpack LibreHardwareMonitor. A failed attempt leaves nothing installed. */
|
|
13142
|
+
async function installLibreHardwareMonitor(options = {}) {
|
|
13143
|
+
const report = options.onProgress ?? (() => {});
|
|
13144
|
+
const targetWindows = lhmDirectoryWindows();
|
|
13145
|
+
const target = lhmDirectory();
|
|
13146
|
+
if (targetWindows === null || target === null) return {
|
|
13147
|
+
dir: null,
|
|
13148
|
+
error: "the Windows ProgramData directory could not be read, so there is nowhere to install to"
|
|
13149
|
+
};
|
|
13150
|
+
let staging = null;
|
|
13151
|
+
try {
|
|
13152
|
+
report(`downloading ${LHM_RELEASE.asset} (${LHM_RELEASE.version})…`);
|
|
13153
|
+
const response = await fetch(LHM_RELEASE.url, {
|
|
13154
|
+
redirect: "follow",
|
|
13155
|
+
signal: AbortSignal.timeout(12e4)
|
|
13156
|
+
});
|
|
13157
|
+
if (!response.ok) return {
|
|
13158
|
+
dir: null,
|
|
13159
|
+
error: `the download answered ${response.status} for ${LHM_RELEASE.url}`
|
|
13160
|
+
};
|
|
13161
|
+
const bytes = Buffer$1.from(await response.arrayBuffer());
|
|
13162
|
+
const digest = createHash("sha256").update(bytes).digest("hex");
|
|
13163
|
+
if (digest !== LHM_RELEASE.sha256) return {
|
|
13164
|
+
dir: null,
|
|
13165
|
+
error: `the download did not match its published sha256 (got ${digest.slice(0, 16)}…, expected ${LHM_RELEASE.sha256.slice(0, 16)}…) — nothing was installed`
|
|
13166
|
+
};
|
|
13167
|
+
const stagingRoot = path.join(path.dirname(target), ".staging");
|
|
13168
|
+
await fs.promises.mkdir(stagingRoot, { recursive: true });
|
|
13169
|
+
staging = await fs.promises.mkdtemp(path.join(stagingRoot, "run-"));
|
|
13170
|
+
const archive = path.join(staging, LHM_RELEASE.asset);
|
|
13171
|
+
await fs.promises.writeFile(archive, bytes);
|
|
13172
|
+
report(`unpacking into ${targetWindows}…`);
|
|
13173
|
+
await fs.promises.rm(target, {
|
|
13174
|
+
recursive: true,
|
|
13175
|
+
force: true
|
|
13176
|
+
});
|
|
13177
|
+
await fs.promises.mkdir(target, { recursive: true });
|
|
13178
|
+
await execFileAsync$2("powershell.exe", [
|
|
13179
|
+
"-NoProfile",
|
|
13180
|
+
"-NonInteractive",
|
|
13181
|
+
"-Command",
|
|
13182
|
+
`Expand-Archive -LiteralPath '${windowsScriptPath(archive)}' -DestinationPath '${targetWindows}' -Force`
|
|
13183
|
+
], {
|
|
13184
|
+
timeout: 12e4,
|
|
13185
|
+
windowsHide: true
|
|
13186
|
+
});
|
|
13187
|
+
if (!lhmInstalled()) {
|
|
13188
|
+
await fs.promises.rm(target, {
|
|
13189
|
+
recursive: true,
|
|
13190
|
+
force: true
|
|
13191
|
+
}).catch(() => {});
|
|
13192
|
+
return {
|
|
13193
|
+
dir: null,
|
|
13194
|
+
error: `the archive unpacked but LibreHardwareMonitorLib.dll is not in ${targetWindows}`
|
|
13195
|
+
};
|
|
13196
|
+
}
|
|
13197
|
+
return {
|
|
13198
|
+
dir: targetWindows,
|
|
13199
|
+
error: null
|
|
13200
|
+
};
|
|
13201
|
+
} catch (error) {
|
|
13202
|
+
return {
|
|
13203
|
+
dir: null,
|
|
13204
|
+
error: error instanceof Error ? error.message : String(error)
|
|
13205
|
+
};
|
|
13206
|
+
} finally {
|
|
13207
|
+
if (staging !== null) {
|
|
13208
|
+
await fs.promises.rm(staging, {
|
|
13209
|
+
recursive: true,
|
|
13210
|
+
force: true
|
|
13211
|
+
}).catch(() => {});
|
|
13212
|
+
await fs.promises.rmdir(path.dirname(staging)).catch(() => {});
|
|
13213
|
+
}
|
|
13214
|
+
}
|
|
13215
|
+
}
|
|
13216
|
+
/** Run the helper once, so a setup that cannot work is reported rather than saved. */
|
|
13217
|
+
async function probeWslTemperature(tempCommand, timeoutMs) {
|
|
13218
|
+
try {
|
|
13219
|
+
const { stdout, stderr } = await execFileAsync$2(tempCommand, {
|
|
13220
|
+
timeout: timeoutMs,
|
|
13221
|
+
windowsHide: true,
|
|
13222
|
+
maxBuffer: 65536,
|
|
13223
|
+
shell: true
|
|
13224
|
+
});
|
|
13225
|
+
const match = /-?\d+(?:\.\d+)?/.exec(stdout);
|
|
13226
|
+
if (match === null) return {
|
|
13227
|
+
celsius: null,
|
|
13228
|
+
error: stderr.trim().length > 0 ? stderr.trim() : "the script printed no number — is LibreHardwareMonitor installed at C:\\Tools\\LibreHardwareMonitor?"
|
|
13229
|
+
};
|
|
13230
|
+
const celsius = Number.parseFloat(match[0]);
|
|
13231
|
+
if (!Number.isFinite(celsius) || celsius <= 0 || celsius >= 150) return {
|
|
13232
|
+
celsius: null,
|
|
13233
|
+
error: `the script printed ${match[0]}, which is not a temperature`
|
|
13234
|
+
};
|
|
13235
|
+
return {
|
|
13236
|
+
celsius,
|
|
13237
|
+
error: null
|
|
13238
|
+
};
|
|
13239
|
+
} catch (error) {
|
|
13240
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
13241
|
+
logger.warn(`the WSL temperature probe failed: ${message}`);
|
|
13242
|
+
return {
|
|
13243
|
+
celsius: null,
|
|
13244
|
+
error: message
|
|
13245
|
+
};
|
|
13246
|
+
}
|
|
13247
|
+
}
|
|
13248
|
+
var execFileAsync$2, SCRIPT_NAME, LHM_SUBDIR, LHM_RELEASE;
|
|
13249
|
+
var init_wsl_temperature$1 = __esmMin((() => {
|
|
13250
|
+
init_logger();
|
|
13251
|
+
execFileAsync$2 = promisify(execFile);
|
|
13252
|
+
SCRIPT_NAME = "cpu-temp.ps1";
|
|
13253
|
+
LHM_SUBDIR = "home-hosted\\LibreHardwareMonitor";
|
|
13254
|
+
LHM_RELEASE = {
|
|
13255
|
+
version: "0.9.6",
|
|
13256
|
+
asset: "LibreHardwareMonitor.zip",
|
|
13257
|
+
/** From the release's asset `digest` field, `sha256:…`. */
|
|
13258
|
+
sha256: "086d9f1b5a99e643edc2cfaaac16051685b551e4c5ac0b32a57c58c0e529c001",
|
|
13259
|
+
url: "https://github.com/LibreHardwareMonitor/LibreHardwareMonitor/releases/download/v0.9.6/LibreHardwareMonitor.zip"
|
|
13260
|
+
};
|
|
13261
|
+
}));
|
|
13262
|
+
//#endregion
|
|
13263
|
+
//#region src/api/wsl-temperature.ts
|
|
13264
|
+
/**
|
|
13265
|
+
* The helper's location, or null when the Windows drive is not mounted.
|
|
13266
|
+
*
|
|
13267
|
+
* It lives on the *Windows* side: `powershell.exe` cannot read the guest's Linux home, so a script
|
|
13268
|
+
* written there is invisible to it.
|
|
13269
|
+
*/
|
|
13270
|
+
function scriptPath() {
|
|
13271
|
+
return wslScriptPath();
|
|
13272
|
+
}
|
|
13273
|
+
function status(deps) {
|
|
13274
|
+
return wslTemperatureStatus(scriptPath(), deps.panel.settings.host.tempCommand);
|
|
13275
|
+
}
|
|
13276
|
+
/**
|
|
13277
|
+
* The WSL2 temperature bridge, over the panel's own settings.
|
|
13278
|
+
*
|
|
13279
|
+
* Panel-wide (a temperature is the machine's, not a workspace's), and deliberately three small
|
|
13280
|
+
* routes rather than one: read the state, install it, test it. Installing writes a file and changes
|
|
13281
|
+
* a setting, so it is the one that can fail and has to say why.
|
|
13282
|
+
*/
|
|
13283
|
+
function createWslTemperatureRoute(deps) {
|
|
13284
|
+
return appFactory.createApp().get("/host/temperature", describeRoute({
|
|
13285
|
+
tags: ["panel"],
|
|
13286
|
+
summary: "Whether the WSL temperature bridge is set up, and what it last read",
|
|
13287
|
+
responses: { 200: {
|
|
13288
|
+
description: "The bridge state",
|
|
13289
|
+
content: jsonBody(wslTemperatureSchema)
|
|
13290
|
+
} }
|
|
13291
|
+
}), async (c) => {
|
|
13292
|
+
const current = status(deps);
|
|
13293
|
+
if (!current.configured) return c.json(current);
|
|
13294
|
+
const probe = await probeWslTemperature(deps.panel.settings.host.tempCommand, deps.panel.settings.host.tempCommandTimeoutMs);
|
|
13295
|
+
return c.json({
|
|
13296
|
+
...current,
|
|
13297
|
+
lastReadingCelsius: probe.celsius,
|
|
13298
|
+
lastError: probe.error
|
|
13299
|
+
});
|
|
13300
|
+
}).post("/host/temperature", describeRoute({
|
|
13301
|
+
tags: ["panel"],
|
|
13302
|
+
summary: "Write the WSL helper script and point the temperature command at it",
|
|
13303
|
+
responses: {
|
|
13304
|
+
200: {
|
|
13305
|
+
description: "Set up",
|
|
13306
|
+
content: jsonBody(wslTemperatureSchema)
|
|
13307
|
+
},
|
|
13308
|
+
400: ERROR_RESPONSES[400]
|
|
13309
|
+
}
|
|
13310
|
+
}), async (c) => {
|
|
13311
|
+
if (!status(deps).supported) throw new DetailedError("this is not a WSL2 guest, so there is no host sensor to bridge to", {
|
|
13312
|
+
statusCode: 400,
|
|
13313
|
+
code: "NOT_WSL"
|
|
13314
|
+
});
|
|
13315
|
+
const target = scriptPath();
|
|
13316
|
+
if (target === null) throw new DetailedError("the Windows drive is not mounted at /mnt/c, so the helper cannot be written where powershell.exe can read it", {
|
|
13317
|
+
statusCode: 400,
|
|
13318
|
+
code: "WINDOWS_DRIVE_MISSING"
|
|
13319
|
+
});
|
|
13320
|
+
try {
|
|
13321
|
+
writeWslTemperatureScript(target);
|
|
13322
|
+
} catch (error) {
|
|
13323
|
+
throw new DetailedError(`the helper could not be written to ${target}: ${error instanceof Error ? error.message : String(error)}`, {
|
|
13324
|
+
statusCode: 400,
|
|
13325
|
+
code: "SCRIPT_WRITE_FAILED"
|
|
13326
|
+
});
|
|
13327
|
+
}
|
|
13328
|
+
const command = tempCommandFor(target);
|
|
13329
|
+
const probe = await probeWslTemperature(command, 5e3);
|
|
13330
|
+
if (probe.celsius === null) return c.json({
|
|
13331
|
+
...status(deps),
|
|
13332
|
+
lastReadingCelsius: null,
|
|
13333
|
+
lastError: probe.error ?? "the helper did not answer"
|
|
13334
|
+
});
|
|
13335
|
+
deps.panel.settings.updateHost({
|
|
13336
|
+
tempCommand: command,
|
|
13337
|
+
tempCommandTimeoutMs: 5e3
|
|
13338
|
+
});
|
|
13339
|
+
return c.json({
|
|
13340
|
+
...status(deps),
|
|
13341
|
+
lastReadingCelsius: probe.celsius,
|
|
13342
|
+
lastError: null
|
|
13343
|
+
});
|
|
13344
|
+
}).delete("/host/temperature", describeRoute({
|
|
13345
|
+
tags: ["panel"],
|
|
13346
|
+
summary: "Stop using the helper and delete it",
|
|
13347
|
+
responses: {
|
|
13348
|
+
200: {
|
|
13349
|
+
description: "Cleared",
|
|
13350
|
+
content: jsonBody(wslTemperatureSchema)
|
|
13351
|
+
},
|
|
13352
|
+
400: ERROR_RESPONSES[400]
|
|
13353
|
+
}
|
|
13354
|
+
}), async (c) => {
|
|
13355
|
+
const target = scriptPath();
|
|
13356
|
+
deps.panel.settings.updateHost({ tempCommand: "" });
|
|
13357
|
+
try {
|
|
13358
|
+
if (target !== null) fs.rmSync(target, { force: true });
|
|
13359
|
+
} catch {}
|
|
13360
|
+
return c.json(status(deps));
|
|
13361
|
+
});
|
|
13362
|
+
}
|
|
13363
|
+
var init_wsl_temperature = __esmMin((() => {
|
|
13364
|
+
init_factory();
|
|
13365
|
+
init_openapi$1();
|
|
13366
|
+
init_wsl_temperature$1();
|
|
13367
|
+
init_contracts();
|
|
13368
|
+
}));
|
|
13369
|
+
//#endregion
|
|
12716
13370
|
//#region src/helpers/error.ts
|
|
12717
13371
|
function toErrorBody(error) {
|
|
12718
13372
|
if (error instanceof HTTPException) return {
|
|
@@ -12753,17 +13407,144 @@ var init_error = __esmMin((() => {
|
|
|
12753
13407
|
};
|
|
12754
13408
|
}));
|
|
12755
13409
|
//#endregion
|
|
12756
|
-
//#region src/openapi.ts
|
|
13410
|
+
//#region src/openapi-reference.ts
|
|
12757
13411
|
/**
|
|
12758
|
-
*
|
|
12759
|
-
*
|
|
12760
|
-
* `/openapi/ui` is a browsable reference (Scalar) and needs no session, since a
|
|
12761
|
-
* UI author has to be able to read it before they can log in.
|
|
13412
|
+
* Deliberately a string, not a `.vue` or a template dependency: this route is outside `/api` and outside
|
|
13413
|
+
* both UIs, and `src/**` may not know a UI's files.
|
|
12762
13414
|
*/
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12766
|
-
|
|
13415
|
+
function openApiReferencePage(specUrl) {
|
|
13416
|
+
return `<!doctype html>
|
|
13417
|
+
<html lang="en">
|
|
13418
|
+
<head>
|
|
13419
|
+
<meta charset="utf-8" />
|
|
13420
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
13421
|
+
<title>home-hosted — API reference</title>
|
|
13422
|
+
<style>
|
|
13423
|
+
:root { color-scheme: light dark; --line: #d8dee9; --ink: #14202e; --muted: #5b6b80; --page: #fbfcfe; --code: #eef2f8; }
|
|
13424
|
+
@media (prefers-color-scheme: dark) { :root { --line: #263243; --ink: #e6edf7; --muted: #9fb0c6; --page: #0d131c; --code: #16202c; } }
|
|
13425
|
+
* { box-sizing: border-box; }
|
|
13426
|
+
body { margin: 0; padding: 2rem 1.25rem 4rem; background: var(--page); color: var(--ink);
|
|
13427
|
+
font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
|
|
13428
|
+
main { max-width: 60rem; margin: 0 auto; }
|
|
13429
|
+
h1 { font-size: 1.35rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
|
|
13430
|
+
p.lede { margin: 0 0 1.75rem; color: var(--muted); }
|
|
13431
|
+
a { color: inherit; }
|
|
13432
|
+
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
|
|
13433
|
+
margin: 2rem 0 .6rem; }
|
|
13434
|
+
ul { list-style: none; margin: 0; padding: 0; }
|
|
13435
|
+
li { display: grid; grid-template-columns: 4.6rem 1fr; gap: .75rem; align-items: baseline;
|
|
13436
|
+
padding: .55rem .7rem; border: 1px solid var(--line); border-radius: .5rem; margin-bottom: .4rem; }
|
|
13437
|
+
.m { font: 600 .72rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em;
|
|
13438
|
+
padding: .3rem .4rem; border-radius: .3rem; text-align: center; background: var(--code); }
|
|
13439
|
+
.m[data-m="GET"] { color: #0a7d52; } .m[data-m="POST"] { color: #1f5fd0; }
|
|
13440
|
+
.m[data-m="PUT"], .m[data-m="PATCH"] { color: #8a5b00; } .m[data-m="DELETE"] { color: #b32020; }
|
|
13441
|
+
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; }
|
|
13442
|
+
.summary { color: var(--muted); font-size: .87rem; }
|
|
13443
|
+
.error { padding: 1rem; border: 1px solid var(--line); border-radius: .5rem; color: var(--muted); }
|
|
13444
|
+
footer { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line);
|
|
13445
|
+
color: var(--muted); font-size: .85rem; }
|
|
13446
|
+
@media (max-width: 30rem) { li { grid-template-columns: 4rem 1fr; } body { padding: 1.25rem 1rem 3rem; } }
|
|
13447
|
+
</style>
|
|
13448
|
+
</head>
|
|
13449
|
+
<body>
|
|
13450
|
+
<main>
|
|
13451
|
+
<h1>home-hosted API</h1>
|
|
13452
|
+
<p class="lede">Every route the panel serves, generated from the same schemas the routes validate
|
|
13453
|
+
with. Send <code>Authorization: Bearer hh_…</code> with any call; a cookie session works too.</p>
|
|
13454
|
+
<div id="app" data-fallback="index"><p class="error">Loading the route index…</p></div>
|
|
13455
|
+
<footer>
|
|
13456
|
+
<a href="${specUrl}">${specUrl}</a> — the OpenAPI document, for
|
|
13457
|
+
<code>openapi-typescript</code>, <code>openapi-generator</code> or any other client.
|
|
13458
|
+
</footer>
|
|
13459
|
+
</main>
|
|
13460
|
+
<script type="module">
|
|
13461
|
+
const specUrl = ${JSON.stringify(specUrl)}
|
|
13462
|
+
const app = document.getElementById('app')
|
|
13463
|
+
|
|
13464
|
+
/**
|
|
13465
|
+
* The index, from the spec, with nothing but \`fetch\`. This is the page's real content: it is what a
|
|
13466
|
+
* person on an air-gapped box sees, and what the browser below replaces only if the CDN answers.
|
|
13467
|
+
*/
|
|
13468
|
+
async function renderIndex() {
|
|
13469
|
+
let spec
|
|
13470
|
+
try {
|
|
13471
|
+
const response = await fetch(specUrl, { headers: { accept: 'application/json' } })
|
|
13472
|
+
if (!response.ok) throw new Error(String(response.status))
|
|
13473
|
+
spec = await response.json()
|
|
13474
|
+
} catch (error) {
|
|
13475
|
+
app.dataset.fallback = 'error'
|
|
13476
|
+
app.innerHTML = '<p class="error">The OpenAPI document could not be read (' +
|
|
13477
|
+
String(error && error.message ? error.message : error) + ').</p>'
|
|
13478
|
+
return
|
|
13479
|
+
}
|
|
13480
|
+
|
|
13481
|
+
const tags = (spec.tags || []).map(tag => tag.name)
|
|
13482
|
+
const groups = new Map(tags.map(name => [name, []]))
|
|
13483
|
+
for (const [path, operations] of Object.entries(spec.paths || {})) {
|
|
13484
|
+
for (const [method, operation] of Object.entries(operations || {})) {
|
|
13485
|
+
const name = (operation.tags && operation.tags[0]) || 'other'
|
|
13486
|
+
if (!groups.has(name)) groups.set(name, [])
|
|
13487
|
+
groups.get(name).push({ path, method: method.toUpperCase(), summary: operation.summary || '' })
|
|
13488
|
+
}
|
|
13489
|
+
}
|
|
13490
|
+
|
|
13491
|
+
let html = ''
|
|
13492
|
+
for (const [tag, rows] of groups) {
|
|
13493
|
+
if (rows.length === 0) continue
|
|
13494
|
+
html += '<h2>' + escapeHtml(tag) + '</h2><ul>'
|
|
13495
|
+
for (const row of rows.sort((a, b) => a.path.localeCompare(b.path) || a.method.localeCompare(b.method)))
|
|
13496
|
+
html += '<li><span class="m" data-m="' + row.method + '">' + row.method + '</span><span><code>' +
|
|
13497
|
+
escapeHtml(row.path) + '</code><br><span class="summary">' + escapeHtml(row.summary) + '</span></span></li>'
|
|
13498
|
+
html += '</ul>'
|
|
13499
|
+
}
|
|
13500
|
+
app.dataset.fallback = 'rendered'
|
|
13501
|
+
app.innerHTML = html || '<p class="error">The OpenAPI document lists no operations.</p>'
|
|
13502
|
+
}
|
|
13503
|
+
|
|
13504
|
+
function escapeHtml(value) {
|
|
13505
|
+
return String(value).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
13506
|
+
.replace(/"/g, '"')
|
|
13507
|
+
}
|
|
13508
|
+
|
|
13509
|
+
await renderIndex()
|
|
13510
|
+
|
|
13511
|
+
/**
|
|
13512
|
+
* Optional enhancement: the interactive reference, which lives on a CDN. It is allowed to fail —
|
|
13513
|
+
* that is the whole point of rendering the index first — so a LAN box with no internet keeps a
|
|
13514
|
+
* usable page instead of a blank one.
|
|
13515
|
+
*
|
|
13516
|
+
* The version is pinned: this is an enhancement fetched from a third party at page load, and a
|
|
13517
|
+
* floating major would let an upstream release break or restyle the panel's page with no change
|
|
13518
|
+
* here. The index above is unaffected either way.
|
|
13519
|
+
*/
|
|
13520
|
+
try {
|
|
13521
|
+
const { createApiReference } = await import('https://cdn.jsdelivr.net/npm/@scalar/api-reference@${SCALAR_VERSION}/esm.js')
|
|
13522
|
+
app.innerHTML = ''
|
|
13523
|
+
app.dataset.fallback = 'enhanced'
|
|
13524
|
+
createApiReference('#app', { _integration: 'hono', url: specUrl, theme: 'deepSpace' })
|
|
13525
|
+
} catch {
|
|
13526
|
+
// No CDN: the index above stays, and that is a supported outcome.
|
|
13527
|
+
}
|
|
13528
|
+
<\/script>
|
|
13529
|
+
</body>
|
|
13530
|
+
</html>`;
|
|
13531
|
+
}
|
|
13532
|
+
var SCALAR_VERSION;
|
|
13533
|
+
var init_openapi_reference = __esmMin((() => {
|
|
13534
|
+
SCALAR_VERSION = "1.76.0";
|
|
13535
|
+
}));
|
|
13536
|
+
//#endregion
|
|
13537
|
+
//#region src/openapi.ts
|
|
13538
|
+
/**
|
|
13539
|
+
* The machine-readable contract, generated from the same ArkType schemas the
|
|
13540
|
+
* routes validate with — one source of truth, no second set of DTOs to drift.
|
|
13541
|
+
* `/openapi/ui` is the browsable reference and needs no session, since a UI
|
|
13542
|
+
* author has to be able to read it before they can log in.
|
|
13543
|
+
*/
|
|
13544
|
+
/** The version the package was built with, so the spec never drifts from it. */
|
|
13545
|
+
function setupOpenAPI(app) {
|
|
13546
|
+
return appFactory.createApp().get(`${PREFIX}/spec.json`, openAPIRouteHandler(app, { documentation: {
|
|
13547
|
+
info: {
|
|
12767
13548
|
title: "home-hosted",
|
|
12768
13549
|
version: appVersion(),
|
|
12769
13550
|
description: "Control plane for the processes you host at home: servers, logs, vitals, backups and settings."
|
|
@@ -12829,15 +13610,13 @@ function setupOpenAPI(app) {
|
|
|
12829
13610
|
url: "/",
|
|
12830
13611
|
description: "This panel"
|
|
12831
13612
|
}]
|
|
12832
|
-
} })).get(`${PREFIX}/ui`,
|
|
12833
|
-
theme: "deepSpace",
|
|
12834
|
-
url: `${PREFIX}/spec.json`
|
|
12835
|
-
}));
|
|
13613
|
+
} })).get(`${PREFIX}/ui`, (c) => c.html(openApiReferencePage(`${PREFIX}/spec.json`)));
|
|
12836
13614
|
}
|
|
12837
13615
|
var PREFIX;
|
|
12838
13616
|
var init_openapi = __esmMin((() => {
|
|
12839
13617
|
init_factory();
|
|
12840
13618
|
init_version();
|
|
13619
|
+
init_openapi_reference();
|
|
12841
13620
|
PREFIX = "/openapi";
|
|
12842
13621
|
}));
|
|
12843
13622
|
//#endregion
|
|
@@ -12854,7 +13633,7 @@ function createRootApp(deps) {
|
|
|
12854
13633
|
const started = Date.now();
|
|
12855
13634
|
await next();
|
|
12856
13635
|
logger.debug(`${c.req.method} ${new URL(c.req.url).pathname} ${c.res.status} ${Date.now() - started}ms`);
|
|
12857
|
-
}).onError(errorHandler).route("/_hh", createControlRoute(deps)).route("/_acme", createAcmeChallengeRoute(deps)).use("/api/*", createAuthGuard({ auth: deps.auth })).route("/api", createAuthRoute(deps)).route("/api", createStateRoute(deps)).route("/api", createEventsRoute(deps)).route("/api", createSettingsRoute(deps)).route("/api", createTlsRoute(deps)).route("/api", createLogsRoute(deps)).route("/api", createNotificationsRoute(deps)).route("/api", createDdnsRoute(deps)).route("/api", createProxyRoute(deps)).route("/api", createMetricsRoute(deps)).route("/api", createBackupsRoute(deps)).route("/api/workspaces", createWorkspacesRoute(deps)).route("/api/servers", createServersRoute(deps)).route("/", createHealthRoute(deps));
|
|
13636
|
+
}).onError(errorHandler).route("/_hh", createControlRoute(deps)).route("/_acme", createAcmeChallengeRoute(deps)).use("/api/*", createAuthGuard({ auth: deps.auth })).route("/api", createAuthRoute(deps)).route("/api", createStateRoute(deps)).route("/api", createEventsRoute(deps)).route("/api", createSettingsRoute(deps)).route("/api", createTlsRoute(deps)).route("/api", createWslTemperatureRoute(deps)).route("/api", createLogsRoute(deps)).route("/api", createNotificationsRoute(deps)).route("/api", createDdnsRoute(deps)).route("/api", createProxyRoute(deps)).route("/api", createMetricsRoute(deps)).route("/api", createBackupsRoute(deps)).route("/api/workspaces", createWorkspacesRoute(deps)).route("/api/servers", createServersRoute(deps)).route("/", createHealthRoute(deps));
|
|
12858
13637
|
return app.route("/", setupOpenAPI(app)).route("/", createStaticRoute({ dir: () => deps.ui.resolveDir() }));
|
|
12859
13638
|
}
|
|
12860
13639
|
var init_app = __esmMin((() => {
|
|
@@ -12875,6 +13654,7 @@ var init_app = __esmMin((() => {
|
|
|
12875
13654
|
init_static();
|
|
12876
13655
|
init_tls();
|
|
12877
13656
|
init_$_routes();
|
|
13657
|
+
init_wsl_temperature();
|
|
12878
13658
|
init_error();
|
|
12879
13659
|
init_factory();
|
|
12880
13660
|
init_logger();
|
|
@@ -12995,8 +13775,8 @@ async function probeRuntime(runtime, timeoutMs = 2500) {
|
|
|
12995
13775
|
* Asks the daemon to stop through its own endpoint, so supervised servers are
|
|
12996
13776
|
* shut down cleanly on every platform (a bare signal is not graceful on Windows).
|
|
12997
13777
|
*/
|
|
12998
|
-
async function requestShutdown(runtime, timeoutMs = 4e3) {
|
|
12999
|
-
const answer = await localCall(runtime,
|
|
13778
|
+
async function requestShutdown(runtime, timeoutMs = 4e3, options = {}) {
|
|
13779
|
+
const answer = await localCall(runtime, `/_hh/shutdown${options.withPersistent === true ? "?withPersistent=true" : ""}`, "POST", runtime.token, timeoutMs);
|
|
13000
13780
|
return answer !== null && answer.status >= 200 && answer.status < 300;
|
|
13001
13781
|
}
|
|
13002
13782
|
/**
|
|
@@ -13414,7 +14194,8 @@ async function listZip(file) {
|
|
|
13414
14194
|
directory: entry.directory === true,
|
|
13415
14195
|
encrypted: entry.encrypted === true,
|
|
13416
14196
|
symlink: entry.symlink === true,
|
|
13417
|
-
size: entry.uncompressedSize ?? 0
|
|
14197
|
+
size: entry.uncompressedSize ?? 0,
|
|
14198
|
+
...entry.unixMode === void 0 ? {} : { mode: entry.unixMode }
|
|
13418
14199
|
}));
|
|
13419
14200
|
} finally {
|
|
13420
14201
|
await reader.close();
|
|
@@ -13434,10 +14215,14 @@ function isInvalidPassword(error) {
|
|
|
13434
14215
|
return error instanceof Error && /invalid password/i.test(error.message);
|
|
13435
14216
|
}
|
|
13436
14217
|
/**
|
|
13437
|
-
* Writes the contents of `sourceDir` into `destination`, preserving the tree
|
|
13438
|
-
*
|
|
13439
|
-
*
|
|
13440
|
-
*
|
|
14218
|
+
* Writes the contents of `sourceDir` into `destination`, preserving the tree and each
|
|
14219
|
+
* entry's permission bits.
|
|
14220
|
+
*
|
|
14221
|
+
* The mode is captured because the tree is somebody's data directory: a `0600` key, a `0700`
|
|
14222
|
+
* directory and a `0755` script are all routine there, and a backup that restores them as `0644`
|
|
14223
|
+
* changes who can read the data it was taken to protect. What a symlink may bring in is bounded by
|
|
14224
|
+
* the tree itself (`walk`): the target has to be inside it, so a declared path cannot capture bytes
|
|
14225
|
+
* from outside itself. Streams from disk to disk: nothing is buffered whole.
|
|
13441
14226
|
*/
|
|
13442
14227
|
async function createZip(sourceDir, destination, options = {}) {
|
|
13443
14228
|
const output = fs.createWriteStream(destination, { mode: 384 });
|
|
@@ -13452,9 +14237,18 @@ async function createZip(sourceDir, destination, options = {}) {
|
|
|
13452
14237
|
keepOrder: true
|
|
13453
14238
|
});
|
|
13454
14239
|
try {
|
|
13455
|
-
for (const item of walk(sourceDir))
|
|
13456
|
-
|
|
13457
|
-
|
|
14240
|
+
for (const item of walk(sourceDir)) {
|
|
14241
|
+
const mode = item.mode === null ? {} : { unixMode: item.mode };
|
|
14242
|
+
if (item.directory) await zip.add(item.name, null, {
|
|
14243
|
+
directory: true,
|
|
14244
|
+
...mode
|
|
14245
|
+
});
|
|
14246
|
+
else if (item.size === 0) await zip.add(item.name, null, {
|
|
14247
|
+
directory: false,
|
|
14248
|
+
...mode
|
|
14249
|
+
});
|
|
14250
|
+
else await zip.add(item.name, Readable.toWeb(fs.createReadStream(item.absolute)), mode);
|
|
14251
|
+
}
|
|
13458
14252
|
await zip.close();
|
|
13459
14253
|
await flushed;
|
|
13460
14254
|
} catch (error) {
|
|
@@ -13467,10 +14261,16 @@ async function createZip(sourceDir, destination, options = {}) {
|
|
|
13467
14261
|
* Extracts the given entries (already validated by the caller) into
|
|
13468
14262
|
* `destination`. Symbolic links are never recreated — an archive is not allowed
|
|
13469
14263
|
* to make the filesystem point somewhere else.
|
|
14264
|
+
*
|
|
14265
|
+
* An entry's permission bits are applied after it lands. The file is created under a restrictive
|
|
14266
|
+
* mode first, so a `0600` secret never exists world-readable between two calls, and a mode the
|
|
14267
|
+
* current umask would widen is set with an explicit `chmod` rather than left to the create.
|
|
13470
14268
|
*/
|
|
13471
14269
|
async function extractZip(file, destination, options) {
|
|
13472
14270
|
const reader = await open(file, options.password);
|
|
13473
14271
|
const skipped = [];
|
|
14272
|
+
/** Directory modes, applied after their contents: a `0700` dir cannot be written into. */
|
|
14273
|
+
const pendingDirModes = [];
|
|
13474
14274
|
try {
|
|
13475
14275
|
const entries = new Map((await reader.getEntries()).map((entry) => [entry.filename, entry]));
|
|
13476
14276
|
for (const name of options.names) {
|
|
@@ -13482,6 +14282,11 @@ async function extractZip(file, destination, options) {
|
|
|
13482
14282
|
const target = path.join(destination, name);
|
|
13483
14283
|
if (entry.directory) {
|
|
13484
14284
|
fs.mkdirSync(target, { recursive: true });
|
|
14285
|
+
const mode = permissionBits(entry.unixMode);
|
|
14286
|
+
if (mode !== null) pendingDirModes.push({
|
|
14287
|
+
target,
|
|
14288
|
+
mode
|
|
14289
|
+
});
|
|
13485
14290
|
continue;
|
|
13486
14291
|
}
|
|
13487
14292
|
if (entry.symlink) {
|
|
@@ -13489,10 +14294,18 @@ async function extractZip(file, destination, options) {
|
|
|
13489
14294
|
continue;
|
|
13490
14295
|
}
|
|
13491
14296
|
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
13492
|
-
await entry.getData(Writable.toWeb(fs.createWriteStream(target)), writeOptions(entry, options.password));
|
|
14297
|
+
await entry.getData(Writable.toWeb(fs.createWriteStream(target, { mode: 384 })), writeOptions(entry, options.password));
|
|
14298
|
+
const mode = permissionBits(entry.unixMode);
|
|
14299
|
+
if (mode !== null) try {
|
|
14300
|
+
fs.chmodSync(target, mode);
|
|
14301
|
+
} catch {}
|
|
13493
14302
|
}
|
|
13494
14303
|
} finally {
|
|
13495
14304
|
await reader.close();
|
|
14305
|
+
for (const { target, mode } of pendingDirModes.sort((left, right) => right.target.length - left.target.length)) try {
|
|
14306
|
+
fs.chmodSync(target, mode);
|
|
14307
|
+
} catch {}
|
|
14308
|
+
pendingDirModes.length = 0;
|
|
13496
14309
|
}
|
|
13497
14310
|
return { skipped };
|
|
13498
14311
|
}
|
|
@@ -13504,15 +14317,58 @@ async function open(file, password) {
|
|
|
13504
14317
|
return password === void 0 ? new ZipReader(new BlobReader(blob)) : new ZipReader(new BlobReader(blob), { password });
|
|
13505
14318
|
}
|
|
13506
14319
|
/**
|
|
13507
|
-
*
|
|
14320
|
+
* The `st_mode` an entry should carry, or `null` where the platform does not report one.
|
|
14321
|
+
*
|
|
14322
|
+
* Only the permission bits and the file type are kept: the archive records a mode, not an owner,
|
|
14323
|
+
* because a restore runs as whoever restores it and a foreign uid would be a worse lie than the
|
|
14324
|
+
* restoring user's own.
|
|
14325
|
+
*/
|
|
14326
|
+
function archiveMode(stats) {
|
|
14327
|
+
const bits = stats.mode & 511;
|
|
14328
|
+
if (process.platform === "win32" || bits === 0) return null;
|
|
14329
|
+
return (stats.isDirectory() ? 16384 : 32768) | bits;
|
|
14330
|
+
}
|
|
14331
|
+
/**
|
|
14332
|
+
* The permission bits an extracted entry should be given, or `null` when the archive carries none.
|
|
14333
|
+
*
|
|
14334
|
+
* Zip stores the type in the same field, so the file type is dropped: the entry is written as the
|
|
14335
|
+
* ordinary file or directory this call is creating, never as a fifo or a device node an archive
|
|
14336
|
+
* could name. The setuid/setgid/sticky bits are dropped too — an archive from another host does not
|
|
14337
|
+
* get to install a privileged binary here.
|
|
14338
|
+
*/
|
|
14339
|
+
function permissionBits(unixMode) {
|
|
14340
|
+
if (unixMode === void 0 || unixMode === 0) return null;
|
|
14341
|
+
const bits = unixMode & 511;
|
|
14342
|
+
return bits === 0 ? null : bits;
|
|
14343
|
+
}
|
|
14344
|
+
/** True when `child` is `parent` itself or lives underneath it, after resolving both. */
|
|
14345
|
+
function isUnderResolved(parent, child) {
|
|
14346
|
+
const relative = path.relative(parent, child);
|
|
14347
|
+
return relative === "" || !path.isAbsolute(relative) && !relative.startsWith("..");
|
|
14348
|
+
}
|
|
14349
|
+
/**
|
|
14350
|
+
* Sorted, deterministic walk with directory loops broken and the declared tree respected.
|
|
13508
14351
|
*
|
|
13509
14352
|
* Every read is best-effort: a directory that vanishes mid-walk (a rotated log, a
|
|
13510
14353
|
* build directory being cleaned, a container being torn down) must leave it out of
|
|
13511
14354
|
* the archive rather than reject `createZip` and turn a backup into a failure.
|
|
14355
|
+
*
|
|
14356
|
+
* A link that resolves **outside** `root` is left out rather than followed. `root` is a copy of the
|
|
14357
|
+
* declared path, so a link inside it points back at the live tree — following one captured bytes
|
|
14358
|
+
* from outside the path the person declared (a `media -> /mnt/nas` symlink pulled the whole share
|
|
14359
|
+
* into the archive), and it captured the *live* copy of anything the copy had already frozen. A
|
|
14360
|
+
* restore never recreates links anyway, so the link itself has nothing to restore; its content, if
|
|
14361
|
+
* it is wanted, is declared as its own path.
|
|
13512
14362
|
*/
|
|
13513
14363
|
function walk(root) {
|
|
13514
14364
|
const files = [];
|
|
13515
14365
|
const seen = /* @__PURE__ */ new Set();
|
|
14366
|
+
let realRoot;
|
|
14367
|
+
try {
|
|
14368
|
+
realRoot = fs.realpathSync(root);
|
|
14369
|
+
} catch {
|
|
14370
|
+
return files;
|
|
14371
|
+
}
|
|
13516
14372
|
const readDir = (absolute) => {
|
|
13517
14373
|
try {
|
|
13518
14374
|
return fs.readdirSync(absolute).sort();
|
|
@@ -13527,20 +14383,22 @@ function walk(root) {
|
|
|
13527
14383
|
} catch {
|
|
13528
14384
|
return;
|
|
13529
14385
|
}
|
|
14386
|
+
let real;
|
|
14387
|
+
try {
|
|
14388
|
+
real = fs.realpathSync(absolute);
|
|
14389
|
+
} catch {
|
|
14390
|
+
return;
|
|
14391
|
+
}
|
|
14392
|
+
if (!isUnderResolved(realRoot, real)) return;
|
|
13530
14393
|
if (stats.isDirectory()) {
|
|
13531
|
-
let real;
|
|
13532
|
-
try {
|
|
13533
|
-
real = fs.realpathSync(absolute);
|
|
13534
|
-
} catch {
|
|
13535
|
-
return;
|
|
13536
|
-
}
|
|
13537
14394
|
if (seen.has(real)) return;
|
|
13538
14395
|
seen.add(real);
|
|
13539
14396
|
files.push({
|
|
13540
14397
|
name: `${name}/`,
|
|
13541
14398
|
absolute,
|
|
13542
14399
|
directory: true,
|
|
13543
|
-
size: 0
|
|
14400
|
+
size: 0,
|
|
14401
|
+
mode: archiveMode(stats)
|
|
13544
14402
|
});
|
|
13545
14403
|
for (const child of readDir(absolute)) visit(path.join(absolute, child), `${name}/${child}`);
|
|
13546
14404
|
return;
|
|
@@ -13549,7 +14407,8 @@ function walk(root) {
|
|
|
13549
14407
|
name,
|
|
13550
14408
|
absolute,
|
|
13551
14409
|
directory: false,
|
|
13552
|
-
size: stats.size
|
|
14410
|
+
size: stats.size,
|
|
14411
|
+
mode: archiveMode(stats)
|
|
13553
14412
|
});
|
|
13554
14413
|
};
|
|
13555
14414
|
for (const child of readDir(root)) visit(path.join(root, child), child);
|
|
@@ -13745,6 +14604,10 @@ function findComposeFile(from) {
|
|
|
13745
14604
|
dir = parent;
|
|
13746
14605
|
}
|
|
13747
14606
|
}
|
|
14607
|
+
/** Whether this argv runs a compose stack, without resolving anything — a cheap pre-check. */
|
|
14608
|
+
function isComposeCommand(command, args) {
|
|
14609
|
+
return composeArgv(command, args) !== null;
|
|
14610
|
+
}
|
|
13748
14611
|
/**
|
|
13749
14612
|
* The compose project an entry runs, from evidence in its own config: the command it spawns, its
|
|
13750
14613
|
* argv, its cwd and its environment. `null` means "sample the process tree", which is the right
|
|
@@ -13801,6 +14664,58 @@ function sumContainers(rows, readings) {
|
|
|
13801
14664
|
containers: rows.length
|
|
13802
14665
|
};
|
|
13803
14666
|
}
|
|
14667
|
+
/** Whether a container publishing a port belongs to the stack this entry itself declares. */
|
|
14668
|
+
function isOwnStack(holder, target) {
|
|
14669
|
+
if (target === null) return false;
|
|
14670
|
+
if (holder.project !== null && target.project !== null) return holder.project === target.project;
|
|
14671
|
+
if (holder.composeDir === null) return false;
|
|
14672
|
+
return target.configFiles.some((file) => samePath(path.dirname(file), holder.composeDir));
|
|
14673
|
+
}
|
|
14674
|
+
/** One target's running containers from a fresh `docker ps`, or `null` when docker cannot answer. */
|
|
14675
|
+
async function composeContainers(target) {
|
|
14676
|
+
try {
|
|
14677
|
+
return attributeContainers(target, parseDockerPs((await execFileAsync$1("docker", [
|
|
14678
|
+
"ps",
|
|
14679
|
+
"--filter",
|
|
14680
|
+
"label=com.docker.compose.project",
|
|
14681
|
+
"--format",
|
|
14682
|
+
PS_FORMAT
|
|
14683
|
+
], {
|
|
14684
|
+
timeout: 5e3,
|
|
14685
|
+
maxBuffer: 4194304
|
|
14686
|
+
})).stdout));
|
|
14687
|
+
} catch {
|
|
14688
|
+
return null;
|
|
14689
|
+
}
|
|
14690
|
+
}
|
|
14691
|
+
/**
|
|
14692
|
+
* Stops every container of one target and reports what is still running afterwards.
|
|
14693
|
+
*
|
|
14694
|
+
* The answer comes from a **fresh listing**, not from `docker stop`'s exit code: a stop that
|
|
14695
|
+
* printed success for a container still listed is the empty success this exists to refuse.
|
|
14696
|
+
* `null` means docker could not be asked, which is not the same as "it stopped".
|
|
14697
|
+
*/
|
|
14698
|
+
async function stopComposeContainers(target) {
|
|
14699
|
+
const before = await composeContainers(target);
|
|
14700
|
+
if (before === null) return null;
|
|
14701
|
+
if (before.length === 0) return {
|
|
14702
|
+
stopped: [],
|
|
14703
|
+
survivors: []
|
|
14704
|
+
};
|
|
14705
|
+
try {
|
|
14706
|
+
await execFileAsync$1("docker", ["stop", ...before.map((row) => row.name)], {
|
|
14707
|
+
timeout: 12e4,
|
|
14708
|
+
maxBuffer: 4194304
|
|
14709
|
+
});
|
|
14710
|
+
} catch {}
|
|
14711
|
+
const after = await composeContainers(target);
|
|
14712
|
+
if (after === null) return null;
|
|
14713
|
+
const remaining = new Set(after.map((row) => row.name));
|
|
14714
|
+
return {
|
|
14715
|
+
stopped: before.map((row) => row.name).filter((name) => !remaining.has(name)),
|
|
14716
|
+
survivors: after.map((row) => row.name)
|
|
14717
|
+
};
|
|
14718
|
+
}
|
|
13804
14719
|
var execFileAsync$1, DOCKER_CACHE_MS, COMPOSE_FILES, COMPOSE_VALUE_FLAGS, COMPOSE_VALUELESS_FLAGS, DOCKER_VALUE_FLAGS, PS_FORMAT, EMPTY, statsLineSchema, BYTE_SCALES, DockerMetrics;
|
|
13805
14720
|
var init_docker = __esmMin((() => {
|
|
13806
14721
|
execFileAsync$1 = promisify(execFile);
|
|
@@ -14702,15 +15617,15 @@ var init_supervisor = __esmMin((() => {
|
|
|
14702
15617
|
for (const config of orderByDependencies(targets)) await this.start(config.id, { actor: "boot" });
|
|
14703
15618
|
}
|
|
14704
15619
|
/**
|
|
14705
|
-
* Stops every entry this command owns. A persistent entry is deliberately not among
|
|
14706
|
-
*
|
|
15620
|
+
* Stops every entry this command owns. A persistent entry is deliberately not among them
|
|
15621
|
+
* unless asked: that is the whole point of the flag, and it is said out loud rather than
|
|
14707
15622
|
* silently skipped, so "stopped everything" is never claimed about a running server.
|
|
14708
15623
|
*/
|
|
14709
|
-
async stopAll() {
|
|
15624
|
+
async stopAll(options = {}) {
|
|
14710
15625
|
const targets = orderByDependencies([...this.entries.values()].map((entry) => entry.config)).reverse();
|
|
14711
15626
|
for (const config of targets) {
|
|
14712
15627
|
const entry = this.entries.get(config.id);
|
|
14713
|
-
if (entry !== void 0 && entry.config.persistent) {
|
|
15628
|
+
if (entry !== void 0 && entry.config.persistent && options.withPersistent !== true) {
|
|
14714
15629
|
if (this.isActive(entry)) this.log(entry, "system", "persistent: left running (stop it explicitly to end it)");
|
|
14715
15630
|
continue;
|
|
14716
15631
|
}
|
|
@@ -15015,12 +15930,17 @@ var init_supervisor = __esmMin((() => {
|
|
|
15015
15930
|
entry.logs.clear();
|
|
15016
15931
|
this.publishServer(entry);
|
|
15017
15932
|
}
|
|
15018
|
-
|
|
15933
|
+
/**
|
|
15934
|
+
* Ends this supervisor's work. Persistent entries outlive the process by design, so they
|
|
15935
|
+
* are left running unless `withPersistent` says otherwise — `down --with-persistent` is
|
|
15936
|
+
* what asks, and it needs the stop recorded here, while the panel is still alive to do it.
|
|
15937
|
+
*/
|
|
15938
|
+
async dispose(options = {}) {
|
|
15019
15939
|
this.disposed = true;
|
|
15020
15940
|
clearInterval(this.tickTimer);
|
|
15021
15941
|
this.storeUnsubscribe();
|
|
15022
15942
|
for (const entry of this.entries.values()) this.clearRetry(entry);
|
|
15023
|
-
await Promise.all([...this.entries.values()].filter((entry) => !entry.config.persistent).map((entry) => this.stopEntry(entry)));
|
|
15943
|
+
await Promise.all([...this.entries.values()].filter((entry) => options.withPersistent === true || !entry.config.persistent).map((entry) => this.stopEntry(entry)));
|
|
15024
15944
|
this.relay.dispose();
|
|
15025
15945
|
}
|
|
15026
15946
|
/**
|
|
@@ -15088,6 +16008,12 @@ var init_supervisor = __esmMin((() => {
|
|
|
15088
16008
|
});
|
|
15089
16009
|
if (entry.child === null && entry.pid === null) {
|
|
15090
16010
|
entry.stopping = false;
|
|
16011
|
+
const stack = await this.stopComposeStack(entry);
|
|
16012
|
+
entry.stopping = false;
|
|
16013
|
+
if (this.refuseLingeringStack(entry, stack)) return {
|
|
16014
|
+
ok: false,
|
|
16015
|
+
error: entry.lastError
|
|
16016
|
+
};
|
|
15091
16017
|
entry.status = "stopped";
|
|
15092
16018
|
this.publishServer(entry);
|
|
15093
16019
|
return { ok: true };
|
|
@@ -15120,6 +16046,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
15120
16046
|
}
|
|
15121
16047
|
entry.stopping = false;
|
|
15122
16048
|
entry.child = null;
|
|
16049
|
+
const stack = await this.stopComposeStack(entry);
|
|
15123
16050
|
this.endProcessReadings(entry);
|
|
15124
16051
|
entry.nannyExit = null;
|
|
15125
16052
|
this.endHealthStreak(entry);
|
|
@@ -15128,11 +16055,12 @@ var init_supervisor = __esmMin((() => {
|
|
|
15128
16055
|
entry.lastChild = null;
|
|
15129
16056
|
this.persistEntryState(entry);
|
|
15130
16057
|
}
|
|
15131
|
-
|
|
16058
|
+
const lingering = this.refuseLingeringStack(entry, stack);
|
|
15132
16059
|
if (survivor !== null) entry.lastError = `pid ${survivor} survived the stop`;
|
|
15133
|
-
|
|
16060
|
+
entry.status = survivor === null && !lingering ? "stopped" : "conflict";
|
|
16061
|
+
this.log(entry, "system", entry.status === "stopped" ? "stopped" : entry.lastError);
|
|
15134
16062
|
this.publishServer(entry);
|
|
15135
|
-
return
|
|
16063
|
+
return entry.status === "stopped" ? { ok: true } : {
|
|
15136
16064
|
ok: false,
|
|
15137
16065
|
error: entry.lastError
|
|
15138
16066
|
};
|
|
@@ -15364,7 +16292,10 @@ var init_supervisor = __esmMin((() => {
|
|
|
15364
16292
|
this.log(entry, "system", `port ${port} is held by pid ${own}, a detached restart of this entry — replacing it with a supervised process`);
|
|
15365
16293
|
return await this.stopPortHolders(entry, [own], port, "replacing", freeOnAll);
|
|
15366
16294
|
}
|
|
15367
|
-
const hint =
|
|
16295
|
+
const hint = isOwnStack(docker ?? {
|
|
16296
|
+
project: null,
|
|
16297
|
+
composeDir: null
|
|
16298
|
+
}, entry.compose) ? ` — this is this entry's own stack, already up: set onPortConflict to "warn" to attach to it` : own !== null ? ` — pid ${own} is a detached restart of this entry: set onPortConflict to "follow" to adopt it, "reclaim" to replace it with a supervised process, or "kill" to stop whatever holds the port` : docker === null ? "" : ` — it is published by a docker container, which \`kill\` stops through docker; \`block\` and \`warn\` leave it alone`;
|
|
15368
16299
|
const blockedError = ours.length > 0 ? this.heldByOurs(port, ours, siblings) : `port ${port} is already in use${suffix}${hint}`;
|
|
15369
16300
|
if (entry.config.onPortConflict !== "warn") {
|
|
15370
16301
|
entry.status = "conflict";
|
|
@@ -15555,6 +16486,46 @@ var init_supervisor = __esmMin((() => {
|
|
|
15555
16486
|
else if (code !== null) this.log(entry, "system", `bootstrap exited with code ${code} — continuing anyway`);
|
|
15556
16487
|
}
|
|
15557
16488
|
/**
|
|
16489
|
+
* Marks a stop that did not take because a container outlived it, and reports whether it happened.
|
|
16490
|
+
*
|
|
16491
|
+
* Both stop paths can end with the wrapper gone and the stack up — with no child to signal at all
|
|
16492
|
+
* (a reboot, `compose up -d` from a shell, a panel crash), or with one this process signalled that
|
|
16493
|
+
* did not take its containers down. One sentence for the one condition, so the card answers the
|
|
16494
|
+
* same whether the person pressed Stop on a conflict or on a running entry.
|
|
16495
|
+
*/
|
|
16496
|
+
refuseLingeringStack(entry, stack) {
|
|
16497
|
+
const survivors = stack?.survivors ?? [];
|
|
16498
|
+
if (survivors.length === 0) return false;
|
|
16499
|
+
entry.status = "conflict";
|
|
16500
|
+
entry.lastError = `the stack "${entry.config.id}" is still running: container${survivors.length === 1 ? "" : "s"} ${survivors.join(", ")} — docker was asked to stop them and they stayed up`;
|
|
16501
|
+
this.log(entry, "system", entry.lastError);
|
|
16502
|
+
return true;
|
|
16503
|
+
}
|
|
16504
|
+
/**
|
|
16505
|
+
* Stops the running containers of a compose entry whose wrapper this panel is not holding.
|
|
16506
|
+
*
|
|
16507
|
+
* A compose entry's server is its containers, and they are not descendants of the wrapper: a
|
|
16508
|
+
* reboot, a `docker compose up -d` from a shell, or a panel crash leaves them running with no
|
|
16509
|
+
* child to signal. The stop path answered "stopped" for exactly that state (measured: the stack
|
|
16510
|
+
* kept serving HTTP 200 through `stop`, `stop-all` and `down`, all exiting 0), so the containers
|
|
16511
|
+
* have to be ended by the thing that knows which stack this entry declares.
|
|
16512
|
+
*
|
|
16513
|
+
* `null` means "this entry has no compose stack, or docker could not be asked" — the caller then
|
|
16514
|
+
* reports what it can actually see, never a stack it did not confirm is gone.
|
|
16515
|
+
*/
|
|
16516
|
+
async stopComposeStack(entry) {
|
|
16517
|
+
if (entry.compose === null && !isComposeCommand(entry.config.command, entry.config.args)) return null;
|
|
16518
|
+
if (entry.compose === null) this.detectCompose(entry, this.resolveSpawn(entry));
|
|
16519
|
+
if (entry.compose === null) return null;
|
|
16520
|
+
const outcome = await stopComposeContainers(entry.compose);
|
|
16521
|
+
if (outcome === null) {
|
|
16522
|
+
this.log(entry, "system", "docker could not be asked to stop this stack — its containers were not confirmed stopped");
|
|
16523
|
+
return null;
|
|
16524
|
+
}
|
|
16525
|
+
if (outcome.stopped.length > 0) this.log(entry, "system", `stopped the container${outcome.stopped.length === 1 ? "" : "s"} ${outcome.stopped.join(", ")}`);
|
|
16526
|
+
return outcome;
|
|
16527
|
+
}
|
|
16528
|
+
/**
|
|
15558
16529
|
* Whether this entry runs a compose stack, from what it would actually spawn.
|
|
15559
16530
|
*
|
|
15560
16531
|
* `command`/`args` are read through the same `resolveSpawn` the spawn itself uses, so the
|
|
@@ -16443,6 +17414,21 @@ function readArchivedServers(staging, workspaceId, defaults = {}) {
|
|
|
16443
17414
|
return [];
|
|
16444
17415
|
}
|
|
16445
17416
|
}
|
|
17417
|
+
/**
|
|
17418
|
+
* Whether one archive path segment is a name a filesystem will accept as-is.
|
|
17419
|
+
*
|
|
17420
|
+
* A separator moves the path, and `\` is a separator on Windows while an archive crosses platforms;
|
|
17421
|
+
* `:` re-roots or opens a stream there. A control character is never a real filename and is how an
|
|
17422
|
+
* extractor is confused. Everything else — spaces, non-ASCII, `&`, `$`, `#`, `@` — is what a data
|
|
17423
|
+
* directory actually contains.
|
|
17424
|
+
*/
|
|
17425
|
+
function isPortableSegment(segment) {
|
|
17426
|
+
for (const character of segment) {
|
|
17427
|
+
const code = character.codePointAt(0) ?? 0;
|
|
17428
|
+
if (character === "\\" || character === ":" || code < 32 || code === 127) return false;
|
|
17429
|
+
}
|
|
17430
|
+
return true;
|
|
17431
|
+
}
|
|
16446
17432
|
function isSafeArchiveEntry(entry) {
|
|
16447
17433
|
if (entry.startsWith("/") || entry.includes("\0")) return false;
|
|
16448
17434
|
const cleaned = entry.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
@@ -16451,7 +17437,7 @@ function isSafeArchiveEntry(entry) {
|
|
|
16451
17437
|
const segments = cleaned.split("/");
|
|
16452
17438
|
if (segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) return false;
|
|
16453
17439
|
if (!ALLOWED_ROOTS.has(segments[0])) return false;
|
|
16454
|
-
return segments.every(
|
|
17440
|
+
return segments.every(isPortableSegment);
|
|
16455
17441
|
}
|
|
16456
17442
|
async function admitArchive(archivePath) {
|
|
16457
17443
|
if (!isZipArchive(archivePath)) return {
|
|
@@ -16602,16 +17588,53 @@ function buildBackupSources(input) {
|
|
|
16602
17588
|
};
|
|
16603
17589
|
}
|
|
16604
17590
|
/**
|
|
17591
|
+
* An archived config, lifted to the schema this release reads.
|
|
17592
|
+
*
|
|
17593
|
+
* An archive is a snapshot, so the release that wrote it is often **older** than the one restoring
|
|
17594
|
+
* it — the backup someone takes before an upgrade is the one they reach for afterwards. Its files
|
|
17595
|
+
* carry the schema they were written with, and the parsers refuse an older stamp by design, so a
|
|
17596
|
+
* plain readability gate discarded every config an older archive carried: measured on a real
|
|
17597
|
+
* 0.7.21 archive applied to a blank 0.10.0 home, it reported "restored 4 items" and every one of
|
|
17598
|
+
* them was a secrets leaf, while both workspaces and the global settings were dropped as "not
|
|
17599
|
+
* valid" — a half-restored setup that reads as a success.
|
|
17600
|
+
*
|
|
17601
|
+
* So run the same chain `migrate` runs, on the contents rather than on a file: an archive that
|
|
17602
|
+
* needs lifting is lifted, and one this release cannot lift is still refused. A newer archive is
|
|
17603
|
+
* never rewritten here — that direction is refused earlier, from the manifest's own schema.
|
|
17604
|
+
*
|
|
17605
|
+
* **Lifting needs an explicit older stamp.** A file carrying no `meta.schema` is not evidence of an
|
|
17606
|
+
* older release — it is a seed (written in the current shape) or a damaged file, and lifting an
|
|
17607
|
+
* unparseable one let `{"not": "a servers file"}` be stamped as a valid empty `servers.config.json`,
|
|
17608
|
+
* which would restore a workspace with every entry deleted. Only a numeric stamp this release can
|
|
17609
|
+
* lift qualifies; anything else is left to its own parser, which refuses it.
|
|
17610
|
+
*
|
|
17611
|
+
* `null` means "this release cannot read it", which stays distinguishable from "it was fine".
|
|
17612
|
+
*/
|
|
17613
|
+
function liftArchived(raw) {
|
|
17614
|
+
if (!isRecord(raw)) return null;
|
|
17615
|
+
const meta = isRecord(raw.meta) ? raw.meta : {};
|
|
17616
|
+
if (typeof meta.schema !== "number") return raw;
|
|
17617
|
+
const plan = planConfigMigrations(meta.schema);
|
|
17618
|
+
if (plan.tooNew || plan.reached !== plan.to) return null;
|
|
17619
|
+
if (plan.steps.length === 0) return raw;
|
|
17620
|
+
const lifted = applyConfigMigrations(raw, meta.schema).config;
|
|
17621
|
+
return isRecord(lifted) ? stampConfig(lifted) : null;
|
|
17622
|
+
}
|
|
17623
|
+
/**
|
|
16605
17624
|
* A restored settings file is accepted when this release can read it — through
|
|
16606
17625
|
* the same tolerant parser the stores use, so an archive from a newer release
|
|
16607
17626
|
* keeps only the keys this one understands instead of being refused outright.
|
|
17627
|
+
*
|
|
17628
|
+
* An older one is lifted first (`liftArchived`), and the **lifted** value is returned so the
|
|
17629
|
+
* caller writes a config this release can load rather than the stamp it could not.
|
|
16608
17630
|
*/
|
|
16609
17631
|
function readableGlobalSettings(text) {
|
|
16610
|
-
if (text === null) return
|
|
17632
|
+
if (text === null) return null;
|
|
16611
17633
|
try {
|
|
16612
|
-
|
|
17634
|
+
const lifted = liftArchived(JSON.parse(text));
|
|
17635
|
+
return lifted !== null && parseGlobalSettings(lifted).config !== null ? lifted : null;
|
|
16613
17636
|
} catch {
|
|
16614
|
-
return
|
|
17637
|
+
return null;
|
|
16615
17638
|
}
|
|
16616
17639
|
}
|
|
16617
17640
|
/**
|
|
@@ -16706,21 +17729,27 @@ function manifestInfo(manifest) {
|
|
|
16706
17729
|
* `servers.config.json` is only a readability gate here: the store applies the
|
|
16707
17730
|
* workspace's own defaults on the next load, and an archive from another machine
|
|
16708
17731
|
* need not match this one's default shapes exactly.
|
|
17732
|
+
*
|
|
17733
|
+
* An older archive is lifted to this release's schema first, so its entries are adopted rather
|
|
17734
|
+
* than dropped; `null` means this release cannot read it at all.
|
|
16709
17735
|
*/
|
|
16710
17736
|
function readableServersFile(text) {
|
|
16711
17737
|
try {
|
|
16712
|
-
const
|
|
17738
|
+
const lifted = liftArchived(JSON.parse(text));
|
|
17739
|
+
if (lifted === null) return null;
|
|
17740
|
+
const result = parseServersFile(lifted, {});
|
|
16713
17741
|
return result.errors.length === 0 ? result.servers : null;
|
|
16714
17742
|
} catch {
|
|
16715
17743
|
return null;
|
|
16716
17744
|
}
|
|
16717
17745
|
}
|
|
16718
|
-
/** A workspace settings file is adopted only when this release can read it. */
|
|
17746
|
+
/** A workspace settings file is adopted only when this release can read it, lifted when older. */
|
|
16719
17747
|
function readableWorkspaceSettings(text) {
|
|
16720
17748
|
try {
|
|
16721
|
-
|
|
17749
|
+
const lifted = liftArchived(JSON.parse(text));
|
|
17750
|
+
return lifted !== null && parseWorkspaceSettings(lifted).config !== null ? lifted : null;
|
|
16722
17751
|
} catch {
|
|
16723
|
-
return
|
|
17752
|
+
return null;
|
|
16724
17753
|
}
|
|
16725
17754
|
}
|
|
16726
17755
|
var MANIFEST, REGISTRY, ALLOWED_ROOTS, SUFFIX, PENDING_LOAD, AUTO_PREFIX, RELOADABLE, SECRET_LABELS, BackupService;
|
|
@@ -17134,7 +18163,8 @@ var init_backups = __esmMin((() => {
|
|
|
17134
18163
|
}
|
|
17135
18164
|
};
|
|
17136
18165
|
const settingsText = readText(path.join(staging, "global", "settings.json"));
|
|
17137
|
-
const
|
|
18166
|
+
const liftedGlobal = readableGlobalSettings(settingsText);
|
|
18167
|
+
const parsedGlobal = liftedGlobal === null ? null : parseGlobalSettings(liftedGlobal).config;
|
|
17138
18168
|
if (settingsText !== null && parsedGlobal === null) {
|
|
17139
18169
|
plan.skipped.push("Global settings (the archive's settings are not valid)");
|
|
17140
18170
|
plan.skippedItems.push({
|
|
@@ -17143,16 +18173,19 @@ var init_backups = __esmMin((() => {
|
|
|
17143
18173
|
reasonKey: "settings.restore.reasonInvalidSettings"
|
|
17144
18174
|
});
|
|
17145
18175
|
}
|
|
17146
|
-
if (parsedGlobal !== null &&
|
|
17147
|
-
|
|
17148
|
-
|
|
17149
|
-
|
|
17150
|
-
|
|
17151
|
-
|
|
17152
|
-
|
|
17153
|
-
|
|
17154
|
-
|
|
17155
|
-
|
|
18176
|
+
if (parsedGlobal !== null && liftedGlobal !== null) {
|
|
18177
|
+
const globalText = `${JSON.stringify(liftedGlobal, null, 2)}\n`;
|
|
18178
|
+
addItem({
|
|
18179
|
+
id: "global:settings",
|
|
18180
|
+
label: "Global settings",
|
|
18181
|
+
labelKey: "settings.backup.entryGlobalSettings",
|
|
18182
|
+
kind: "settings",
|
|
18183
|
+
restorable: true,
|
|
18184
|
+
note: null
|
|
18185
|
+
}, () => {
|
|
18186
|
+
writeFileAtomic(sources.globalSettingsPath, globalText);
|
|
18187
|
+
}, ["config"]);
|
|
18188
|
+
}
|
|
17156
18189
|
const globalSecrets = readText(path.join(staging, "global", "secrets.json"));
|
|
17157
18190
|
if (globalSecrets !== null) {
|
|
17158
18191
|
const globalSecretKeys = presentSecretKeys(parseSecrets(globalSecrets));
|
|
@@ -17242,23 +18275,26 @@ var init_backups = __esmMin((() => {
|
|
|
17242
18275
|
}
|
|
17243
18276
|
if (!sources.workspaces.some((candidate) => candidate.id === id)) createdWorkspaces.set(id, workspace);
|
|
17244
18277
|
if (settings !== null) {
|
|
17245
|
-
|
|
17246
|
-
|
|
17247
|
-
|
|
17248
|
-
|
|
17249
|
-
|
|
17250
|
-
|
|
17251
|
-
|
|
17252
|
-
|
|
17253
|
-
|
|
17254
|
-
|
|
17255
|
-
|
|
17256
|
-
|
|
17257
|
-
|
|
17258
|
-
|
|
17259
|
-
|
|
17260
|
-
|
|
17261
|
-
|
|
18278
|
+
const liftedSettings = readableWorkspaceSettings(settings);
|
|
18279
|
+
if (liftedSettings !== null) {
|
|
18280
|
+
const settingsText = `${JSON.stringify(liftedSettings, null, 2)}\n`;
|
|
18281
|
+
addItem({
|
|
18282
|
+
id: `workspace:${id}:settings`,
|
|
18283
|
+
label: `${workspace.label}: Settings`,
|
|
18284
|
+
labelKey: "settings.backup.restoreItemLabel",
|
|
18285
|
+
labelParams: {
|
|
18286
|
+
workspace: workspace.label,
|
|
18287
|
+
item: "settings"
|
|
18288
|
+
},
|
|
18289
|
+
kind: "settings",
|
|
18290
|
+
workspaceId: id,
|
|
18291
|
+
restorable: true,
|
|
18292
|
+
note: null
|
|
18293
|
+
}, () => {
|
|
18294
|
+
fs.mkdirSync(path.dirname(workspace.settingsPath), { recursive: true });
|
|
18295
|
+
writeFileAtomic(workspace.settingsPath, settingsText);
|
|
18296
|
+
});
|
|
18297
|
+
} else {
|
|
17262
18298
|
plan.skipped.push(`${workspace.label}: Settings (the archive's settings are not valid)`);
|
|
17263
18299
|
plan.skippedItems.push({
|
|
17264
18300
|
label: `${workspace.label}: Settings`,
|
|
@@ -17273,7 +18309,9 @@ var init_backups = __esmMin((() => {
|
|
|
17273
18309
|
}
|
|
17274
18310
|
if (servers !== null) {
|
|
17275
18311
|
const parsed = readableServersFile(servers);
|
|
17276
|
-
|
|
18312
|
+
const liftedServers = parsed === null ? null : liftArchived(JSON.parse(servers));
|
|
18313
|
+
if (parsed !== null && liftedServers !== null) {
|
|
18314
|
+
const serversText = `${JSON.stringify(liftedServers, null, 2)}\n`;
|
|
17277
18315
|
archivedServers.set(id, parsed);
|
|
17278
18316
|
addItem({
|
|
17279
18317
|
id: `workspace:${id}:servers`,
|
|
@@ -17289,7 +18327,7 @@ var init_backups = __esmMin((() => {
|
|
|
17289
18327
|
note: null
|
|
17290
18328
|
}, () => {
|
|
17291
18329
|
fs.mkdirSync(path.dirname(workspace.serversPath), { recursive: true });
|
|
17292
|
-
writeFileAtomic(workspace.serversPath,
|
|
18330
|
+
writeFileAtomic(workspace.serversPath, serversText);
|
|
17293
18331
|
});
|
|
17294
18332
|
} else {
|
|
17295
18333
|
plan.skipped.push(`${workspace.label}: Servers (the archive's servers are not valid)`);
|
|
@@ -17462,9 +18500,8 @@ var init_backups = __esmMin((() => {
|
|
|
17462
18500
|
}, aliases);
|
|
17463
18501
|
}
|
|
17464
18502
|
if (parsedGlobal !== null && actions.has("global:settings") && settingsText !== null) {
|
|
17465
|
-
const
|
|
17466
|
-
|
|
17467
|
-
plan.restartRequired = JSON.stringify(parsedGlobal.control) !== JSON.stringify(current?.control ?? null);
|
|
18503
|
+
const current = readableGlobalSettings(readText(sources.globalSettingsPath));
|
|
18504
|
+
plan.restartRequired = JSON.stringify(parsedGlobal.control) !== JSON.stringify(current === null ? null : parseGlobalSettings(current).config?.control ?? null);
|
|
17468
18505
|
}
|
|
17469
18506
|
if (!options.confirm) {
|
|
17470
18507
|
plan.applied = [...actions.keys()].map((id) => labelOf(plan, id));
|
|
@@ -18236,30 +19273,60 @@ function getPageSize() {
|
|
|
18236
19273
|
}
|
|
18237
19274
|
}
|
|
18238
19275
|
/**
|
|
18239
|
-
*
|
|
18240
|
-
*
|
|
18241
|
-
*
|
|
19276
|
+
* The CPU temperature, or null when this machine names no CPU sensor.
|
|
19277
|
+
*
|
|
19278
|
+
* One tier is chosen and the maximum is taken only *within* it — a CPU package reports several
|
|
19279
|
+
* dies, so the hottest die is the reading, but a disk's temperature is not a second opinion.
|
|
19280
|
+
*/
|
|
19281
|
+
function pickCpuTemperature(sensors) {
|
|
19282
|
+
for (const pattern of [CPU_SENSOR, ACPI_SENSOR]) {
|
|
19283
|
+
const tier = sensors.filter((sensor) => pattern.test(sensor.name)).map((sensor) => sensor.celsius);
|
|
19284
|
+
if (tier.length > 0) return Math.max(...tier);
|
|
19285
|
+
}
|
|
19286
|
+
return null;
|
|
19287
|
+
}
|
|
19288
|
+
/**
|
|
19289
|
+
* Best-effort CPU temperature from Linux thermal zones / hwmon. macOS and Windows expose no
|
|
19290
|
+
* unprivileged sensor, so those platforms report null and both UIs read "n/a" — a WSL2 guest has
|
|
19291
|
+
* none either, and the Windows host's `MSAcpi_ThermalZoneTemperature` answers a constant 20 °C
|
|
19292
|
+
* regardless of load, so reaching across for it would be a fabricated number rather than a reading.
|
|
18242
19293
|
*/
|
|
18243
19294
|
function cpuTemperature() {
|
|
18244
|
-
const
|
|
18245
|
-
|
|
19295
|
+
const sensors = [];
|
|
19296
|
+
/** `name` is the sensor's own label; absent means the file could not be read, so skip it. */
|
|
19297
|
+
const inspect = (file, name) => {
|
|
18246
19298
|
try {
|
|
18247
19299
|
const raw = Number.parseInt(fs.readFileSync(file, "utf8").trim(), 10);
|
|
18248
19300
|
if (!Number.isFinite(raw)) return;
|
|
18249
19301
|
const celsius = raw / 1e3;
|
|
18250
|
-
if (celsius > 0 && celsius < 150)
|
|
19302
|
+
if (celsius > 0 && celsius < 150) sensors.push({
|
|
19303
|
+
name,
|
|
19304
|
+
celsius
|
|
19305
|
+
});
|
|
18251
19306
|
} catch {}
|
|
18252
19307
|
};
|
|
18253
19308
|
try {
|
|
18254
|
-
for (const zone of fs.readdirSync("/sys/class/thermal"))
|
|
19309
|
+
for (const zone of fs.readdirSync("/sys/class/thermal")) {
|
|
19310
|
+
if (!zone.startsWith("thermal_zone")) continue;
|
|
19311
|
+
const dir = path.join("/sys/class/thermal", zone);
|
|
19312
|
+
let type = "";
|
|
19313
|
+
try {
|
|
19314
|
+
type = fs.readFileSync(path.join(dir, "type"), "utf8").trim();
|
|
19315
|
+
} catch {}
|
|
19316
|
+
inspect(path.join(dir, "temp"), type);
|
|
19317
|
+
}
|
|
18255
19318
|
} catch {}
|
|
18256
19319
|
try {
|
|
18257
19320
|
for (const hwmon of fs.readdirSync("/sys/class/hwmon")) {
|
|
18258
19321
|
const dir = path.join("/sys/class/hwmon", hwmon);
|
|
18259
|
-
|
|
19322
|
+
let chip = "";
|
|
19323
|
+
try {
|
|
19324
|
+
chip = fs.readFileSync(path.join(dir, "name"), "utf8").trim();
|
|
19325
|
+
} catch {}
|
|
19326
|
+
for (const entry of fs.readdirSync(dir)) if (/^temp\d+_input$/.test(entry)) inspect(path.join(dir, entry), chip);
|
|
18260
19327
|
}
|
|
18261
19328
|
} catch {}
|
|
18262
|
-
return
|
|
19329
|
+
return pickCpuTemperature(sensors);
|
|
18263
19330
|
}
|
|
18264
19331
|
async function diskUsage(target) {
|
|
18265
19332
|
try {
|
|
@@ -18277,6 +19344,51 @@ async function diskUsage(target) {
|
|
|
18277
19344
|
}
|
|
18278
19345
|
}
|
|
18279
19346
|
/**
|
|
19347
|
+
* Run the configured temperature command and parse one number out of its stdout.
|
|
19348
|
+
*
|
|
19349
|
+
* This is the escape hatch for a machine whose kernel exposes no sensor — a WSL2 guest above all,
|
|
19350
|
+
* where `/sys/class/hwmon` is empty and the Windows ACPI zone answers a constant 20 °C. The user
|
|
19351
|
+
* supplies the command, so it is spawned without a shell and given a timeout: a hung helper must
|
|
19352
|
+
* not stall a sample that the whole panel's tick waits on.
|
|
19353
|
+
*
|
|
19354
|
+
* Only a whole-number or decimal reading in a plausible range is accepted. Anything else answers
|
|
19355
|
+
* null, which the UI reads as `n/a` — never a guess, for the same reason a missing sensor is not
|
|
19356
|
+
* published as 0.
|
|
19357
|
+
*/
|
|
19358
|
+
async function temperatureFromCommand(command, timeoutMs) {
|
|
19359
|
+
const trimmed = command.trim();
|
|
19360
|
+
if (trimmed.length === 0) return null;
|
|
19361
|
+
try {
|
|
19362
|
+
const { stdout } = await execFileAsync(trimmed, {
|
|
19363
|
+
timeout: timeoutMs,
|
|
19364
|
+
windowsHide: true,
|
|
19365
|
+
maxBuffer: 65536,
|
|
19366
|
+
shell: true
|
|
19367
|
+
});
|
|
19368
|
+
return parseTemperature(stdout);
|
|
19369
|
+
} catch {
|
|
19370
|
+
return null;
|
|
19371
|
+
}
|
|
19372
|
+
}
|
|
19373
|
+
/** The first plausible °C reading in a command's output, or null. Exported for its own tests. */
|
|
19374
|
+
function parseTemperature(output) {
|
|
19375
|
+
const match = /-?\d+(?:\.\d+)?/.exec(output);
|
|
19376
|
+
if (match === null) return null;
|
|
19377
|
+
const celsius = Number.parseFloat(match[0]);
|
|
19378
|
+
if (!Number.isFinite(celsius) || celsius <= 0 || celsius >= 150) return null;
|
|
19379
|
+
return celsius;
|
|
19380
|
+
}
|
|
19381
|
+
/**
|
|
19382
|
+
* The temperature to report: the configured command when there is one, else the built-in probe.
|
|
19383
|
+
*
|
|
19384
|
+
* The command wins even on a platform whose probe works, because a person who set it did so to
|
|
19385
|
+
* override what the panel found.
|
|
19386
|
+
*/
|
|
19387
|
+
async function readTemperature(config) {
|
|
19388
|
+
if (config.tempCommand.trim().length > 0) return temperatureFromCommand(config.tempCommand, config.tempCommandTimeoutMs);
|
|
19389
|
+
return cpuTemperature();
|
|
19390
|
+
}
|
|
19391
|
+
/**
|
|
18280
19392
|
* Samples the machine itself: the failures a home server actually dies from are
|
|
18281
19393
|
* a full disk, exhausted memory or a runaway load — none of which a port probe
|
|
18282
19394
|
* can see.
|
|
@@ -18290,7 +19402,7 @@ async function sampleHost(config, resolvePath) {
|
|
|
18290
19402
|
previousCpuTimes = cpuTimes;
|
|
18291
19403
|
if (process.platform === "win32") loadAvg.fill(0);
|
|
18292
19404
|
if (memory.swapUsedPercent === 0 && process.platform !== "linux") memory.swapUsedPercent = await swapUsedPercent();
|
|
18293
|
-
const tempCelsius =
|
|
19405
|
+
const tempCelsius = await readTemperature(config);
|
|
18294
19406
|
const disks = (await Promise.all(config.diskPaths.map((entry) => diskUsage(resolvePath(entry))))).filter((disk) => disk !== null);
|
|
18295
19407
|
const alerts = [];
|
|
18296
19408
|
for (const disk of disks) if (config.diskUsedPercent > 0 && disk.usedPercent >= config.diskUsedPercent) alerts.push(`disk ${disk.path} is ${disk.usedPercent.toFixed(1)}% full`);
|
|
@@ -18332,12 +19444,14 @@ function emptyHostView(config) {
|
|
|
18332
19444
|
sampledAt: null
|
|
18333
19445
|
};
|
|
18334
19446
|
}
|
|
18335
|
-
var execFileAsync, SWAP_CACHE_MS, swapCache, previousCpuTimes;
|
|
19447
|
+
var execFileAsync, SWAP_CACHE_MS, swapCache, previousCpuTimes, CPU_SENSOR, ACPI_SENSOR;
|
|
18336
19448
|
var init_host = __esmMin((() => {
|
|
18337
19449
|
execFileAsync = promisify(execFile);
|
|
18338
19450
|
SWAP_CACHE_MS = 6e4;
|
|
18339
19451
|
swapCache = null;
|
|
18340
19452
|
previousCpuTimes = null;
|
|
19453
|
+
CPU_SENSOR = /coretemp|k10temp|zenpower|cpu_thermal|cpu-thermal|x86_pkg_temp|soc_thermal|package/i;
|
|
19454
|
+
ACPI_SENSOR = /acpitz|acpi/i;
|
|
18341
19455
|
}));
|
|
18342
19456
|
//#endregion
|
|
18343
19457
|
//#region src/services/host-monitor.ts
|
|
@@ -18980,13 +20094,13 @@ var init_log_files = __esmMin((() => {
|
|
|
18980
20094
|
sizeBytes,
|
|
18981
20095
|
files
|
|
18982
20096
|
};
|
|
18983
|
-
for (const file of this.
|
|
20097
|
+
for (const file of this.retained(serverId)) try {
|
|
18984
20098
|
const stats = fs.statSync(file);
|
|
18985
20099
|
files.push({
|
|
18986
20100
|
name: path.basename(file),
|
|
18987
20101
|
sizeBytes: stats.size
|
|
18988
20102
|
});
|
|
18989
|
-
|
|
20103
|
+
sizeBytes += stats.size;
|
|
18990
20104
|
} catch {}
|
|
18991
20105
|
return {
|
|
18992
20106
|
enabled: config.persist,
|
|
@@ -18995,15 +20109,21 @@ var init_log_files = __esmMin((() => {
|
|
|
18995
20109
|
};
|
|
18996
20110
|
}
|
|
18997
20111
|
/**
|
|
18998
|
-
* Reads the last `tail` lines, newest file first, padding from
|
|
20112
|
+
* Reads the last `tail` lines, newest file first, padding from the rotations behind it.
|
|
18999
20113
|
*
|
|
19000
20114
|
* With `persist` off there is nothing this panel is willing to serve, even though a
|
|
19001
20115
|
* persistent entry's nanny still writes its file: that file is the log's transport —
|
|
19002
20116
|
* there is no pipe to carry it — and `persist` decides what counts as history.
|
|
20117
|
+
*
|
|
20118
|
+
* Every *retained* file is a source, not just `.1`: `keep` is the number of rotations the
|
|
20119
|
+
* person asked to keep, so a 5000-line window over a 10 MB rotation could not be filled by
|
|
20120
|
+
* the current file and `.1` alone. It read two of eleven files and returned "no matches" for
|
|
20121
|
+
* a line that was on disk — a search that answers "nothing found" while the log holds the
|
|
20122
|
+
* match is worse than a shorter window.
|
|
19003
20123
|
*/
|
|
19004
20124
|
readTail(serverId, tail) {
|
|
19005
20125
|
if (!this.getConfig().persist) return [];
|
|
19006
|
-
const sources =
|
|
20126
|
+
const sources = this.retained(serverId);
|
|
19007
20127
|
const lines = [];
|
|
19008
20128
|
for (const file of sources) {
|
|
19009
20129
|
if (lines.length >= tail) break;
|
|
@@ -19014,10 +20134,32 @@ var init_log_files = __esmMin((() => {
|
|
|
19014
20134
|
}
|
|
19015
20135
|
clear(serverId) {
|
|
19016
20136
|
this.pending.delete(serverId);
|
|
19017
|
-
for (const file of this.
|
|
20137
|
+
for (const file of this.ownedFiles(serverId)) try {
|
|
19018
20138
|
fs.rmSync(file, { force: true });
|
|
19019
20139
|
} catch {}
|
|
19020
20140
|
}
|
|
20141
|
+
/**
|
|
20142
|
+
* Drops rotations above the current `keep`, for every server, now.
|
|
20143
|
+
*
|
|
20144
|
+
* `rotate` prunes too, but it only runs when a file fills — which on a quiet entry can be days
|
|
20145
|
+
* after the person lowered the ceiling. A retention setting that takes effect "eventually, once
|
|
20146
|
+
* the server is chatty enough" is not the promise the page makes, so the settings save calls
|
|
20147
|
+
* this directly.
|
|
20148
|
+
*/
|
|
20149
|
+
prune() {
|
|
20150
|
+
let names;
|
|
20151
|
+
try {
|
|
20152
|
+
names = fs.readdirSync(this.dir);
|
|
20153
|
+
} catch {
|
|
20154
|
+
return;
|
|
20155
|
+
}
|
|
20156
|
+
const ids = /* @__PURE__ */ new Set();
|
|
20157
|
+
for (const name of names) {
|
|
20158
|
+
const dot = name.indexOf(".log");
|
|
20159
|
+
if (dot > 0 && (name.length === dot + 4 || name.startsWith(".log.", dot))) ids.add(name.slice(0, dot));
|
|
20160
|
+
}
|
|
20161
|
+
for (const id of ids) this.pruneServer(id);
|
|
20162
|
+
}
|
|
19021
20163
|
dispose() {
|
|
19022
20164
|
this.closed = true;
|
|
19023
20165
|
if (this.timer !== null) clearTimeout(this.timer);
|
|
@@ -19047,8 +20189,28 @@ var init_log_files = __esmMin((() => {
|
|
|
19047
20189
|
}
|
|
19048
20190
|
commit();
|
|
19049
20191
|
}
|
|
20192
|
+
/**
|
|
20193
|
+
* Drops this id's rotations numbered above `keep`.
|
|
20194
|
+
*
|
|
20195
|
+
* They are left over from a higher ceiling (or an older release). Renaming up only ever shifts
|
|
20196
|
+
* them further out of reach, so they have to be removed outright: a retention setting is a
|
|
20197
|
+
* promise about the directory, not about a rename loop.
|
|
20198
|
+
*/
|
|
20199
|
+
pruneServer(serverId) {
|
|
20200
|
+
const { keep } = this.getConfig();
|
|
20201
|
+
const current = this.currentPath(serverId);
|
|
20202
|
+
for (const file of this.ownedFiles(serverId)) {
|
|
20203
|
+
if (file === current) continue;
|
|
20204
|
+
const index = Number(file.slice(current.length + 1));
|
|
20205
|
+
if (!Number.isInteger(index) || index <= keep) continue;
|
|
20206
|
+
try {
|
|
20207
|
+
fs.rmSync(file, { force: true });
|
|
20208
|
+
} catch {}
|
|
20209
|
+
}
|
|
20210
|
+
}
|
|
19050
20211
|
rotate(serverId) {
|
|
19051
20212
|
const { keep } = this.getConfig();
|
|
20213
|
+
this.pruneServer(serverId);
|
|
19052
20214
|
for (let index = keep - 1; index >= 1; index--) {
|
|
19053
20215
|
const from = this.rotatedPath(serverId, index);
|
|
19054
20216
|
if (!fs.existsSync(from)) continue;
|
|
@@ -19102,11 +20264,43 @@ var init_log_files = __esmMin((() => {
|
|
|
19102
20264
|
rotatedPath(serverId, index) {
|
|
19103
20265
|
return path.join(this.dir, `${serverId}.log.${index}`);
|
|
19104
20266
|
}
|
|
19105
|
-
|
|
20267
|
+
/**
|
|
20268
|
+
* Every file this id owns on disk, newest first, found by reading the directory.
|
|
20269
|
+
*
|
|
20270
|
+
* The count comes from the directory rather than from `keep` because the two disagree the
|
|
20271
|
+
* moment a person lowers it: `rotate` only renames *up* to the new ceiling, so it never removes
|
|
20272
|
+
* the rotations numbered above it. Those files stayed, were invisible to `info()`, were served
|
|
20273
|
+
* by no reader, and survived a `clear` — growth the retention setting promised to bound, in
|
|
20274
|
+
* files nothing would ever show. Reading the directory is also what makes them prunable.
|
|
20275
|
+
*/
|
|
20276
|
+
ownedFiles(serverId) {
|
|
20277
|
+
const current = this.currentPath(serverId);
|
|
20278
|
+
const prefix = `${serverId}.log.`;
|
|
20279
|
+
let names;
|
|
20280
|
+
try {
|
|
20281
|
+
names = fs.readdirSync(this.dir);
|
|
20282
|
+
} catch {
|
|
20283
|
+
return fs.existsSync(current) ? [current] : [];
|
|
20284
|
+
}
|
|
20285
|
+
const rotated = names.filter((name) => name.startsWith(prefix)).map((name) => ({
|
|
20286
|
+
name,
|
|
20287
|
+
index: Number(name.slice(prefix.length))
|
|
20288
|
+
})).filter((entry) => Number.isInteger(entry.index) && entry.index >= 1).sort((a, b) => a.index - b.index).map((entry) => path.join(this.dir, entry.name));
|
|
20289
|
+
return fs.existsSync(current) ? [current, ...rotated] : rotated;
|
|
20290
|
+
}
|
|
20291
|
+
/**
|
|
20292
|
+
* The files `keep` still covers, newest first — what `info` lists and what a tail may read.
|
|
20293
|
+
*
|
|
20294
|
+
* The current file is always first and never counted against `keep`, which is what the UI
|
|
20295
|
+
* promises ("before rolling to .1, .2, …").
|
|
20296
|
+
*/
|
|
20297
|
+
retained(serverId) {
|
|
19106
20298
|
const { keep } = this.getConfig();
|
|
19107
|
-
const
|
|
19108
|
-
|
|
19109
|
-
|
|
20299
|
+
const owned = this.ownedFiles(serverId);
|
|
20300
|
+
if (owned.length === 0) return [];
|
|
20301
|
+
const [current, ...rotated] = owned;
|
|
20302
|
+
const covered = rotated.slice(0, keep);
|
|
20303
|
+
return current === void 0 ? covered : [current, ...covered];
|
|
19110
20304
|
}
|
|
19111
20305
|
};
|
|
19112
20306
|
}));
|
|
@@ -19250,7 +20444,28 @@ var init_notifications = __esmMin((() => {
|
|
|
19250
20444
|
}
|
|
19251
20445
|
/** Starts the cooldown window for every destination about to be asked to send. */
|
|
19252
20446
|
markSent(event, now = Date.now()) {
|
|
19253
|
-
for (const target of this.targetsFor(event, now)) this.
|
|
20447
|
+
for (const target of this.targetsFor(event, now)) this.armCooldown(target, event, now);
|
|
20448
|
+
}
|
|
20449
|
+
/** One destination's window, returning the deadline it set so a failed send can undo it. */
|
|
20450
|
+
armCooldown(target, event, now = Date.now()) {
|
|
20451
|
+
const until = now + this.effectivePolicy(target).cooldownMs;
|
|
20452
|
+
this.cooldowns.set(this.cooldownKey(target, event), until);
|
|
20453
|
+
return until;
|
|
20454
|
+
}
|
|
20455
|
+
/**
|
|
20456
|
+
* Gives back the window a **failed** send took.
|
|
20457
|
+
*
|
|
20458
|
+
* The window exists to collapse a flapping server into one message, so it is armed before the
|
|
20459
|
+
* send rather than after: two events already in flight must not both go out. But a send that
|
|
20460
|
+
* never arrived has told nobody anything — measured on the built panel, a crash alert sent while
|
|
20461
|
+
* the receiver was down recorded `fetch failed`, and the next two crashes inside the 5-minute
|
|
20462
|
+
* window were silenced by it, so the one alert that would have reached a working receiver was
|
|
20463
|
+
* the one the outage took. Undo only the deadline this send set: a concurrent dispatch may have
|
|
20464
|
+
* armed a later one, and clearing that would reopen the flood the window is for.
|
|
20465
|
+
*/
|
|
20466
|
+
releaseCooldown(target, event, armed) {
|
|
20467
|
+
const key = this.cooldownKey(target, event);
|
|
20468
|
+
if (this.cooldowns.get(key) === armed) this.cooldowns.delete(key);
|
|
19254
20469
|
}
|
|
19255
20470
|
/** Fire-and-forget by design: supervision must never wait on a chat or webhook API. */
|
|
19256
20471
|
notify(event) {
|
|
@@ -19261,13 +20476,13 @@ var init_notifications = __esmMin((() => {
|
|
|
19261
20476
|
async dispatch(event) {
|
|
19262
20477
|
const targets = this.targetsFor(event);
|
|
19263
20478
|
if (targets.length === 0) return false;
|
|
19264
|
-
this.
|
|
20479
|
+
const armed = new Map(targets.map((target) => [target.id, this.armCooldown(target, event)]));
|
|
19265
20480
|
const title = TITLE[event.reason];
|
|
19266
20481
|
const message = `${event.label} (${event.serverId}) ${REASON_LABEL[event.reason]}\n${event.detail}`;
|
|
19267
|
-
return (await Promise.all(targets.map((target) => this.deliver(target, title, message, event)))).includes(true);
|
|
20482
|
+
return (await Promise.all(targets.map((target) => this.deliver(target, title, message, event, armed.get(target.id) ?? 0)))).includes(true);
|
|
19268
20483
|
}
|
|
19269
20484
|
/** One destination, one event. A throw is recorded against it and nothing else. */
|
|
19270
|
-
async deliver(target, title, message, event) {
|
|
20485
|
+
async deliver(target, title, message, event, armed) {
|
|
19271
20486
|
try {
|
|
19272
20487
|
const result = target.kind === "telegram" ? await this.sendTelegram(target, title, message) : await sendWebhook(target, {
|
|
19273
20488
|
title,
|
|
@@ -19277,9 +20492,11 @@ var init_notifications = __esmMin((() => {
|
|
|
19277
20492
|
label: event.label
|
|
19278
20493
|
});
|
|
19279
20494
|
this.remember(target.id, result.ok ? "sent" : result.error ?? "send failed");
|
|
20495
|
+
if (!result.ok) this.releaseCooldown(target, event, armed);
|
|
19280
20496
|
return result.ok;
|
|
19281
20497
|
} catch (error) {
|
|
19282
20498
|
this.remember(target.id, errorMessage(error));
|
|
20499
|
+
this.releaseCooldown(target, event, armed);
|
|
19283
20500
|
return false;
|
|
19284
20501
|
}
|
|
19285
20502
|
}
|
|
@@ -19736,11 +20953,12 @@ var init_panel = __esmMin((() => {
|
|
|
19736
20953
|
}
|
|
19737
20954
|
}
|
|
19738
20955
|
}
|
|
19739
|
-
|
|
20956
|
+
/** `withPersistent` reaches every workspace's supervisor: a `down` is host-wide. */
|
|
20957
|
+
async dispose(options = {}) {
|
|
19740
20958
|
this.disposed = true;
|
|
19741
20959
|
clearInterval(this.timer);
|
|
19742
20960
|
this.options.backups.dispose();
|
|
19743
|
-
await Promise.all(this.workspaces().map((runtime) => runtime.supervisor.dispose()));
|
|
20961
|
+
await Promise.all(this.workspaces().map((runtime) => runtime.supervisor.dispose(options)));
|
|
19744
20962
|
for (const runtime of this.workspaces()) this.disposeRuntime(runtime);
|
|
19745
20963
|
}
|
|
19746
20964
|
createRuntime(workspace) {
|
|
@@ -20809,7 +22027,7 @@ async function runControlPlane(options) {
|
|
|
20809
22027
|
}
|
|
20810
22028
|
}
|
|
20811
22029
|
let shuttingDown = false;
|
|
20812
|
-
const shutdown = async (reason) => {
|
|
22030
|
+
const shutdown = async (reason, options = {}) => {
|
|
20813
22031
|
if (shuttingDown) return;
|
|
20814
22032
|
shuttingDown = true;
|
|
20815
22033
|
logger.info(`${reason} — stopping ${panel.serverViews().length} server(s) across ${panel.workspaces().length} workspace(s)`);
|
|
@@ -20817,7 +22035,7 @@ async function runControlPlane(options) {
|
|
|
20817
22035
|
clearRuntime();
|
|
20818
22036
|
auth.dispose();
|
|
20819
22037
|
proxy.dispose();
|
|
20820
|
-
await panel.dispose();
|
|
22038
|
+
await panel.dispose(options);
|
|
20821
22039
|
await controlServer.close(true);
|
|
20822
22040
|
process.exit(0);
|
|
20823
22041
|
};
|
|
@@ -20839,7 +22057,7 @@ async function runControlPlane(options) {
|
|
|
20839
22057
|
}
|
|
20840
22058
|
}),
|
|
20841
22059
|
runtimeToken: token,
|
|
20842
|
-
onShutdown: () => shutdown("shutdown requested locally")
|
|
22060
|
+
onShutdown: (options) => shutdown("shutdown requested locally", options)
|
|
20843
22061
|
});
|
|
20844
22062
|
await controlServer.start();
|
|
20845
22063
|
await backups.warm();
|
|
@@ -21029,6 +22247,26 @@ async function runUp(flags, entry) {
|
|
|
21029
22247
|
process.stdout.write(` ${dim(`project ${runtime.projectDir}`)}\n`);
|
|
21030
22248
|
process.stdout.write(` ${dim(`state ${runtime.dataRoot}`)}\n`);
|
|
21031
22249
|
process.stdout.write(` ${dim(`log ${runtime.logFile}`)}\n`);
|
|
22250
|
+
await warnIfWslTemperatureMissing();
|
|
22251
|
+
}
|
|
22252
|
+
/**
|
|
22253
|
+
* Say once, on `up`, that this box cannot read its own temperature and that it can be fixed.
|
|
22254
|
+
*
|
|
22255
|
+
* A WSL2 guest has no sensor the kernel exposes, so the Host vitals tile reads `n/a` and looks
|
|
22256
|
+
* broken. Nothing tells a person why — the settings page has the button, but only if they go
|
|
22257
|
+
* looking. This is the one line that turns "the panel is broken" into "run one command".
|
|
22258
|
+
*
|
|
22259
|
+
* Silent when a command is already configured, and on any platform that is not WSL.
|
|
22260
|
+
*/
|
|
22261
|
+
async function warnIfWslTemperatureMissing() {
|
|
22262
|
+
const { isWsl } = await Promise.resolve().then(() => (init_wsl_temperature$1(), wsl_temperature_exports));
|
|
22263
|
+
if (!isWsl()) return;
|
|
22264
|
+
const { GlobalSettingsStore } = await Promise.resolve().then(() => (init_settings$1(), settings_exports));
|
|
22265
|
+
const { globalSettingsPath } = await Promise.resolve().then(() => (init_paths(), paths_exports));
|
|
22266
|
+
const store = new GlobalSettingsStore(globalSettingsPath);
|
|
22267
|
+
store.load();
|
|
22268
|
+
if (store.host.tempCommand.trim().length > 0) return;
|
|
22269
|
+
process.stdout.write(`${paint("33", "note")} WSL2 detected: the guest exposes no CPU temperature, so Host vitals shows n/a\n ${dim(`set it up with ${invocation()} setup-temp --wsl`)}\n`);
|
|
21032
22270
|
}
|
|
21033
22271
|
async function waitForStartup(child, timeoutMs = 2e4) {
|
|
21034
22272
|
const { readRuntime } = await Promise.resolve().then(() => (init_daemon(), daemon_exports));
|
|
@@ -21088,24 +22326,142 @@ var init_up = __esmMin((() => {
|
|
|
21088
22326
|
};
|
|
21089
22327
|
}));
|
|
21090
22328
|
//#endregion
|
|
22329
|
+
//#region src/providers/nanny-sweep.ts
|
|
22330
|
+
var nanny_sweep_exports = /* @__PURE__ */ __exportAll({
|
|
22331
|
+
livePersistentEntries: () => livePersistentEntries,
|
|
22332
|
+
stopPersistentEntries: () => stopPersistentEntries
|
|
22333
|
+
});
|
|
22334
|
+
/**
|
|
22335
|
+
* Every workspace's state directory.
|
|
22336
|
+
*
|
|
22337
|
+
* Read here rather than through `workspaceStateDir()`, which resolves from *this* process's
|
|
22338
|
+
* `HHOSTED_HOME`: a caller passing `--home` elsewhere would otherwise sweep another host's
|
|
22339
|
+
* state — the mistake `backup-offline` already paid for.
|
|
22340
|
+
*/
|
|
22341
|
+
function stateDirs(hhDir) {
|
|
22342
|
+
try {
|
|
22343
|
+
return fs.readdirSync(hhDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).filter((id) => /^[a-z0-9][a-z0-9_-]*$/.test(id)).map((workspaceId) => ({
|
|
22344
|
+
workspaceId,
|
|
22345
|
+
dir: path.join(hhDir, workspaceId, ".state")
|
|
22346
|
+
}));
|
|
22347
|
+
} catch {
|
|
22348
|
+
return [];
|
|
22349
|
+
}
|
|
22350
|
+
}
|
|
22351
|
+
/**
|
|
22352
|
+
* The persistent entries whose nanny is running right now.
|
|
22353
|
+
*
|
|
22354
|
+
* A `<id>.run.json` file is a *non-persistent* child's own record and carries no nanny, so it
|
|
22355
|
+
* is skipped by suffix — the same distinction `backup-offline` relies on. `nannyIsAlive` is
|
|
22356
|
+
* the identity check: a live pid alone proves nothing, since pids are reused.
|
|
22357
|
+
*/
|
|
22358
|
+
async function livePersistentEntries(hhDir) {
|
|
22359
|
+
const found = [];
|
|
22360
|
+
for (const { workspaceId, dir } of stateDirs(hhDir)) {
|
|
22361
|
+
let names;
|
|
22362
|
+
try {
|
|
22363
|
+
names = fs.readdirSync(dir);
|
|
22364
|
+
} catch {
|
|
22365
|
+
continue;
|
|
22366
|
+
}
|
|
22367
|
+
for (const name of names) {
|
|
22368
|
+
if (!name.endsWith(".json") || name.endsWith(".spec.json")) continue;
|
|
22369
|
+
const serverId = name.slice(0, -5);
|
|
22370
|
+
const state = readNannyState(path.join(dir, name));
|
|
22371
|
+
if (state === null || state.serverId !== serverId) continue;
|
|
22372
|
+
if (await nannyIsAlive(state, serverId)) found.push({
|
|
22373
|
+
workspaceId,
|
|
22374
|
+
serverId,
|
|
22375
|
+
state,
|
|
22376
|
+
dir
|
|
22377
|
+
});
|
|
22378
|
+
}
|
|
22379
|
+
}
|
|
22380
|
+
return found;
|
|
22381
|
+
}
|
|
22382
|
+
/**
|
|
22383
|
+
* Stops these entries and consumes the record of each one that ended.
|
|
22384
|
+
*
|
|
22385
|
+
* `stopFor` is the entry's own `stop` config, read by the caller from the workspace that
|
|
22386
|
+
* declares it: the grace period here has to be the one the entry asked for, or a stop that
|
|
22387
|
+
* was still finishing its shutdown reads as a failure and escalates to `SIGKILL`.
|
|
22388
|
+
*/
|
|
22389
|
+
async function stopPersistentEntries(handles, options = {}) {
|
|
22390
|
+
const results = [];
|
|
22391
|
+
const terminate = options.terminate ?? terminatePid;
|
|
22392
|
+
const defaultStop = stopSchema.assert({});
|
|
22393
|
+
for (const handle of handles) {
|
|
22394
|
+
const stop = options.stopFor?.(handle) ?? defaultStop;
|
|
22395
|
+
const { state, dir, serverId } = handle;
|
|
22396
|
+
const nanny = await terminate(state.nannyPid, {
|
|
22397
|
+
signal: stop.signal,
|
|
22398
|
+
killGroup: stop.killGroup,
|
|
22399
|
+
graceMs: stop.graceMs
|
|
22400
|
+
});
|
|
22401
|
+
if (isProcessAlive(state.nannyPid)) {
|
|
22402
|
+
results.push({
|
|
22403
|
+
handle,
|
|
22404
|
+
stopped: false,
|
|
22405
|
+
error: `pid ${state.nannyPid} survived the stop — its record is kept, so the next \`up\` can still find it`
|
|
22406
|
+
});
|
|
22407
|
+
continue;
|
|
22408
|
+
}
|
|
22409
|
+
if (!stop.killGroup && nanny === "force-killed" && state.childPid !== null && state.childPid > 0) await terminate(state.childPid, {
|
|
22410
|
+
signal: "SIGKILL",
|
|
22411
|
+
killGroup: false,
|
|
22412
|
+
graceMs: 0
|
|
22413
|
+
});
|
|
22414
|
+
consumeRecord(dir, serverId);
|
|
22415
|
+
results.push({
|
|
22416
|
+
handle,
|
|
22417
|
+
stopped: true,
|
|
22418
|
+
error: null
|
|
22419
|
+
});
|
|
22420
|
+
}
|
|
22421
|
+
return results;
|
|
22422
|
+
}
|
|
22423
|
+
/**
|
|
22424
|
+
* The record goes only once the process it names is gone: a state file kept past its process
|
|
22425
|
+
* is a false reattach waiting, which is what `resumePersistent` exists to prevent.
|
|
22426
|
+
*/
|
|
22427
|
+
function consumeRecord(dir, serverId) {
|
|
22428
|
+
for (const file of [nannyStatePath(dir, serverId), nannySpecPath(dir, serverId)]) try {
|
|
22429
|
+
fs.rmSync(file, { force: true });
|
|
22430
|
+
} catch {}
|
|
22431
|
+
}
|
|
22432
|
+
var init_nanny_sweep = __esmMin((() => {
|
|
22433
|
+
init_nanny$2();
|
|
22434
|
+
init_port();
|
|
22435
|
+
init_process();
|
|
22436
|
+
init_contracts();
|
|
22437
|
+
}));
|
|
22438
|
+
//#endregion
|
|
21091
22439
|
//#region src/cli/down.ts
|
|
21092
22440
|
var down_exports = /* @__PURE__ */ __exportAll({
|
|
21093
22441
|
downCommand: () => downCommand,
|
|
22442
|
+
exitCodeForStops: () => exitCodeForStops,
|
|
22443
|
+
livePersistents: () => livePersistents,
|
|
22444
|
+
persistentLabel: () => persistentLabel,
|
|
21094
22445
|
runDown: () => runDown
|
|
21095
22446
|
});
|
|
21096
|
-
|
|
21097
|
-
async function runDown() {
|
|
22447
|
+
async function runDown(options = {}) {
|
|
21098
22448
|
const { clearRuntime, isLiveLiveness, readRuntime, requestShutdown, runtimeLiveness } = await Promise.resolve().then(() => (init_daemon(), daemon_exports));
|
|
22449
|
+
const result = { stoppedPersistent: [] };
|
|
22450
|
+
const before = options.withPersistent === true ? await livePersistents() : [];
|
|
22451
|
+
const finish = async () => {
|
|
22452
|
+
result.stoppedPersistent.push(...await reportPersistent(options, before));
|
|
22453
|
+
return result;
|
|
22454
|
+
};
|
|
21099
22455
|
const runtime = readRuntime();
|
|
21100
22456
|
if (runtime === null) {
|
|
21101
22457
|
process.stdout.write("home-hosted is not running\n");
|
|
21102
|
-
return;
|
|
22458
|
+
return finish();
|
|
21103
22459
|
}
|
|
21104
22460
|
const liveness = await runtimeLiveness(runtime);
|
|
21105
22461
|
if (liveness === "gone") {
|
|
21106
22462
|
clearRuntime();
|
|
21107
22463
|
process.stdout.write(`home-hosted is not running (removed a stale run.json from home-hosted ${runtime.version})\n`);
|
|
21108
|
-
return;
|
|
22464
|
+
return finish();
|
|
21109
22465
|
}
|
|
21110
22466
|
/** What was stopped, and whether this CLI is a different release than it was. */
|
|
21111
22467
|
const reportStopped = (forced) => {
|
|
@@ -21116,59 +22472,141 @@ async function runDown() {
|
|
|
21116
22472
|
let answered = false;
|
|
21117
22473
|
if (isLiveLiveness(liveness)) {
|
|
21118
22474
|
process.stdout.write(`stopping pid ${runtime.pid}…\n`);
|
|
21119
|
-
answered = await requestShutdown(runtime);
|
|
22475
|
+
answered = await requestShutdown(runtime, 4e3, { withPersistent: options.withPersistent === true });
|
|
21120
22476
|
if (!answered) signal(runtime.pid, "SIGTERM");
|
|
21121
22477
|
} else {
|
|
21122
|
-
if (!await requestShutdown(runtime)) {
|
|
22478
|
+
if (!await requestShutdown(runtime, 4e3, { withPersistent: options.withPersistent === true })) {
|
|
21123
22479
|
process.stdout.write(`home-hosted is not running (the pid in run.json, ${runtime.pid}, belongs to another process — it was not signalled)\n`);
|
|
21124
|
-
return;
|
|
22480
|
+
return finish();
|
|
21125
22481
|
}
|
|
21126
22482
|
process.stdout.write(`stopped the panel on ${runtime.url} (its pid in run.json, ${runtime.pid}, was another process and was left alone)\n`);
|
|
21127
22483
|
clearRuntime();
|
|
21128
|
-
|
|
21129
|
-
return;
|
|
22484
|
+
return finish();
|
|
21130
22485
|
}
|
|
21131
22486
|
if (await waitForExit(runtime.pid, 2e4)) {
|
|
21132
22487
|
clearRuntime();
|
|
21133
22488
|
reportStopped(false);
|
|
21134
|
-
|
|
21135
|
-
return;
|
|
22489
|
+
return finish();
|
|
21136
22490
|
}
|
|
21137
22491
|
process.stdout.write(`${dim("it did not stop in time — forcing")}\n`);
|
|
21138
22492
|
forceStop(runtime.pid);
|
|
21139
22493
|
await waitForExit(runtime.pid, 5e3);
|
|
21140
22494
|
clearRuntime();
|
|
21141
22495
|
reportStopped(true);
|
|
21142
|
-
|
|
22496
|
+
return finish();
|
|
21143
22497
|
}
|
|
21144
22498
|
/**
|
|
21145
|
-
*
|
|
21146
|
-
*
|
|
21147
|
-
*
|
|
21148
|
-
*
|
|
22499
|
+
* The persistent entries this host has running, as their state files describe them.
|
|
22500
|
+
*
|
|
22501
|
+
* Every workspace keeps its own `.state`, and only the panel normally sees all of them, so
|
|
22502
|
+
* `down` reads them itself — after a crash there is nobody left to ask.
|
|
21149
22503
|
*/
|
|
21150
|
-
async function
|
|
21151
|
-
const {
|
|
21152
|
-
const {
|
|
21153
|
-
|
|
21154
|
-
|
|
21155
|
-
|
|
21156
|
-
|
|
21157
|
-
|
|
21158
|
-
|
|
21159
|
-
|
|
21160
|
-
|
|
21161
|
-
|
|
22504
|
+
async function livePersistents() {
|
|
22505
|
+
const { livePersistentEntries } = await Promise.resolve().then(() => (init_nanny_sweep(), nanny_sweep_exports));
|
|
22506
|
+
const { hhDir } = await Promise.resolve().then(() => (init_paths(), paths_exports));
|
|
22507
|
+
return livePersistentEntries(hhDir);
|
|
22508
|
+
}
|
|
22509
|
+
/** `workspace/id`, because a server id is only unique inside its workspace. */
|
|
22510
|
+
function persistentLabel(handle) {
|
|
22511
|
+
return `${handle.workspaceId}/${handle.serverId}`;
|
|
22512
|
+
}
|
|
22513
|
+
/**
|
|
22514
|
+
* Stops what is left of the snapshot: with the panel gone each nanny is signalled directly, and
|
|
22515
|
+
* its state file consumed once it is really gone. Returns which were ended here and which
|
|
22516
|
+
* survived, so the caller can account for the rest as the panel's work.
|
|
22517
|
+
*/
|
|
22518
|
+
async function stopPersistents(before) {
|
|
22519
|
+
const done = /* @__PURE__ */ new Set();
|
|
22520
|
+
const survived = /* @__PURE__ */ new Set();
|
|
22521
|
+
const live = new Set((await livePersistents()).map(persistentLabel));
|
|
22522
|
+
const handles = before.filter((handle) => live.has(persistentLabel(handle)));
|
|
22523
|
+
if (handles.length === 0) return {
|
|
22524
|
+
done,
|
|
22525
|
+
survived
|
|
22526
|
+
};
|
|
22527
|
+
const { stopPersistentEntries } = await Promise.resolve().then(() => (init_nanny_sweep(), nanny_sweep_exports));
|
|
22528
|
+
const results = await stopPersistentEntries(handles, { stopFor: await stopPolicyLookup() });
|
|
22529
|
+
for (const result of results) {
|
|
22530
|
+
const label = persistentLabel(result.handle);
|
|
22531
|
+
if (result.stopped) {
|
|
22532
|
+
done.add(label);
|
|
22533
|
+
process.stdout.write(`${green("stopped")} persistent ${label}\n`);
|
|
21162
22534
|
continue;
|
|
21163
22535
|
}
|
|
21164
|
-
|
|
21165
|
-
|
|
21166
|
-
|
|
22536
|
+
survived.add(label);
|
|
22537
|
+
process.stderr.write(`${paint("31", "error")} persistent ${label}: ${result.error}\n`);
|
|
22538
|
+
}
|
|
22539
|
+
const code = exitCodeForStops(results);
|
|
22540
|
+
if (code !== 0) process.exitCode = code;
|
|
22541
|
+
return {
|
|
22542
|
+
done,
|
|
22543
|
+
survived
|
|
22544
|
+
};
|
|
22545
|
+
}
|
|
22546
|
+
/**
|
|
22547
|
+
* The exit code these stops earn: any survivor is a failure, because the command was asked to
|
|
22548
|
+
* stop them and the host is still running one. Separated from the printing so the rule is
|
|
22549
|
+
* pinned where it can be read, not inferred from a process's status.
|
|
22550
|
+
*/
|
|
22551
|
+
function exitCodeForStops(results) {
|
|
22552
|
+
return results.some((result) => !result.stopped) ? 1 : 0;
|
|
22553
|
+
}
|
|
22554
|
+
/**
|
|
22555
|
+
* Each entry's own `stop` policy, read from the workspace that declares it.
|
|
22556
|
+
*
|
|
22557
|
+
* The grace period is the entry's, not a constant: the nanny forwards it to the child it
|
|
22558
|
+
* owns, so a shorter one here would escalate to `SIGKILL` while a shutdown the config asked
|
|
22559
|
+
* to allow more time for was still running. A workspace whose config cannot be read falls
|
|
22560
|
+
* back to the defaults — the host is being brought down either way.
|
|
22561
|
+
*/
|
|
22562
|
+
async function stopPolicyLookup() {
|
|
22563
|
+
const { WorkspaceStore } = await Promise.resolve().then(() => (init_store(), store_exports));
|
|
22564
|
+
const { workspaceServersPath, workspaceSettingsPath } = await Promise.resolve().then(() => (init_paths(), paths_exports));
|
|
22565
|
+
const { stopSchema } = await Promise.resolve().then(() => (init_contracts(), contracts_exports));
|
|
22566
|
+
const policies = /* @__PURE__ */ new Map();
|
|
22567
|
+
return (handle) => {
|
|
22568
|
+
let byId = policies.get(handle.workspaceId);
|
|
22569
|
+
if (byId === void 0) {
|
|
22570
|
+
byId = /* @__PURE__ */ new Map();
|
|
22571
|
+
try {
|
|
22572
|
+
const store = new WorkspaceStore(handle.workspaceId, workspaceSettingsPath(handle.workspaceId), workspaceServersPath(handle.workspaceId));
|
|
22573
|
+
store.load();
|
|
22574
|
+
for (const server of store.servers) byId.set(server.id, server.stop);
|
|
22575
|
+
} catch {}
|
|
22576
|
+
policies.set(handle.workspaceId, byId);
|
|
21167
22577
|
}
|
|
22578
|
+
return byId.get(handle.serverId) ?? stopSchema.assert({});
|
|
22579
|
+
};
|
|
22580
|
+
}
|
|
22581
|
+
/**
|
|
22582
|
+
* The last step: name what the flag left running, or stop what the panel could not and account
|
|
22583
|
+
* for every entry that was running when this command started.
|
|
22584
|
+
*
|
|
22585
|
+
* The panel does the stopping whenever it is reachable — it is the only process that can record
|
|
22586
|
+
* it — so what is left of the snapshot is what still needs a signal here. Anything else in the
|
|
22587
|
+
* snapshot was ended by the panel, and is reported as stopped; a survivor is never reported as
|
|
22588
|
+
* stopped, or `restart` would treat a failed stop as a successful one.
|
|
22589
|
+
*/
|
|
22590
|
+
async function reportPersistent(options, before = []) {
|
|
22591
|
+
if (options.withPersistent !== true) {
|
|
22592
|
+
const running = await livePersistents();
|
|
22593
|
+
if (running.length === 0) return [];
|
|
22594
|
+
process.stdout.write(`${dim(`${running.length} persistent server(s) left running: ${running.map(persistentLabel).join(", ")}\n`)}`);
|
|
22595
|
+
process.stdout.write(`${dim("stop one from the panel, or pass --with-persistent")}\n`);
|
|
22596
|
+
return [];
|
|
21168
22597
|
}
|
|
21169
|
-
|
|
21170
|
-
|
|
21171
|
-
|
|
22598
|
+
const ended = await stopPersistents(before);
|
|
22599
|
+
const stopped = [];
|
|
22600
|
+
for (const handle of before) {
|
|
22601
|
+
const label = persistentLabel(handle);
|
|
22602
|
+
if (ended.survived.has(label)) continue;
|
|
22603
|
+
if (!ended.done.has(label)) process.stdout.write(`${green("stopped")} persistent ${label}\n`);
|
|
22604
|
+
stopped.push({
|
|
22605
|
+
workspaceId: handle.workspaceId,
|
|
22606
|
+
serverId: handle.serverId
|
|
22607
|
+
});
|
|
22608
|
+
}
|
|
22609
|
+
return stopped;
|
|
21172
22610
|
}
|
|
21173
22611
|
async function waitForExit(pid, timeoutMs) {
|
|
21174
22612
|
const { isProcessAlive } = await Promise.resolve().then(() => (init_daemon(), daemon_exports));
|
|
@@ -21203,8 +22641,12 @@ var init_down = __esmMin((() => {
|
|
|
21203
22641
|
init_version();
|
|
21204
22642
|
downCommand = defineCommand({
|
|
21205
22643
|
meta: { name: "down" },
|
|
21206
|
-
|
|
21207
|
-
|
|
22644
|
+
args: { withPersistent: {
|
|
22645
|
+
type: "boolean",
|
|
22646
|
+
description: "also stop every persistent entry, in every workspace"
|
|
22647
|
+
} },
|
|
22648
|
+
run: async ({ args }) => {
|
|
22649
|
+
await runDown({ withPersistent: args.withPersistent === true });
|
|
21208
22650
|
}
|
|
21209
22651
|
});
|
|
21210
22652
|
}));
|
|
@@ -21366,6 +22808,10 @@ function restartCommand(entry) {
|
|
|
21366
22808
|
meta: { name: "restart" },
|
|
21367
22809
|
args: {
|
|
21368
22810
|
...upArgs,
|
|
22811
|
+
withPersistent: {
|
|
22812
|
+
type: "boolean",
|
|
22813
|
+
description: "stop the persistent entries too, instead of leaving them running"
|
|
22814
|
+
},
|
|
21369
22815
|
id: {
|
|
21370
22816
|
type: "positional",
|
|
21371
22817
|
required: false,
|
|
@@ -21380,15 +22826,35 @@ function restartCommand(entry) {
|
|
|
21380
22826
|
run: async ({ args }) => {
|
|
21381
22827
|
const id = typeof args.id === "string" ? args.id.trim() : "";
|
|
21382
22828
|
if (id.length > 0) {
|
|
22829
|
+
if (args.withPersistent === true) fail("restart <id> restarts one server — drop --with-persistent, or use it on a bare `restart`");
|
|
21383
22830
|
await runServerAction("restart", id, typeof args.workspace === "string" ? args.workspace.trim() : void 0);
|
|
21384
22831
|
return;
|
|
21385
22832
|
}
|
|
21386
22833
|
if (args.workspace !== void 0) fail("restart --workspace needs a server id — `home-hosted restart <id> --workspace <id>`");
|
|
21387
|
-
await runDown();
|
|
22834
|
+
const stopped = (await runDown({ withPersistent: args.withPersistent === true })).stoppedPersistent;
|
|
21388
22835
|
await runUp(toUpFlags(args), entry);
|
|
22836
|
+
if (stopped.length > 0) await startPersistentBack(stopped);
|
|
21389
22837
|
}
|
|
21390
22838
|
});
|
|
21391
22839
|
}
|
|
22840
|
+
/**
|
|
22841
|
+
* Starts the entries this restart stopped, through the panel that just came back.
|
|
22842
|
+
*
|
|
22843
|
+
* Only the ones `up` did not already start: its autostart pass runs asynchronously and a second
|
|
22844
|
+
* start of a running entry is a plain `{ ok: true }`, so re-asking is harmless — but the
|
|
22845
|
+
* entries with `autostart: false`, the reason this exists, would never come back otherwise.
|
|
22846
|
+
*/
|
|
22847
|
+
async function startPersistentBack(stopped) {
|
|
22848
|
+
const { readRuntime, requestControl } = await Promise.resolve().then(() => (init_daemon(), daemon_exports));
|
|
22849
|
+
const runtime = readRuntime();
|
|
22850
|
+
if (runtime === null) return;
|
|
22851
|
+
for (const { workspaceId, serverId } of stopped) {
|
|
22852
|
+
const workspace = `?workspace=${encodeURIComponent(workspaceId)}`;
|
|
22853
|
+
const answer = await requestControl(runtime, `/_hh/servers/${encodeURIComponent(serverId)}/start${workspace}`);
|
|
22854
|
+
const body = answer?.body ?? {};
|
|
22855
|
+
if (body.ok !== true) process.stderr.write(`${paint("31", "error")} ${workspaceId}/${serverId} did not come back: ${body.error ?? `the panel answered ${answer?.status}`}\n`);
|
|
22856
|
+
}
|
|
22857
|
+
}
|
|
21392
22858
|
var init_restart = __esmMin((() => {
|
|
21393
22859
|
init_down();
|
|
21394
22860
|
init_io();
|
|
@@ -21744,6 +23210,130 @@ var init_set_token = __esmMin((() => {
|
|
|
21744
23210
|
});
|
|
21745
23211
|
}));
|
|
21746
23212
|
//#endregion
|
|
23213
|
+
//#region src/cli/setup-temp.ts
|
|
23214
|
+
var setup_temp_exports = /* @__PURE__ */ __exportAll({
|
|
23215
|
+
runSetupTemp: () => runSetupTemp,
|
|
23216
|
+
setupTempArgs: () => setupTempArgs,
|
|
23217
|
+
setupTempCommand: () => setupTempCommand,
|
|
23218
|
+
sourceFromFlags: () => sourceFromFlags
|
|
23219
|
+
});
|
|
23220
|
+
/** Which source a flag names, or null when the invocation asks for no change. */
|
|
23221
|
+
function sourceFromFlags(flags) {
|
|
23222
|
+
if (flags.clear === true) return null;
|
|
23223
|
+
if (flags.wsl === true) return "wsl";
|
|
23224
|
+
return null;
|
|
23225
|
+
}
|
|
23226
|
+
async function runSetupTemp(flags) {
|
|
23227
|
+
const store = new GlobalSettingsStore(globalSettingsPath);
|
|
23228
|
+
store.load();
|
|
23229
|
+
const host = store.host;
|
|
23230
|
+
const configured = host.tempCommand.trim().length > 0;
|
|
23231
|
+
if (flags.clear === true) {
|
|
23232
|
+
if (!configured) {
|
|
23233
|
+
process.stdout.write("no temperature command is set — nothing to clear\n");
|
|
23234
|
+
return;
|
|
23235
|
+
}
|
|
23236
|
+
store.updateHost({ tempCommand: "" });
|
|
23237
|
+
process.stdout.write(`${green("temperature command cleared")} — the tile uses the built-in probe again\n`);
|
|
23238
|
+
return;
|
|
23239
|
+
}
|
|
23240
|
+
const source = sourceFromFlags(flags);
|
|
23241
|
+
if (source === null) {
|
|
23242
|
+
if (configured) {
|
|
23243
|
+
process.stdout.write(`${green("a temperature command is set")}: ${bold(host.tempCommand)}\n`);
|
|
23244
|
+
const probe = await probeWslTemperature(host.tempCommand, host.tempCommandTimeoutMs);
|
|
23245
|
+
process.stdout.write(probe.celsius === null ? ` ${dim(`it did not answer: ${probe.error ?? "unknown reason"}`)}\n` : ` last reading: ${green(`${probe.celsius}°C`)}\n`);
|
|
23246
|
+
return;
|
|
23247
|
+
}
|
|
23248
|
+
process.stdout.write("the panel reads the temperature from the kernel when the machine exposes a sensor.\n");
|
|
23249
|
+
process.stdout.write(`this machine: ${host.tempCelsius > 0 ? `threshold ${host.tempCelsius}°C` : "no temperature alert"}\n`);
|
|
23250
|
+
process.stdout.write(`\n${dim("if the Host vitals tile says n/a, set a source up:")}\n`);
|
|
23251
|
+
process.stdout.write(` ${bold("setup-temp --wsl")} read it through the Windows host (WSL2)\n`);
|
|
23252
|
+
return;
|
|
23253
|
+
}
|
|
23254
|
+
if (source === "wsl") {
|
|
23255
|
+
const { isWsl } = await Promise.resolve().then(() => (init_wsl_temperature$1(), wsl_temperature_exports));
|
|
23256
|
+
if (!isWsl()) fail("--wsl is for a WSL2 guest, and this is not one. Run `setup-temp` with no flag to see the options");
|
|
23257
|
+
const scriptPath = wslScriptPath();
|
|
23258
|
+
if (scriptPath === null) fail("the Windows drive is not mounted, so the helper cannot be written where powershell.exe can read it");
|
|
23259
|
+
if (!lhmInstalled()) await offerLibreHardwareMonitor(flags);
|
|
23260
|
+
writeWslTemperatureScript(scriptPath);
|
|
23261
|
+
const command = tempCommandFor(scriptPath);
|
|
23262
|
+
process.stdout.write(` helper ${dim(`${scriptPath} (${windowsScriptPath(scriptPath)} on Windows)`)}\n`);
|
|
23263
|
+
const probe = await probeWslTemperature(command, 5e3);
|
|
23264
|
+
if (probe.celsius === null) {
|
|
23265
|
+
process.stdout.write(`${fail("not set up")} — the helper did not answer: ${probe.error ?? "unknown reason"}\n`);
|
|
23266
|
+
process.stdout.write(`${dim(`the script is at ${scriptPath}; the config was left unchanged`)}\n`);
|
|
23267
|
+
return;
|
|
23268
|
+
}
|
|
23269
|
+
store.updateHost({
|
|
23270
|
+
tempCommand: command,
|
|
23271
|
+
tempCommandTimeoutMs: 5e3
|
|
23272
|
+
});
|
|
23273
|
+
process.stdout.write(`${green("WSL temperature bridge set up")}\n`);
|
|
23274
|
+
process.stdout.write(` command ${bold(command)}\n`);
|
|
23275
|
+
process.stdout.write(` reading ${green(`${probe.celsius}°C`)}\n`);
|
|
23276
|
+
}
|
|
23277
|
+
}
|
|
23278
|
+
/**
|
|
23279
|
+
* Offer the ~6 MB download. A prompt, never a silent fetch: installing software nobody asked for is
|
|
23280
|
+
* not a setup command's job, and a non-interactive stdin answers no.
|
|
23281
|
+
*/
|
|
23282
|
+
async function offerLibreHardwareMonitor(flags) {
|
|
23283
|
+
const where = lhmDirectoryWindows() ?? "C:\\ProgramData\\home-hosted\\LibreHardwareMonitor";
|
|
23284
|
+
if (flags.download !== true) {
|
|
23285
|
+
if (flags.download === false) {
|
|
23286
|
+
process.stdout.write(`${dim(`LibreHardwareMonitor is not installed; install it into ${where}, or pass --download`)}\n`);
|
|
23287
|
+
return;
|
|
23288
|
+
}
|
|
23289
|
+
const answer = await prompt(`LibreHardwareMonitor is required to read the sensor. Download it now (~6 MB)? [y/N] `);
|
|
23290
|
+
if (!/^y(?:es)?$/i.test(answer.trim())) {
|
|
23291
|
+
process.stdout.write(`${dim(`left it alone — install it into ${where} and re-run this command`)}\n`);
|
|
23292
|
+
return;
|
|
23293
|
+
}
|
|
23294
|
+
}
|
|
23295
|
+
const result = await installLibreHardwareMonitor({ onProgress: (message) => process.stdout.write(` ${dim(message)}\n`) });
|
|
23296
|
+
if (result.error !== null) {
|
|
23297
|
+
process.stdout.write(`${fail("the download did not install")} — ${result.error}\n`);
|
|
23298
|
+
return;
|
|
23299
|
+
}
|
|
23300
|
+
process.stdout.write(` library ${green("installed")} in ${result.dir}\n`);
|
|
23301
|
+
}
|
|
23302
|
+
var setupTempArgs, setupTempCommand;
|
|
23303
|
+
var init_setup_temp = __esmMin((() => {
|
|
23304
|
+
init_io();
|
|
23305
|
+
init_settings$1();
|
|
23306
|
+
init_paths();
|
|
23307
|
+
init_wsl_temperature$1();
|
|
23308
|
+
setupTempArgs = {
|
|
23309
|
+
wsl: {
|
|
23310
|
+
type: "boolean",
|
|
23311
|
+
description: "read the temperature through the Windows host (WSL2)",
|
|
23312
|
+
default: false
|
|
23313
|
+
},
|
|
23314
|
+
clear: {
|
|
23315
|
+
type: "boolean",
|
|
23316
|
+
description: "stop using a configured command and delete its helper",
|
|
23317
|
+
default: false
|
|
23318
|
+
},
|
|
23319
|
+
download: {
|
|
23320
|
+
type: "boolean",
|
|
23321
|
+
description: "download LibreHardwareMonitor without asking; --no-download never does (for a script)"
|
|
23322
|
+
}
|
|
23323
|
+
};
|
|
23324
|
+
setupTempCommand = defineCommand({
|
|
23325
|
+
meta: { name: "setup-temp" },
|
|
23326
|
+
args: setupTempArgs,
|
|
23327
|
+
async run({ args }) {
|
|
23328
|
+
await runSetupTemp({
|
|
23329
|
+
wsl: args.wsl === true,
|
|
23330
|
+
clear: args.clear === true,
|
|
23331
|
+
download: args.download
|
|
23332
|
+
});
|
|
23333
|
+
}
|
|
23334
|
+
});
|
|
23335
|
+
}));
|
|
23336
|
+
//#endregion
|
|
21747
23337
|
//#region src/cli/migrate.ts
|
|
21748
23338
|
var migrate_exports = /* @__PURE__ */ __exportAll({
|
|
21749
23339
|
migrateArgs: () => migrateArgs,
|
|
@@ -21788,6 +23378,7 @@ async function runMigrate(dryRun, yes) {
|
|
|
21788
23378
|
if (existing.length === 0) fail(`no home-hosted state to migrate — nothing at ${globalSettingsPath} or any workspace`);
|
|
21789
23379
|
const consented = yes || (process.env.HHOSTED_MIGRATE ?? "").toLowerCase() === "allow";
|
|
21790
23380
|
let stampOnly = 0;
|
|
23381
|
+
let lifted = 0;
|
|
21791
23382
|
for (const target of existing) {
|
|
21792
23383
|
let raw;
|
|
21793
23384
|
try {
|
|
@@ -21835,6 +23426,7 @@ async function runMigrate(dryRun, yes) {
|
|
|
21835
23426
|
if (migratedProblem !== null) fail(`the migration produced a config this release cannot read:\n ${migratedProblem}`);
|
|
21836
23427
|
fs.copyFileSync(target.file, `${target.file}.bak`);
|
|
21837
23428
|
writeFileAtomic(target.file, `${JSON.stringify(stampConfig(migrated), null, 2)}\n`);
|
|
23429
|
+
lifted += 1;
|
|
21838
23430
|
process.stdout.write(`${green(`migrated ${target.label} to schema ${plan.to}`)} in ${target.file}\n`);
|
|
21839
23431
|
process.stdout.write(` ${dim(`previous file kept at ${target.file}.bak`)}\n`);
|
|
21840
23432
|
}
|
|
@@ -21842,8 +23434,11 @@ async function runMigrate(dryRun, yes) {
|
|
|
21842
23434
|
process.stdout.write(`${dim("nothing was written (--dry-run)")}\n`);
|
|
21843
23435
|
return;
|
|
21844
23436
|
}
|
|
21845
|
-
|
|
21846
|
-
|
|
23437
|
+
const done = [];
|
|
23438
|
+
if (lifted > 0) done.push(green(`${lifted} file(s) migrated`));
|
|
23439
|
+
if (stampOnly > 0) done.push(green(`${stampOnly} file(s) stamped`));
|
|
23440
|
+
if (done.length === 0) process.stdout.write(`every file is already what home-hosted ${appVersion()} understands — nothing to migrate\n`);
|
|
23441
|
+
else process.stdout.write(`${done.join(", ")} to what home-hosted ${appVersion()} understands\n`);
|
|
21847
23442
|
}
|
|
21848
23443
|
var migrateArgs, migrateCommand;
|
|
21849
23444
|
var init_migrate = __esmMin((() => {
|
|
@@ -22722,7 +24317,7 @@ var backup_exports = /* @__PURE__ */ __exportAll({
|
|
|
22722
24317
|
* Both directions print through this, and so does the "what could I act on" list, so the three read
|
|
22723
24318
|
* alike. A row's note is the panel's own wording, passed through untouched.
|
|
22724
24319
|
*/
|
|
22725
|
-
function printPlanTree(rows) {
|
|
24320
|
+
function printPlanTree(rows, out = (text) => process.stdout.write(text)) {
|
|
22726
24321
|
const known = new Set(rows.map((row) => row.id));
|
|
22727
24322
|
const nodes = /* @__PURE__ */ new Map();
|
|
22728
24323
|
const ensure = (id) => {
|
|
@@ -22748,8 +24343,7 @@ function printPlanTree(rows) {
|
|
|
22748
24343
|
const write = (id, depth) => {
|
|
22749
24344
|
const node = nodes.get(id);
|
|
22750
24345
|
if (node === void 0) return;
|
|
22751
|
-
|
|
22752
|
-
process.stdout.write(`${padding}${depth === 1 ? "" : "- "}${id}${node.note === null ? "" : ` ${dim(`(${node.note})`)}`}\n`);
|
|
24346
|
+
out(`${" ".repeat(depth)}${depth === 1 ? "" : "- "}${id}${node.note === null ? "" : ` ${dim(`(${node.note})`)}`}\n`);
|
|
22753
24347
|
for (const child of node.children) write(child, depth + 1);
|
|
22754
24348
|
};
|
|
22755
24349
|
for (const root of roots) write(root, 1);
|
|
@@ -22877,7 +24471,7 @@ async function refuseWithoutScope(action, suffix) {
|
|
|
22877
24471
|
if (rows.length === 0) fail("name what to act on — pass --include <ids> or --all");
|
|
22878
24472
|
process.stderr.write(`${paint("31", "error")} name what to act on — pass --include <ids> or --all\n\n`);
|
|
22879
24473
|
process.stderr.write("available (or narrow it):\n");
|
|
22880
|
-
printPlanTree(flattenRows(rows));
|
|
24474
|
+
printPlanTree(flattenRows(rows), (text) => process.stderr.write(text));
|
|
22881
24475
|
process.stderr.write("\n--exclude <ids> leaves those out: --all --exclude global:secrets\n");
|
|
22882
24476
|
process.exit(1);
|
|
22883
24477
|
}
|
|
@@ -23544,7 +25138,7 @@ var HEADER = "home-hosted — a control panel for the processes on your home ser
|
|
|
23544
25138
|
/** The one line the full reference lists for a command. */
|
|
23545
25139
|
var SYNOPSIS = {
|
|
23546
25140
|
"up": "home-hosted up [options]",
|
|
23547
|
-
"down": "home-hosted down",
|
|
25141
|
+
"down": "home-hosted down [--with-persistent]",
|
|
23548
25142
|
"restart": "home-hosted restart [<id>] [options]",
|
|
23549
25143
|
"status": "home-hosted status [--json]",
|
|
23550
25144
|
"logs": "home-hosted logs [--lines <n>] [--follow] [--json]",
|
|
@@ -23554,6 +25148,7 @@ var SYNOPSIS = {
|
|
|
23554
25148
|
"free-port": "home-hosted free-port <id> [--workspace <id>]",
|
|
23555
25149
|
"set-password": "home-hosted set-password",
|
|
23556
25150
|
"set-token": "home-hosted set-token",
|
|
25151
|
+
"setup-temp": "home-hosted setup-temp [--wsl] [--download|--no-download] [--clear]",
|
|
23557
25152
|
"migrate": "home-hosted migrate",
|
|
23558
25153
|
"init": "home-hosted init",
|
|
23559
25154
|
"ui-switch": "home-hosted ui-switch",
|
|
@@ -23572,6 +25167,7 @@ var SUMMARIES = {
|
|
|
23572
25167
|
"free-port": "free the port a server needs, so it can start",
|
|
23573
25168
|
"set-password": "set the panel password without the API",
|
|
23574
25169
|
"set-token": "set the API token that scripts and agents use",
|
|
25170
|
+
"setup-temp": "teach the panel how to read this machine's CPU temperature",
|
|
23575
25171
|
"migrate": "bring the config up to this release's schema",
|
|
23576
25172
|
"init": "scaffold a project that keeps its state in the repo",
|
|
23577
25173
|
"ui-switch": "install a UI from a release asset, a zip file or a URL",
|
|
@@ -23629,11 +25225,17 @@ var START_SECTION = {
|
|
|
23629
25225
|
["--free-port", "free the port first, then start — the panel's Free port button"]
|
|
23630
25226
|
]
|
|
23631
25227
|
};
|
|
25228
|
+
var PERSISTENT_LINE = ["--with-persistent", "stop the persistent entries too (default: leave them running)"];
|
|
25229
|
+
var DOWN_SECTION = {
|
|
25230
|
+
heading: "Options for down",
|
|
25231
|
+
lines: [PERSISTENT_LINE]
|
|
25232
|
+
};
|
|
23632
25233
|
var RESTART_SECTION = {
|
|
23633
25234
|
heading: "Options for restart",
|
|
23634
25235
|
lines: [
|
|
23635
25236
|
["<id>", "restart just this server, leaving the panel up (optional)"],
|
|
23636
25237
|
["-w, --workspace <id>", "the workspace to act in, with an id"],
|
|
25238
|
+
PERSISTENT_LINE,
|
|
23637
25239
|
...UP_SECTION.lines
|
|
23638
25240
|
]
|
|
23639
25241
|
};
|
|
@@ -23645,6 +25247,15 @@ var SET_TOKEN_SECTION = {
|
|
|
23645
25247
|
heading: "Options for set-token",
|
|
23646
25248
|
lines: [["--generate", "create a strong token and print it once"], ["--clear", "remove the token, so it stops working"]]
|
|
23647
25249
|
};
|
|
25250
|
+
var SETUP_TEMP_SECTION = {
|
|
25251
|
+
heading: "Options for setup-temp",
|
|
25252
|
+
lines: [
|
|
25253
|
+
["--wsl", "read the temperature through the Windows host (WSL2)"],
|
|
25254
|
+
["--download", "fetch LibreHardwareMonitor without asking (for a script)"],
|
|
25255
|
+
["--no-download", "never fetch it; report what is missing"],
|
|
25256
|
+
["--clear", "stop using the command and delete the helper"]
|
|
25257
|
+
]
|
|
25258
|
+
};
|
|
23648
25259
|
var MIGRATE_SECTION = {
|
|
23649
25260
|
heading: "Options for migrate",
|
|
23650
25261
|
lines: [["--dry-run", "print what would change, write nothing"], ["-y, --yes", "apply without asking (or set HHOSTED_MIGRATE=allow)"]]
|
|
@@ -23754,6 +25365,8 @@ var USAGE = [
|
|
|
23754
25365
|
"",
|
|
23755
25366
|
renderSection(UI_SWITCH_SECTION),
|
|
23756
25367
|
"",
|
|
25368
|
+
renderSection(DOWN_SECTION),
|
|
25369
|
+
"",
|
|
23757
25370
|
renderSection(STATUS_SECTION),
|
|
23758
25371
|
"",
|
|
23759
25372
|
renderSection(SERVER_SECTION),
|
|
@@ -23762,6 +25375,7 @@ var USAGE = [
|
|
|
23762
25375
|
].join("\n");
|
|
23763
25376
|
var UP_COMMANDS = /* @__PURE__ */ new Set(["up", "restart"]);
|
|
23764
25377
|
var SECTIONS = {
|
|
25378
|
+
"down": DOWN_SECTION,
|
|
23765
25379
|
"status": STATUS_SECTION,
|
|
23766
25380
|
"logs": LOGS_SECTION,
|
|
23767
25381
|
"backup": BACKUP_SECTION,
|
|
@@ -23771,6 +25385,7 @@ var SECTIONS = {
|
|
|
23771
25385
|
"free-port": SERVER_SECTION,
|
|
23772
25386
|
"set-password": SET_PASSWORD_SECTION,
|
|
23773
25387
|
"set-token": SET_TOKEN_SECTION,
|
|
25388
|
+
"setup-temp": SETUP_TEMP_SECTION,
|
|
23774
25389
|
"migrate": MIGRATE_SECTION,
|
|
23775
25390
|
"init": INIT_SECTION,
|
|
23776
25391
|
"ui-switch": UI_SWITCH_SECTION,
|
|
@@ -23814,6 +25429,7 @@ var COMMANDS = {
|
|
|
23814
25429
|
"free-port": () => Promise.resolve().then(() => (init_server(), server_exports)).then((module) => module.freePortCommand),
|
|
23815
25430
|
"set-password": () => Promise.resolve().then(() => (init_set_password(), set_password_exports)).then((module) => module.setPasswordCommand),
|
|
23816
25431
|
"set-token": () => Promise.resolve().then(() => (init_set_token(), set_token_exports)).then((module) => module.setTokenCommand),
|
|
25432
|
+
"setup-temp": () => Promise.resolve().then(() => (init_setup_temp(), setup_temp_exports)).then((module) => module.setupTempCommand),
|
|
23817
25433
|
"migrate": () => Promise.resolve().then(() => (init_migrate(), migrate_exports)).then((module) => module.migrateCommand),
|
|
23818
25434
|
"init": () => Promise.resolve().then(() => (init_init(), init_exports)).then((module) => module.initCommand),
|
|
23819
25435
|
"ui-switch": () => Promise.resolve().then(() => (init_ui_switch(), ui_switch_exports)).then((module) => module.uiSwitchCommand),
|
|
@@ -23831,6 +25447,7 @@ var rootCommand = defineCommand({
|
|
|
23831
25447
|
});
|
|
23832
25448
|
var commandNames = Object.keys(COMMANDS);
|
|
23833
25449
|
async function main() {
|
|
25450
|
+
treatClosedReaderAsDone();
|
|
23834
25451
|
const dirFlags = extractDirFlags(process.argv.slice(2));
|
|
23835
25452
|
if (dirFlags.error !== void 0) fail(dirFlags.error);
|
|
23836
25453
|
applyDirFlags(dirFlags);
|