globalThis.__hivemind_tuning__ ??= {};

// src/config.ts
import { readFileSync, existsSync } from "node:fs";
import { join } from "node:path";
import { homedir, userInfo } from "node:os";
function loadConfig() {
  const home = homedir();
  const credPath = join(home, ".deeplake", "credentials.json");
  let creds = null;
  if (existsSync(credPath)) {
    try {
      creds = JSON.parse(readFileSync(credPath, "utf-8"));
    } catch {
      return null;
    }
  }
  const token = creds?.token;
  const orgId = creds?.orgId;
  if (!token || !orgId) return null;
  return {
    token,
    orgId,
    orgName: creds?.orgName ?? orgId,
    userName: creds?.userName || userInfo().username || "unknown",
    workspaceId: creds?.workspaceId ?? "default",
    apiUrl: creds?.apiUrl ?? "https://api.deeplake.ai",
    tableName: "memory",
    sessionsTableName: "sessions",
    skillsTableName: process.env.HIVEMIND_SKILLS_TABLE ?? "skills",
    memoryPath: join(home, ".deeplake", "memory")
  };
}
export {
  loadConfig
};
