openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
39 lines (38 loc) • 1.64 kB
JavaScript
import { r as isPathInside } from "./path-guards-TIjxtj6H.mjs";
import { n as resolveOpenClawPackageRoot } from "./openclaw-root-C-ayo09z.mjs";
import { o as resolveSandboxPathMapping } from "./path-policy-CyYRyWre.mjs";
import fs from "node:fs";
import path from "node:path";
//#region src/agents/docs-path.ts
/**
* Locates local OpenClaw docs/source roots for references shown to agents.
*/
const OPENCLAW_DOCS_URL = "https://docs.openclaw.ai";
const OPENCLAW_SOURCE_URL = "https://github.com/openclaw/openclaw";
/** Resolve docs and source from one package root, preferring workspace docs. */
async function resolveOpenClawReferencePaths(e) {
const resolveReference = (t, n) => {
if (!fs.existsSync(path.join(t, n))) return null;
if (!e.sandbox?.enabled) return t;
try {
const n = fs.realpathSync(t);
const r = e.sandbox.fsBridge;
if (!r) return null;
const i = r.pathMappings;
const a = r.resolvePath({ filePath: i ? t : n });
const o = i ? resolveSandboxPathMapping(i, a.containerPath) : null;
const s = i ? o?.hostPath : a.hostPath;
return s && fs.realpathSync(s) === n && (!o || isPathInside(fs.realpathSync(o.mapping.hostRoot), n)) ? a.containerPath : null;
} catch {
return null;
}
};
const t = await resolveOpenClawPackageRoot(e);
const n = e.workspaceDir?.trim();
return {
docsPath: (n ? resolveReference(path.join(n, "docs"), "docs.json") : null) ?? (t ? resolveReference(path.join(t, "docs"), "docs.json") : null),
sourcePath: t ? resolveReference(t, ".git") : null
};
}
//#endregion
export { OPENCLAW_SOURCE_URL as n, resolveOpenClawReferencePaths as r, OPENCLAW_DOCS_URL as t };