chore: release v0.11.4

This commit is contained in:
晴天
2026-04-06 01:07:36 +08:00
parent 9ff91f74d8
commit 4f8ac803ce
9 changed files with 81 additions and 20 deletions

View File

@@ -2391,6 +2391,14 @@ function clearGatewayOwner() {
} catch {}
}
function shouldAutoClaimGateway(owner) {
const current = currentGatewayOwnerSignature()
if (!owner) return true // 无 owner 文件 → 自动认领
// owner 文件存在但签名不完全匹配 → 仅按 port + openclaw_dir 判断
return Number(owner.port || 0) === current.port
&& !!owner.openclawDir && path.resolve(owner.openclawDir) === current.openclawDir
}
function foreignGatewayError(pid = null) {
const port = readGatewayPort()
const pidText = pid ? ` (PID: ${pid})` : ''
@@ -2403,6 +2411,11 @@ function ensureOwnedGatewayOrThrow(pid = null) {
if (gatewayOwnerPidNeedsRefresh(owner, pid)) writeGatewayOwner(pid)
return true
}
// 无有效 owner 或签名不匹配 → 尝试自动认领(端口 + 数据目录匹配即可)
if (shouldAutoClaimGateway(owner)) {
writeGatewayOwner(pid)
return true
}
throw foreignGatewayError(pid)
}
@@ -2992,10 +3005,15 @@ const handlers = {
const cliInstalled = !!resolveOpenclawCliPath()
const owner = readGatewayOwner()
const ownedByCurrentInstance = !!running && isCurrentGatewayOwner(owner, pid || null)
let ownedByCurrentInstance = !!running && isCurrentGatewayOwner(owner, pid || null)
if (ownedByCurrentInstance && gatewayOwnerPidNeedsRefresh(owner, pid || null)) {
writeGatewayOwner(pid || null)
}
// 自动认领Gateway 在运行但无有效 owner且端口 + 数据目录匹配
if (running && !ownedByCurrentInstance && shouldAutoClaimGateway(owner)) {
writeGatewayOwner(pid || null)
ownedByCurrentInstance = true
}
const ownership = !running ? 'stopped' : ownedByCurrentInstance ? 'owned' : 'foreign'
return [{ label, running, pid, description: 'OpenClaw Gateway', cli_installed: cliInstalled, ownership, owned_by_current_instance: ownedByCurrentInstance }]