openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
60 lines (59 loc) • 2.46 kB
JavaScript
import { o as isDefaultInstallIdentity } from "./paths-DAcAg5aV.mjs";
import { n as resolveStdioMcpServerLaunchConfig } from "./mcp-stdio-BbrQn34X.mjs";
import { n as loadEnabledBundleLspConfig } from "./bundle-lsp-BPvu9pN4.mjs";
import { n as resolveGatewayService } from "./service-hQiIzcTo.mjs";
import { t as note } from "./note-CnLgHvug.mjs";
import { l as shouldManageGatewayService } from "./doctor-service-repair-policy-DAuL0W8-.mjs";
//#region src/commands/doctor-bundle-lsp-env.ts
/** Doctor note for Gateway env vars that bundle LSP servers no longer inherit. */
/** Notes commonly needed, non-secret Gateway env names that configured bundle LSP servers lack. */
async function noteBundleLspEnvPassthrough(e) {
if (e.cfg.gateway?.mode === "remote") return;
const { cfg: t, workspaceDirs: n } = e;
const r = e.runWithPluginMetadataSnapshot;
const i = /* @__PURE__ */ new Map();
for (const e of n) {
const load = () => loadEnabledBundleLspConfig({
workspaceDir: e,
cfg: t
});
const n = r ? r({
config: t,
workspaceDir: e
}, load) : load();
for (const [e, t] of Object.entries(n.config.lspServers)) {
const n = resolveStdioMcpServerLaunchConfig(t);
if (n.ok) i.set(e, [...i.get(e) ?? [], n.config.env]);
}
}
if (i.size === 0) return;
const { collectWithheldLspEnvNames: a, formatWithheldLspEnvHints: o, LSP_ENV_PASSTHROUGH_DOCS_URL: s, resolveLspServerEnv: c } = await import("./agent-bundle-lsp-env-BDMUfsKF.mjs");
const l = e.env ?? process.env;
const u = e.service ?? resolveGatewayService();
const d = [l];
if (isDefaultInstallIdentity(l) && await shouldManageGatewayService(l)) {
const e = await u.readCommand(l).catch(() => null);
if (e?.environment) d.push(e.environment);
}
const f = [];
for (const [e, t] of [...i].toSorted(([e], [t]) => e.localeCompare(t))) {
const n = t.flatMap((e) => d.map((t) => a({
parentEnv: t,
childEnv: c(e, t)
})));
const r = new Set(n.flatMap((e) => e.configurable));
const i = new Set(n.flatMap((e) => e.refused));
for (const t of o({
configurable: [...r].toSorted(),
refused: [...i].toSorted()
})) f.push(`- "${e}": ${t}`);
}
if (f.length === 0) return;
(e.noteFn ?? note)([
"Bundle LSP servers start from an allowlisted environment, not the full Gateway environment. These Gateway variables are set but not passed:",
...f,
`Docs: ${s}`
].join("\n"), "Bundle LSP environment");
}
//#endregion
export { noteBundleLspEnvPassthrough };