@kenhkl/agent-moss 0.8.1 → 0.8.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/dist/cli.js +104 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4091,6 +4091,110 @@ async function main() {
|
|
|
4091
4091
|
console.log("\u67E5\u770B\u65E5\u5FD7\uFF1A journalctl -u agent_moss -f");
|
|
4092
4092
|
break;
|
|
4093
4093
|
}
|
|
4094
|
+
case "status": {
|
|
4095
|
+
const http = await import("http");
|
|
4096
|
+
const { execSync } = await import("child_process");
|
|
4097
|
+
let systemdInfo = "";
|
|
4098
|
+
try {
|
|
4099
|
+
const out = execSync("systemctl is-active agent_moss 2>/dev/null || true", { encoding: "utf-8" }).trim();
|
|
4100
|
+
if (out === "active") {
|
|
4101
|
+
const show = execSync("systemctl show agent_moss --property=MainPID,ActiveEnterTimestamp,ExecStart 2>/dev/null || true", { encoding: "utf-8" });
|
|
4102
|
+
for (const line of show.trim().split("\n")) {
|
|
4103
|
+
const [key, ...vals] = line.split("=");
|
|
4104
|
+
const val = vals.join("=");
|
|
4105
|
+
if (key === "MainPID" && val && val !== "0") systemdInfo += ` PID: ${val}
|
|
4106
|
+
`;
|
|
4107
|
+
else if (key === "ActiveEnterTimestamp" && val) systemdInfo += ` \u542F\u52A8\u65F6\u95F4: ${val}
|
|
4108
|
+
`;
|
|
4109
|
+
else if (key === "ExecStart" && val) systemdInfo += ` \u542F\u52A8\u547D\u4EE4: ${val}
|
|
4110
|
+
`;
|
|
4111
|
+
}
|
|
4112
|
+
if (!systemdInfo) systemdInfo = " Systemd: active\n";
|
|
4113
|
+
}
|
|
4114
|
+
} catch {
|
|
4115
|
+
}
|
|
4116
|
+
let foundPort = 0;
|
|
4117
|
+
let version2 = "";
|
|
4118
|
+
for (let port = 9090; port <= 9095; port++) {
|
|
4119
|
+
try {
|
|
4120
|
+
const data = await new Promise((resolve6, reject) => {
|
|
4121
|
+
const req = http.get(`http://127.0.0.1:${port}/api/v1/health`, { timeout: 2e3 }, (res) => {
|
|
4122
|
+
let body = "";
|
|
4123
|
+
res.on("data", (chunk) => body += chunk);
|
|
4124
|
+
res.on("end", () => {
|
|
4125
|
+
try {
|
|
4126
|
+
resolve6(JSON.parse(body));
|
|
4127
|
+
} catch {
|
|
4128
|
+
reject();
|
|
4129
|
+
}
|
|
4130
|
+
});
|
|
4131
|
+
});
|
|
4132
|
+
req.on("error", reject);
|
|
4133
|
+
});
|
|
4134
|
+
if (data.status === "healthy") {
|
|
4135
|
+
foundPort = port;
|
|
4136
|
+
version2 = data.version || "";
|
|
4137
|
+
break;
|
|
4138
|
+
}
|
|
4139
|
+
} catch {
|
|
4140
|
+
}
|
|
4141
|
+
}
|
|
4142
|
+
if (foundPort) {
|
|
4143
|
+
console.log(`\u2705 AgentMoss \u670D\u52A1\u8FD0\u884C\u4E2D`);
|
|
4144
|
+
console.log(` \u7248\u672C: ${version2 || "?"}`);
|
|
4145
|
+
console.log(` \u7AEF\u53E3: ${foundPort}`);
|
|
4146
|
+
console.log(` Console: http://127.0.0.1:${foundPort}/console`);
|
|
4147
|
+
console.log(` Health: http://127.0.0.1:${foundPort}/api/v1/health`);
|
|
4148
|
+
if (systemdInfo) {
|
|
4149
|
+
process.stdout.write(systemdInfo);
|
|
4150
|
+
} else {
|
|
4151
|
+
console.log(` Systemd: \u672A\u6CE8\u518C\uFF08\u8FD0\u884C agent-moss install --enable \u5B89\u88C5\uFF09`);
|
|
4152
|
+
}
|
|
4153
|
+
try {
|
|
4154
|
+
const data = await new Promise((resolve6, reject) => {
|
|
4155
|
+
const req = http.get(`http://127.0.0.1:${foundPort}/console/api/config`, { timeout: 3e3 }, (res) => {
|
|
4156
|
+
let body = "";
|
|
4157
|
+
res.on("data", (chunk) => body += chunk);
|
|
4158
|
+
res.on("end", () => {
|
|
4159
|
+
try {
|
|
4160
|
+
resolve6(JSON.parse(body));
|
|
4161
|
+
} catch {
|
|
4162
|
+
reject();
|
|
4163
|
+
}
|
|
4164
|
+
});
|
|
4165
|
+
});
|
|
4166
|
+
req.on("error", reject);
|
|
4167
|
+
});
|
|
4168
|
+
const layers = data.layers || {};
|
|
4169
|
+
const l1 = layers.L1_heuristic !== false ? "\u2705 \u542F\u7528" : "\u274C \u7981\u7528";
|
|
4170
|
+
const l2 = layers.L2_logic_rules !== false ? "\u2705 \u542F\u7528" : "\u274C \u7981\u7528";
|
|
4171
|
+
const l3 = layers.L3_llm_analysis !== false ? "\u2705 \u542F\u7528" : "\u274C \u7981\u7528";
|
|
4172
|
+
console.log(` L1 \u9759\u6001\u68C0\u6D4B: ${l1}`);
|
|
4173
|
+
console.log(` L2 \u903B\u8F91\u89C4\u5219: ${l2}`);
|
|
4174
|
+
console.log(` L3 LLM \u5206\u6790: ${l3}`);
|
|
4175
|
+
} catch {
|
|
4176
|
+
}
|
|
4177
|
+
console.log();
|
|
4178
|
+
console.log(" \u542F\u505C\u547D\u4EE4\uFF1A");
|
|
4179
|
+
console.log(" systemctl start agent_moss \u542F\u52A8");
|
|
4180
|
+
console.log(" systemctl stop agent_moss \u505C\u6B62");
|
|
4181
|
+
console.log(" systemctl restart agent_moss \u91CD\u542F");
|
|
4182
|
+
console.log(" systemctl status agent_moss \u72B6\u6001");
|
|
4183
|
+
console.log(" journalctl -u agent_moss -f \u65E5\u5FD7");
|
|
4184
|
+
} else {
|
|
4185
|
+
console.log(`\u274C AgentMoss \u670D\u52A1\u672A\u8FD0\u884C`);
|
|
4186
|
+
if (systemdInfo) {
|
|
4187
|
+
console.log(` Systemd: active \u4F46\u7AEF\u53E3\u63A2\u6D4B\u4E0D\u5230`);
|
|
4188
|
+
console.log(` \u68C0\u67E5\u65E5\u5FD7\uFF1Ajournalctl -u agent_moss -n 20 --no-pager`);
|
|
4189
|
+
} else {
|
|
4190
|
+
console.log(` \u542F\u52A8\u65B9\u5F0F\uFF1A`);
|
|
4191
|
+
console.log(` systemctl start agent_moss \uFF08systemd\uFF09`);
|
|
4192
|
+
console.log(` agent-moss server \uFF08\u524D\u53F0\uFF09`);
|
|
4193
|
+
}
|
|
4194
|
+
process.exit(1);
|
|
4195
|
+
}
|
|
4196
|
+
break;
|
|
4197
|
+
}
|
|
4094
4198
|
default:
|
|
4095
4199
|
console.error(`Unknown command: ${command}`);
|
|
4096
4200
|
printHelp();
|