UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 3.52 kB
import{b as resolveGatewayPort}from"./paths-D_FOvGon.mjs";import{i as runUtf8CommandWithTimeout}from"./exec-runner-BiCq-T1F.mjs";import"./exec-c5tqm8tb.mjs";import{n as inspectTailscaleBackendStateWithRunner,r as inspectTailscaleServeGatewayUrlsWithRunner}from"./tailscale-status-XuUK2SG6.mjs"; //!src/commands/doctor-tailscale.ts async function inspectDoctorTailscalePrerequisite(e){const t=e.gateway?.tailscale?.mode;if(e.gateway?.mode===`remote`||t!==`serve`&&t!==`funnel`)return;const n=await inspectTailscaleBackendStateWithRunner((e,t)=>runUtf8CommandWithTimeout(e,{...t,maxOutputBytes:4e5}));const r=`Gateway startup requires a running Tailscale backend because gateway.tailscale.mode="${t}".`;if(n.status!==`ok`)return`${r} Tailscale status ${n.status===`invalid`?`could not be parsed`:`is unavailable`}. Verify that the Tailscale CLI is installed and the local Tailscale service is running with \`tailscale status --json\`, then rerun Doctor before restarting the Gateway.`;switch(n.state){case`Running`:return;case`Stopped`:return`${r} Tailscale is stopped. Reconnect in the Tailscale app or run \`tailscale up\`, then verify \`tailscale status --json\` reports Running before restarting the Gateway.`;case`NeedsLogin`:return`${r} Tailscale is logged out. Sign in through the Tailscale app or \`tailscale login\`, then verify \`tailscale status --json\` reports Running before restarting the Gateway.`;case`NeedsMachineAuth`:return`${r} This machine needs tailnet administrator approval. Approve it in the Tailscale admin console, then verify \`tailscale status --json\` reports Running before restarting the Gateway.`;case`NoState`:case`Starting`:return`${r} The Tailscale backend is still starting. Wait for \`tailscale status --json\` to report Running before restarting the Gateway.`;default:return`${r} Tailscale did not report a running backend. Inspect \`tailscale status --json\` and resolve its backend state before restarting the Gateway.`}}async function collectTailscaleConfigWarnings(e){const t=e.cfg;const n=t.gateway;const r=(n?.tailscale?.mode??`off`)!==`off`;if(n?.tailscale?.mode===`serve`&&n.tailscale.preserveFunnel)return[];if(!n||n.mode===`remote`||!r&&n.bind!==`lan`)return[];const i=resolveGatewayPort(t,e.env??process.env);const a=await inspectTailscaleServeGatewayUrlsWithRunner(i,(e,t)=>runUtf8CommandWithTimeout(e,{...t,maxOutputBytes:4e5}),r);if(a.status===`unavailable`)return[];if(a.status===`invalid`)return["Tailscale Serve status could not be parsed, so legacy Serve configuration was not changed. Review `tailscale serve status --json`, then rerun Doctor."];if(a.urls.length===0)return[];if(r)return a.urls.some(e=>!new URL(e).port)?[`The predecessor Tailscale route will be adopted from a previous OpenClaw release when the Gateway starts.`]:[];return[`Legacy Tailscale Serve still targets Gateway port ${i}, but Doctor cannot prove that OpenClaw owns the existing route; configuration was not changed. If you confirm the route belongs to the current Tailscale hostname and is stale from an older OpenClaw release, remove only its root handler with ${a.urls.map(e=>`\`tailscale serve --yes --https=${new URL(e).port||`443`} --set-path=/ off\``).join(` or `)}, then configure gateway.bind="loopback" and gateway.tailscale.mode="serve" manually and restart the Gateway. If another service owns the route, leave managed Tailscale ingress off and configure gateway.trustedProxies for that proxy instead.`]}export{collectTailscaleConfigWarnings,inspectDoctorTailscalePrerequisite};