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)}`;