Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

3.6 KB
Raw Blame
import { isGoogleProvider, GOOGLE_APP_PROVIDER } from "./google-native-config";
import { nativeGoogleStatus } from "./google-native";
import { recordConnectionCheck } from "./connection-health";
import { credentialSnapshot, currentIntegrationSelection, resolveIntegration } from "./connection-service";
import { verifyExternalIntegration } from "./connection-external";
import { doctorAdditionalProvider } from "./additional-doctor";
import { readInfraProvider } from "./store";
import type { InfraDoctorResult, InfraProviderId, InfraProviderValues } from "./types";
import { doctorCloudflare } from "./cloudflare";
import { doctorDokploy } from "./dokploy";
import { doctorHostinger } from "./hostinger";
import { doctorComposio } from "./composio";

export { listCloudflareZones, upsertCloudflareDns } from "./cloudflare";
export { ensureDokployProject, listDokployProjects, listDokployApplications, listDokployDeployments, readDokployDeploymentLogs, inspectDokployApplication, listDokployGitProviders, listDokployGithubRepositories, inspectDokployGithubProvider, testDokployGithubProvider, ensureDokployGithubApplication, ensureDokployApplicationDomain, recoverDokployPublicGithubToHttpsGit, deployDokployApplication, configureDokployDockerfileBuild, upsertDokployPublicBuildEnv } from "./dokploy";
export { upsertHostingerDns } from "./hostinger";
export { listHostingerMailOrders, getHostingerMailPlan, listHostingerMail, listHostingerMailLogs, mutateHostingerMail } from "./hostinger-mail";

async function probeInfraProvider(id: InfraProviderId, candidate?: InfraProviderValues): Promise<InfraDoctorResult> {
  try {
    if(!candidate){
      try{const route=await resolveIntegration(id,currentIntegrationSelection());if(route.source!=="direct")return { ...await verifyExternalIntegration(id,{user:route.user,connection:route.id}), id };}catch(error){if(!["connection_not_found","user_required"].includes((error as Error).message))throw error;}
    }
    const detail = id === "dokploy"
      ? await doctorDokploy(candidate)
      : id === "cloudflare"
        ? await doctorCloudflare(candidate)
        : id === "composio"
          ? await doctorComposio(candidate)
          : id === "hostinger" ? await doctorHostinger(candidate) : await doctorAdditionalProvider(id, candidate ?? await readInfraProvider(id));
    return detail === null ? { id, ok: null, detail: "not configured" } : { id, ok: true, detail };
  } catch (error) {
    return { id, ok: false, detail: (error as Error).message.slice(0, 300) };
  }
}

// Pin the credential revision before probing; never attribute an old request to new keys.
export async function doctorInfraProvider(id: InfraProviderId, candidate?: InfraProviderValues): Promise<InfraDoctorResult> {
  if(isGoogleProvider(id)||id===GOOGLE_APP_PROVIDER)return candidate?{id,ok:null,detail:"Google OAuth consent and actual API verification required"}:nativeGoogleStatus(id,currentIntegrationSelection());
  if (candidate) return probeInfraProvider(id, candidate);
  const selector = currentIntegrationSelection();
  let snapshot;
  try {
    const route = await resolveIntegration(id, selector);
    if (route.source !== "direct") return probeInfraProvider(id);
    snapshot = await credentialSnapshot(id, { user: route.user, connection: route.id });
  } catch {
    return probeInfraProvider(id);
  }
  const checkedAt = Date.now();
  const result = await probeInfraProvider(id, snapshot.connection.values);
  const recorded = await recordConnectionCheck(id, snapshot, result, checkedAt);
  return recorded ? result : { id, ok: null, detail: "Connection changed during verification. Check it again." };
}