import { readFile } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
/** Feature keys advertised by this build. Only-true entries by design. */
const FEATURES = {
    'code.searchSymbols': true,
    'code.projectContext': true,
    'code.directoryTree': true,
    'code.map.changed': true,
    'git.cochange': true,
    'metrics.fileComplexity': true,
    'code.index.symbolNodeIds': true,
    'store.peekMetadata': true,
    'store.isFresh': true,
    'session.refresh.signal': true,
    'defaults.excludeDirs': true,
};
let cachedVersion;
async function readVersion() {
    if (cachedVersion)
        return cachedVersion;
    const directory = path.dirname(fileURLToPath(import.meta.url));
    for (const rel of ['..', '../..']) {
        try {
            const raw = await readFile(path.resolve(directory, rel, 'package.json'), 'utf8');
            const parsed = JSON.parse(raw);
            if (parsed.version) {
                cachedVersion = parsed.version;
                return parsed.version;
            }
        }
        catch {
            // Try next package.json location.
        }
    }
    cachedVersion = '0.0.0';
    return cachedVersion;
}
export async function health() {
    return {
        available: true,
        version: await readVersion(),
        capabilities: {
            code: true,
            workspace: true,
            documents: true,
            tables: true,
            health: true,
        },
        features: { ...FEATURES },
    };
}
//# sourceMappingURL=health.js.map