import { g as resolveStateDir } from "./paths-mmi2xb99.js";
import "./globals-D5pM_phR.js";
import "./utils-3Lue6wVm.js";
import "./subsystem-_lp1q2Mi.js";
import "./boolean-BhvV-zDA.js";
import "./env-aEqmsXHj.js";
import "./config-VoJVjSgT.js";
import "./agent-scope-u760_XKU.js";
import "./exec-NeyMP-Tl.js";
import "./edwinpai-root-fGTEvnPp.js";
import "./model-selection-CMHF17-l.js";
import "./github-copilot-token-Bu-iLSUh.js";
import "./command-format-D8drL8c2.js";
import "./manifest-registry-Cobl4jxs.js";
import fs from "node:fs";
import path from "node:path";

//#region ../../src/infra/desktop-identity.ts
function resolveIdentityKeyPath(stateDir) {
	const resolvedStateDir = stateDir ?? resolveStateDir(process.env);
	return path.join(resolvedStateDir, "identity-key");
}
function loadDesktopIdentityKey(stateDir) {
	const keyPath = resolveIdentityKeyPath(stateDir);
	if (!fs.existsSync(keyPath)) return null;
	try {
		const raw = fs.readFileSync(keyPath, "utf-8").trim();
		if (/^[0-9a-fA-F]{64}$/.test(raw)) return raw.toLowerCase();
		return null;
	} catch {
		return null;
	}
}

//#endregion
export { loadDesktopIdentityKey };