/** * Server Detection Utility * * Detects whether a Minecraft server is currently running in a given * directory, and best-effort detects which Minecraft version it runs. * Used to gate plugin-directory mutations (sync/download/auto-update/ * complete-manual) behind a "is the server live?" decision (Phase 4 * safe-apply, roadmap 4.2). * * Detection signals (strongest first) and their HONEST limits: * * 1. `session.lock` with a FRESH mtime — Minecraft writes the lock at world * load, so a fresh mtime means a server started moments ago. The file is * NOT deleted on shutdown, so bare existence proves nothing (the pre-Phase-4 * implementation treated existence as "running" — permanently true for any * server that ever ran). A long-running server's lock mtime goes stale, so * a stale lock is NOT treated as "stopped" either — we fall through. * 2. `logs/latest.log` with a fresh mtime — live servers append to the log * regularly. Limit: a fully idle server (no players, quiet plugins) can go * quiet for longer than the freshness window. * 3. A java process whose command line references the server directory * (pgrep/wmic). Limit: only sees processes visible to the current user; * misses servers in containers or under other accounts; a server started * with relative paths from a different cwd may not carry the absolute path. * * Net effect: false negatives are possible (we may swap in place on a live * server — the pre-Phase-4 behavior for every install, now also guarded by * the pre-swap snapshot); false positives only delay an update until the next * restart via the update-folder staging path. Both failure modes are * recoverable by design. */ /** * Freshness window for session.lock / logs/latest.log mtime checks. * 10 minutes: long enough to bridge autosave/log gaps on quiet servers, * short enough that yesterday's shutdown never reads as "running". */ export declare const ACTIVITY_FRESH_MS: number; export interface ServerStatus { running: boolean; indicator?: 'session.lock' | 'log-activity' | 'process'; } /** * Check if a Minecraft server appears to be running in the given SERVER ROOT * directory (the directory containing world/, logs/, the server jar). * * See the module doc for the signal order and the honest limits of each. * For a PLUGINS directory, use {@link isPluginsDirOfRunningServer} instead — * the signals here live in the server root, not in plugins/. */ export declare function detectRunningServer(serverDir: string): Promise; /** * Simple boolean check — is the server running? */ export declare function isServerRunning(serverDir: string): Promise; /** * Running-server check for a PLUGINS directory (what sync/download/ * auto-update actually hold). Probes the directory itself and — when it is * named `plugins` per the Bukkit convention — its parent server root. * * The pre-Phase-4 sync guard passed the plugins dir straight to * {@link detectRunningServer}, which looked for `plugins/world/session.lock` * (never exists) — the guard could effectively only fire via the process * probe. This helper fixes that by checking the server root. */ export declare function isPluginsDirOfRunningServer(pluginsDir: string): Promise; /** * Memoizing wrapper around {@link isPluginsDirOfRunningServer} — one probe * per workflow run instead of one per plugin (the process probe spawns * pgrep/wmic). The answer is intentionally frozen for the wrapper's lifetime: * a server starting MID-batch is indistinguishable from one starting a moment * after the batch — the snapshot + staged-update safety still applies. */ export declare function createRunningServerProbe(pluginsDir: string): () => Promise; /** * Best-effort detection of the Minecraft version the server at * `pluginsDir`'s parent runs. Filesystem-only, never throws, returns null * when undeterminable (callers fall back to config, then 'unknown' — the * MC compat gate treats 'unknown' as never-blocking). * * Sources, in order: * 1. `/version_history.json` — Paper/Spigot write * `currentVersion: "… (MC: x.y.z)"` on every start; survives jar renames. * 2. The server-software jar's filename (`paper-1.21.4-123.jar` → `1.21.4`). * * Only consulted when the directory is named `plugins` (Bukkit convention) — * see {@link isPluginsDirOfRunningServer} for the same-heuristic rationale. */ export declare function detectServerMcVersion(pluginsDir: string): Promise; //# sourceMappingURL=server-detect.d.ts.map