openclaw-manager 0.1.1
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/bin/openclaw-manager.js +198 -0
- package/dist/app.js +39 -0
- package/dist/controllers/auth.controller.js +19 -0
- package/dist/controllers/cli.controller.js +10 -0
- package/dist/controllers/discord.controller.js +21 -0
- package/dist/controllers/jobs.controller.js +138 -0
- package/dist/controllers/process.controller.js +26 -0
- package/dist/controllers/quickstart.controller.js +11 -0
- package/dist/controllers/status.controller.js +10 -0
- package/dist/deps.js +1 -0
- package/dist/dev.js +156 -0
- package/dist/index.js +37 -0
- package/dist/lib/auth.js +57 -0
- package/dist/lib/commands.js +123 -0
- package/dist/lib/config.js +48 -0
- package/dist/lib/constants.js +9 -0
- package/dist/lib/gateway.js +37 -0
- package/dist/lib/jobs.js +117 -0
- package/dist/lib/onboarding.js +96 -0
- package/dist/lib/runner.js +99 -0
- package/dist/lib/static.js +69 -0
- package/dist/lib/system.js +31 -0
- package/dist/lib/utils.js +31 -0
- package/dist/middlewares/auth.js +23 -0
- package/dist/routes/auth.js +5 -0
- package/dist/routes/cli.js +4 -0
- package/dist/routes/discord.js +5 -0
- package/dist/routes/health.js +9 -0
- package/dist/routes/index.js +18 -0
- package/dist/routes/jobs.js +11 -0
- package/dist/routes/processes.js +6 -0
- package/dist/routes/quickstart.js +4 -0
- package/dist/routes/status.js +4 -0
- package/dist/services/auth.service.js +24 -0
- package/dist/services/cli.service.js +21 -0
- package/dist/services/discord.service.js +38 -0
- package/dist/services/jobs.service.js +307 -0
- package/dist/services/process.service.js +9 -0
- package/dist/services/quickstart.service.js +124 -0
- package/dist/services/resource.service.js +46 -0
- package/dist/services/status.service.js +32 -0
- package/package.json +18 -0
- package/web-dist/assets/index-BabnD_ew.js +13 -0
- package/web-dist/assets/index-CBtcOjoT.css +1 -0
- package/web-dist/docker.sh +62 -0
- package/web-dist/index.html +13 -0
- package/web-dist/install.ps1 +110 -0
- package/web-dist/install.sh +261 -0
- package/web-dist/stop.sh +52 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { Readable } from "node:stream";
|
|
5
|
+
import { pipeline } from "node:stream/promises";
|
|
6
|
+
export async function downloadResource(options, onLog) {
|
|
7
|
+
const url = options.url.trim();
|
|
8
|
+
if (!url)
|
|
9
|
+
throw new Error("resource url missing");
|
|
10
|
+
const targetDir = options.dir ?? path.join(os.homedir(), ".clawdbot-manager", "resources");
|
|
11
|
+
const safeName = options.filename?.trim() || path.basename(new URL(url).pathname) || "resource.bin";
|
|
12
|
+
const targetPath = path.join(targetDir, safeName);
|
|
13
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
14
|
+
onLog(`开始下载: ${url}`);
|
|
15
|
+
onLog(`保存路径: ${targetPath}`);
|
|
16
|
+
const res = await fetch(url);
|
|
17
|
+
if (!res.ok) {
|
|
18
|
+
throw new Error(`download failed: ${res.status}`);
|
|
19
|
+
}
|
|
20
|
+
if (!res.body) {
|
|
21
|
+
throw new Error("empty response body");
|
|
22
|
+
}
|
|
23
|
+
const total = Number(res.headers.get("content-length") ?? "0");
|
|
24
|
+
if (total > 0) {
|
|
25
|
+
onLog(`内容大小: ${(total / 1024 / 1024).toFixed(2)} MB`);
|
|
26
|
+
}
|
|
27
|
+
const readable = Readable.fromWeb(res.body);
|
|
28
|
+
let received = 0;
|
|
29
|
+
let lastLogged = 0;
|
|
30
|
+
readable.on("data", (chunk) => {
|
|
31
|
+
received += chunk.length;
|
|
32
|
+
if (received - lastLogged >= 1024 * 1024) {
|
|
33
|
+
lastLogged = received;
|
|
34
|
+
if (total > 0) {
|
|
35
|
+
const percent = ((received / total) * 100).toFixed(1);
|
|
36
|
+
onLog(`下载进度: ${percent}%`);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
onLog(`已下载: ${(received / 1024 / 1024).toFixed(2)} MB`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
await pipeline(readable, fs.createWriteStream(targetPath));
|
|
44
|
+
onLog("下载完成。");
|
|
45
|
+
return { path: targetPath };
|
|
46
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DEFAULT_GATEWAY_HOST, DEFAULT_GATEWAY_PORT } from "../lib/constants.js";
|
|
2
|
+
import { checkGateway } from "../lib/gateway.js";
|
|
3
|
+
import { getOnboardingStatus } from "../lib/onboarding.js";
|
|
4
|
+
import { getCliStatus, getSystemStatus } from "../lib/system.js";
|
|
5
|
+
import { parsePort } from "../lib/utils.js";
|
|
6
|
+
export async function buildStatus(deps, query) {
|
|
7
|
+
const gatewayHost = query.gatewayHost ?? DEFAULT_GATEWAY_HOST;
|
|
8
|
+
const gatewayPort = parsePort(query.gatewayPort) ?? DEFAULT_GATEWAY_PORT;
|
|
9
|
+
const [system, cli, gateway] = await Promise.all([
|
|
10
|
+
getSystemStatus(),
|
|
11
|
+
getCliStatus(deps.runCommand),
|
|
12
|
+
checkGateway(gatewayHost, gatewayPort)
|
|
13
|
+
]);
|
|
14
|
+
const onboarding = await getOnboardingStatus(cli.installed, deps.runCommand);
|
|
15
|
+
return {
|
|
16
|
+
ok: true,
|
|
17
|
+
now: new Date().toISOString(),
|
|
18
|
+
system,
|
|
19
|
+
cli,
|
|
20
|
+
gateway,
|
|
21
|
+
onboarding,
|
|
22
|
+
commands: deps.commandRegistry.map((cmd) => ({
|
|
23
|
+
id: cmd.id,
|
|
24
|
+
title: cmd.title,
|
|
25
|
+
description: cmd.description,
|
|
26
|
+
command: [cmd.command, ...cmd.args].join(" "),
|
|
27
|
+
cwd: cmd.cwd,
|
|
28
|
+
allowRun: cmd.allowRun
|
|
29
|
+
})),
|
|
30
|
+
processes: deps.processManager.listProcesses()
|
|
31
|
+
};
|
|
32
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "openclaw-manager",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"openclaw-manager": "bin/openclaw-manager.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin",
|
|
10
|
+
"dist",
|
|
11
|
+
"web-dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@hono/node-server": "1.13.1",
|
|
16
|
+
"hono": "4.11.4"
|
|
17
|
+
}
|
|
18
|
+
}
|