import { t as resolveOpenClawPackageRoot } from "./openclaw-root-BizNJX65.js";
import fs from "node:fs";
import path from "node:path";
//#region src/agents/docs-path.ts
const OPENCLAW_DOCS_URL = "https://docs.openclaw.ai";
const OPENCLAW_SOURCE_URL = "https://github.com/openclaw/openclaw";
function isUsableDocsDir(docsDir) {
	return fs.existsSync(path.join(docsDir, "docs.json"));
}
function isGitCheckout(rootDir) {
	return fs.existsSync(path.join(rootDir, ".git"));
}
async function resolveOpenClawDocsPath(params) {
	const workspaceDir = params.workspaceDir?.trim();
	if (workspaceDir) {
		const workspaceDocs = path.join(workspaceDir, "docs");
		if (isUsableDocsDir(workspaceDocs)) return workspaceDocs;
	}
	const packageRoot = await resolveOpenClawPackageRoot({
		cwd: params.cwd,
		argv1: params.argv1,
		moduleUrl: params.moduleUrl
	});
	if (!packageRoot) return null;
	const packageDocs = path.join(packageRoot, "docs");
	return isUsableDocsDir(packageDocs) ? packageDocs : null;
}
async function resolveOpenClawSourcePath(params) {
	const packageRoot = await resolveOpenClawPackageRoot({
		cwd: params.cwd,
		argv1: params.argv1,
		moduleUrl: params.moduleUrl
	});
	if (!packageRoot || !isGitCheckout(packageRoot)) return null;
	return packageRoot;
}
async function resolveOpenClawReferencePaths(params) {
	const [docsPath, sourcePath] = await Promise.all([resolveOpenClawDocsPath(params), resolveOpenClawSourcePath(params)]);
	return {
		docsPath,
		sourcePath
	};
}
//#endregion
export { resolveOpenClawSourcePath as a, resolveOpenClawReferencePaths as i, OPENCLAW_SOURCE_URL as n, resolveOpenClawDocsPath as r, OPENCLAW_DOCS_URL as t };
