From c5fd091f5aba1461c020da0db140d9dd6b5574eb Mon Sep 17 00:00:00 2001 From: hzhang Date: Fri, 22 May 2026 22:46:50 +0100 Subject: [PATCH] fix(triage): resolve claw_identifier via openclaw config (HF plugin's identifier) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit os.hostname() fallback is wrong in sim where container hostname (server.t2) doesn't match the HF agent row's claw_identifier (sim-t2). Add intermediate fallback that reads openclaw config plugins.harbor-forge.identifier — the same value the HF plugin uses for its outbound HF calls — keeping plugin and HF agent state aligned without a per-service-unit HF_CLAW_IDENTIFIER env override. Priority: 1. HF_CLAW_IDENTIFIER env (operator override) 2. openclaw config plugins.harbor-forge.identifier (NEW) 3. os.hostname() last-resort 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) --- src/inbound.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/inbound.ts b/src/inbound.ts index d089448..06c1973 100644 --- a/src/inbound.ts +++ b/src/inbound.ts @@ -129,7 +129,34 @@ export class FabricInbound { return cached.onCall; } const base = (process.env.HF_API_BASE_URL ?? '').trim() || 'https://monitor.hangman-lab.top'; - const claw = (process.env.HF_CLAW_IDENTIFIER ?? '').trim() || (await import('os')).hostname(); + // CLAW_IDENTIFIER resolution priority: + // 1. HF_CLAW_IDENTIFIER env (operator override) + // 2. openclaw config `plugins.harbor-forge.identifier` (what the HF + // plugin itself uses — keeps the two in sync without an extra + // env per service unit) + // 3. os.hostname() last-resort fallback (often wrong: e.g. sim + // container hostname is `server.t2` but HF agent row has + // `claw_identifier=sim-t2`; matching is mandatory for the HF + // backend's _require_agent() check) + let claw = (process.env.HF_CLAW_IDENTIFIER ?? '').trim(); + if (!claw) { + try { + // openclaw config shape (verified in sim): + // { plugins: { entries: { 'harbor-forge': { config: { identifier } } } } } + const cfg = this.cfg as { + plugins?: { entries?: Record }; + }; + const fromCfg = cfg?.plugins?.entries?.['harbor-forge']?.config?.identifier; + if (fromCfg && typeof fromCfg === 'string' && fromCfg.trim()) { + claw = fromCfg.trim(); + } + } catch { + /* fall through to hostname */ + } + } + if (!claw) { + claw = (await import('os')).hostname(); + } let onCall = false; try { const url = `${base.replace(/\/$/, '')}/calendar/agent/status?agent_id=${encodeURIComponent(agentId)}`;