openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
93 lines (92 loc) • 5.58 kB
JavaScript
import { i as listAgentIds } from "./agent-roster-t1ooUdXp.mjs";
import "./agent-scope-config-DmXgFGKP.mjs";
import { f as resolveEffectiveEnableState, u as normalizePluginsConfig } from "./config-state-B1JlHgba.mjs";
import { l as getActivePluginRegistry } from "./runtime-ezCEpumg.mjs";
import { n as OPENCLAW_AGENT_RUNTIME_ID } from "./agent-runtime-id-D8s1CaYB.mjs";
import { n as resolveDefaultModelForAgent } from "./model-selection-config-Bvf5WqHo.mjs";
import "./model-selection-C2A4Wyix.mjs";
import { o as resolveEffectiveAgentRuntime } from "./thinking-runtime-BKWl4CUs.mjs";
import { n as hasConfiguredGatewayAuthSecretInput } from "./auth-config-utils-C9EXfOyf.mjs";
import { a as resolvePairingGatewayUrl, i as resolveConfiguredPairingPublicUrl, t as PAIRING_GATEWAY_LOOPBACK_ERROR } from "./setup-code-BZtNhry3.mjs";
import os from "node:os";
//#region src/commands/doctor-node-hosting-preconditions.ts
const CHECK_ID = "core/doctor/node-hosting-preconditions";
function usesIdentityHeadersWithoutMachineCredentials(e) {
return !hasConfiguredGatewayAuthSecretInput(e, "gateway.auth.token") && !hasConfiguredGatewayAuthSecretInput(e, "gateway.auth.password") && (e.gateway?.auth?.mode === "trusted-proxy" || e.gateway?.tailscale?.mode === "serve" && e.gateway?.auth?.mode !== "password" && e.gateway?.auth?.mode !== "none" && e.gateway?.auth?.allowTailscale !== false);
}
function hasConfiguredNodeHosting(e) {
const t = e.gateway?.nodes;
const n = [e.tools?.exec, ...Object.values(e.agents?.entries ?? {}).map((e) => e.tools?.exec)];
return Boolean(e.plugins?.entries?.["device-pair"]?.enabled === true || resolveConfiguredPairingPublicUrl(e) || t?.browser?.mode !== "off" && t?.browser?.node?.trim() || t?.pairing?.autoApproveCidrs?.length || t?.pairing?.sshVerify || t?.commands?.allow?.length || n.some((t) => t?.host === "node" || (t?.host ?? e.tools?.exec?.host ?? "auto") === "auto" && t?.node?.trim()));
}
function lacksNodeOnboardingPlugin(e) {
return !resolveEffectiveEnableState({
id: "device-pair",
origin: "bundled",
config: normalizePluginsConfig(e.plugins),
rootConfig: e,
enabledByDefault: true
}).enabled;
}
function lacksDeviceCapableRuntimeRoute(e) {
const t = getActivePluginRegistry();
return listAgentIds(e).every((n) => {
const r = resolveDefaultModelForAgent({
cfg: e,
agentId: n
});
const i = resolveEffectiveAgentRuntime({
cfg: e,
provider: r.provider,
modelId: r.model,
agentId: n
});
if (i === "openclaw") return false;
const a = t?.agentHarnesses.find((e) => e.harness.id === i)?.harness;
return a !== void 0 && a.cloudPlacement?.devicePlacement === void 0;
});
}
/** Collects config-only warnings for node authentication, onboarding, and worker ingress. */
async function collectNodeHostingPreconditionFindings(e) {
if (e.gateway?.mode === "remote" || !hasConfiguredNodeHosting(e)) return [];
const t = [];
const warn = (e) => t.push({
checkId: CHECK_ID,
severity: "warning",
category: "fix-now",
docsUrl: "https://docs.openclaw.ai/nodes",
...e
});
if (lacksNodeOnboardingPlugin(e)) warn({
message: "The device-pair plugin is not enabled; node onboarding join codes and openclaw connect are unavailable.",
path: "plugins.entries.device-pair.enabled",
requirement: "node-onboarding-plugin",
fixHint: "Set plugins.entries.device-pair.enabled: true, check that device-pair is not denied or excluded by plugins.allow, then restart the Gateway."
});
if (lacksDeviceCapableRuntimeRoute(e)) warn({
message: "No configured agent/model route resolves to a runtime that supports paired-device placement.",
path: "agents",
requirement: "device-session-runtime",
fixHint: "Select an agent/model route whose runtime supports paired-device placement, then check that its plugin is enabled and its required node commands are explicitly allowed. Runtime policy is model/provider-scoped; whole-agent runtime keys are ignored. For a multi-agent roster, set agents.ownership: \"explicit\"."
});
if (usesIdentityHeadersWithoutMachineCredentials(e)) warn({
message: "Gateway identity-header auth has no configured token/password path for machine clients; new node hosts cannot authenticate or become worker hosts.",
path: "gateway.auth",
requirement: "machine-client-auth",
fixHint: "Switch gateway.auth.mode to token and configure gateway.auth.token as a SecretRef so machine clients can authenticate as devices. Keep trusted-proxy only if machine clients use a clean loopback/direct gateway.auth.password path. For Access-fronted gateways, configure the node gateway.cloudflareAccess.clientId / clientSecret SecretInputs or set CF_ACCESS_CLIENT_ID / CF_ACCESS_CLIENT_SECRET before openclaw connect."
});
const n = e.gateway?.bind ?? "loopback";
if ((n === "loopback" || n === "auto") && (await resolvePairingGatewayUrl(e, {
env: process.env,
publicUrl: resolveConfiguredPairingPublicUrl(e),
networkInterfaces: os.networkInterfaces
})).error === "Gateway is only bound to loopback. Set gateway.publicOrigin to your public HTTPS origin, configure plugins.entries.device-pair.config.publicUrl, enable tailscale serve, or set gateway.bind=lan.") warn({
message: PAIRING_GATEWAY_LOOPBACK_ERROR,
path: "gateway.bind",
requirement: "node-onboarding-url",
fixHint: "If an edge proxy fronts node onboarding, allow /j/* and /__openclaw__/worker without edge identity auth, and preserve WebSocket upgrade on /__openclaw__/worker. Both routes enforce their own credentials."
});
return t;
}
//#endregion
export { collectNodeHostingPreconditionFindings };