Add CLI setup and QQ webhook integration
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import fs from "node:fs";
|
||||
import type { AppConfig } from "../config.js";
|
||||
import { discoverAgents } from "../agents/discovery.js";
|
||||
import { printUrlHints } from "./net.js";
|
||||
|
||||
export async function runDoctor(config: AppConfig, configPath: string): Promise<number> {
|
||||
let problems = 0;
|
||||
console.log(`Config: ${configPath}`);
|
||||
console.log(`Server: ${config.server.host}:${config.server.port}`);
|
||||
|
||||
if (!config.agents.some((agent) => agent.name === config.defaultAgent)) {
|
||||
console.log(`ERROR: defaultAgent '${config.defaultAgent}' is not in agents[].`);
|
||||
problems++;
|
||||
} else {
|
||||
console.log(`Default agent: ${config.defaultAgent}`);
|
||||
}
|
||||
|
||||
for (const agent of config.agents) {
|
||||
if (agent.cwd && !fs.existsSync(agent.cwd)) {
|
||||
console.log(`WARN: agent '${agent.name}' cwd does not exist: ${agent.cwd}`);
|
||||
}
|
||||
}
|
||||
|
||||
const enabledPlatforms = Object.entries(config.platforms).filter(([, value]) => value.enabled).map(([name]) => name);
|
||||
console.log(`Enabled platforms: ${enabledPlatforms.join(", ") || "none"}`);
|
||||
if (enabledPlatforms.length === 0) {
|
||||
console.log("WARN: no IM platform is enabled.");
|
||||
}
|
||||
if (config.platforms.feishu.enabled) {
|
||||
if (!config.platforms.feishu.appId) problems += error("Feishu appId is empty.");
|
||||
if (!config.platforms.feishu.appSecret || config.platforms.feishu.appSecret === "replace-me") warn("Feishu appSecret is missing or placeholder.");
|
||||
if (!config.platforms.feishu.verificationToken || config.platforms.feishu.verificationToken === "replace-me") warn("Feishu verificationToken is missing or placeholder.");
|
||||
}
|
||||
if (config.platforms.qq.enabled) {
|
||||
if (!config.platforms.qq.appId) problems += error("QQ appId is empty.");
|
||||
if (!config.platforms.qq.clientSecret || config.platforms.qq.clientSecret === "replace-me") warn("QQ clientSecret is missing or placeholder.");
|
||||
if (config.platforms.qq.verifySignature) {
|
||||
const callbackSecret = config.platforms.qq.botSecret || config.platforms.qq.clientSecret;
|
||||
if (!callbackSecret || callbackSecret === "replace-me") problems += error("QQ botSecret or clientSecret is required when verifySignature is true.");
|
||||
}
|
||||
}
|
||||
|
||||
const discovered = await discoverAgents();
|
||||
console.log("Discovered local agents:");
|
||||
for (const agent of discovered) {
|
||||
const version = agent.version ? ` (${agent.version})` : "";
|
||||
const reason = agent.reason ? ` - ${agent.reason}` : "";
|
||||
console.log(`- ${agent.name}: ${agent.status}${version}${reason}`);
|
||||
}
|
||||
|
||||
await printUrlHints(config);
|
||||
return problems > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
function error(message: string): 1 {
|
||||
console.log(`ERROR: ${message}`);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function warn(message: string): void {
|
||||
console.log(`WARN: ${message}`);
|
||||
}
|
||||
Reference in New Issue
Block a user