feat: proxy CutOS agent console
This commit is contained in:
+2
-4
@@ -196,9 +196,7 @@ class ClawClient {
|
||||
|
||||
async _proceedWithConnection() {
|
||||
const [dashInfo] = await Promise.all([
|
||||
this._isOpenClaw()
|
||||
? getDashboardInfo().catch(e => { log.warn('clawd', 'dashboard 信息获取失败:', e.message); return null; })
|
||||
: Promise.resolve({}),
|
||||
getDashboardInfo(this._agentType).catch(e => { log.warn('clawd', 'dashboard 信息获取失败:', e.message); return null; }),
|
||||
startTtyd().catch(e => log.warn('ttyd', '启动失败:', e.message)),
|
||||
]);
|
||||
this._dashInfo = dashInfo || {};
|
||||
@@ -460,7 +458,7 @@ class ClawClient {
|
||||
this._applyStatus(msg);
|
||||
|
||||
if (msg.frp && msg.frp.server && msg.frp.auth_token) {
|
||||
this._frpc.start(msg.claw_id, msg.frp, this._cfg.ssh_secret_key ?? null, this._isOpenClaw()).catch(e => {
|
||||
this._frpc.start(msg.claw_id, msg.frp, this._cfg.ssh_secret_key ?? null, true).catch(e => {
|
||||
log.error('frpc', '启动失败:', e.message);
|
||||
});
|
||||
}
|
||||
|
||||
+13
-2
@@ -7,6 +7,7 @@ const path = require('path');
|
||||
const https = require('https');
|
||||
const log = require('./logger');
|
||||
const { Watchdog } = require('./watchdog');
|
||||
const { CUTOS_AGENT } = require('./agent-type');
|
||||
|
||||
const CONFIG_DIR = process.env.CLAWD_CONFIG_DIR
|
||||
|| (process.getuid && process.getuid() === 0 ? '/etc/clawd' : path.join(os.homedir(), '.clawd'));
|
||||
@@ -15,6 +16,7 @@ const FRPC_CONFIG = path.join(CONFIG_DIR, 'frpc.toml');
|
||||
|
||||
const FRP_VERSION = '0.62.0';
|
||||
const TTYD_PORT = 7681;
|
||||
const CUTOS_DASHBOARD_PORT = 30141;
|
||||
|
||||
function findTtydBin() {
|
||||
const candidates = ['/usr/bin/ttyd', '/usr/local/bin/ttyd', path.join(CONFIG_DIR, 'ttyd')];
|
||||
@@ -49,7 +51,10 @@ function resolveOpenclawConfigFile() {
|
||||
* 直接读取比执行命令更可靠(不依赖 PATH、不需要进程启动等待)。
|
||||
* systemd 服务的 ProtectHome=read-only 允许读取 /home 下的文件。
|
||||
*/
|
||||
function getDashboardInfo() {
|
||||
function getDashboardInfo(agentType) {
|
||||
if (agentType === CUTOS_AGENT) {
|
||||
return Promise.resolve({ dashboard_port: CUTOS_DASHBOARD_PORT });
|
||||
}
|
||||
for (const cfgPath of OPENCLAW_JSON_CANDIDATES) {
|
||||
try {
|
||||
const raw = fs.readFileSync(cfgPath, 'utf8');
|
||||
@@ -226,4 +231,10 @@ class FrpcManager {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { getDashboardInfo, resolveOpenclawConfigFile, startTtyd, FrpcManager };
|
||||
module.exports = {
|
||||
CUTOS_DASHBOARD_PORT,
|
||||
getDashboardInfo,
|
||||
resolveOpenclawConfigFile,
|
||||
startTtyd,
|
||||
FrpcManager,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user