@nowcrew/daemon 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/i18n.js +1 -1
- package/dist/machine-info.js +13 -1
- package/dist/main.js +2 -1
- package/package.json +1 -1
package/dist/i18n.js
CHANGED
|
@@ -23,7 +23,7 @@ const zh = {
|
|
|
23
23
|
"Usage:": "用法:",
|
|
24
24
|
"connect and stay resident": "连接并常驻",
|
|
25
25
|
"run once manually": "手动运行一次",
|
|
26
|
-
"
|
|
26
|
+
"resident, connecting to": "常驻,连接到",
|
|
27
27
|
"control plane": "控制面",
|
|
28
28
|
"Waking agent": "唤醒 agent",
|
|
29
29
|
"for channel": "处理频道",
|
package/dist/machine-info.js
CHANGED
|
@@ -8,6 +8,7 @@ import { promisify } from "node:util";
|
|
|
8
8
|
import { readFileSync } from "node:fs";
|
|
9
9
|
import { readdir } from "node:fs/promises";
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { createRequire } from "node:module";
|
|
11
12
|
import { dirname, resolve } from "node:path";
|
|
12
13
|
const execFileP = promisify(execFile);
|
|
13
14
|
/** 候选 runtime CLI:展示名 → 可执行文件名。 */
|
|
@@ -35,7 +36,7 @@ export async function detectRuntimes() {
|
|
|
35
36
|
const checks = await Promise.all(RUNTIME_BINS.map(async ([name, bin]) => ((await isInstalled(bin)) ? name : null)));
|
|
36
37
|
return checks.filter((x) => x !== null);
|
|
37
38
|
}
|
|
38
|
-
function daemonVersion() {
|
|
39
|
+
export function daemonVersion() {
|
|
39
40
|
try {
|
|
40
41
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
41
42
|
const pkg = JSON.parse(readFileSync(resolve(here, "../package.json"), "utf8"));
|
|
@@ -45,6 +46,17 @@ function daemonVersion() {
|
|
|
45
46
|
return "0.0.0";
|
|
46
47
|
}
|
|
47
48
|
}
|
|
49
|
+
/** 读取同装的 @nowcrew/cli 版本(daemon 的依赖,npx 场景与 daemon 一起安装);解析失败返回 "0.0.0"。 */
|
|
50
|
+
export function cliVersion() {
|
|
51
|
+
try {
|
|
52
|
+
const req = createRequire(import.meta.url);
|
|
53
|
+
const pkg = JSON.parse(readFileSync(req.resolve("@nowcrew/cli/package.json"), "utf8"));
|
|
54
|
+
return pkg.version ?? "0.0.0";
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return "0.0.0";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
48
60
|
/** 列出 agentsRoot 下的 agent handle(每个子目录 = 一个 agent),跳过隐藏目录;读不到则返回 []。 */
|
|
49
61
|
async function listAgentHandles(agentsRoot) {
|
|
50
62
|
try {
|
package/dist/main.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { parseArgs } from "node:util";
|
|
9
9
|
import { loadConfig, ConfigError } from "./config.js";
|
|
10
10
|
import { detectDaemonLang, translateDaemon } from "./i18n.js";
|
|
11
|
+
import { cliVersion, daemonVersion } from "./machine-info.js";
|
|
11
12
|
import { runAgent } from "./runner.js";
|
|
12
13
|
import { serve } from "./serve.js";
|
|
13
14
|
async function main() {
|
|
@@ -53,7 +54,7 @@ async function main() {
|
|
|
53
54
|
throw e;
|
|
54
55
|
}
|
|
55
56
|
if (cmd === "serve") {
|
|
56
|
-
process.stdout.write(`\n🛰️ ${td("
|
|
57
|
+
process.stdout.write(`\n🛰️ crew-daemon v${daemonVersion()} (cli v${cliVersion()}) ${td("resident, connecting to")} ${config.serverUrl} ${td("control plane")}...\n`);
|
|
57
58
|
serve(config);
|
|
58
59
|
await new Promise(() => { }); // 常驻,直到被 kill
|
|
59
60
|
return;
|