/**
 * `neotoma processes list|kill` — local OS process discovery (ps) for Neotoma-related
 * dev servers, MCP stdio shims, and build helpers. Does not call the Neotoma HTTP API.
 */
import type { Command } from "commander";
export type OutputMode = "json" | "pretty";
export type NeotomaProcessRow = {
    pid: number;
    ppid: number;
    label: string;
    command: string;
    /** TCP LISTEN ports for this PID (`lsof`); empty when none or lsof unavailable. */
    ports: number[];
    /**
     * Heuristic environment: `dev` | `prod` | `mix` (conflicting signals) | `?` (unknown).
     * Derived from argv tokens (NEOTOMA_ENV, npm script names, launchd wrappers) and listen ports.
     */
    env_hint: string;
    /**
     * Stable role tags for filtering / tooling (e.g. `server`, `mcp`, `build`, `orchestrator`, `tunnel`, `tooling`, `other`).
     */
    categories: string[];
};
type PsProcessNode = {
    pid: number;
    ppid: number;
    command: string;
};
/** One row for `neotoma processes servers` (Neotoma server-class processes). */
export type NeotomaServerProcessSummary = {
    pid: number;
    /** Resolved `NEOTOMA_ENV` when visible, else nearest stack-level heuristic `env_hint`. */
    neotoma_env: string;
    /** Comma-separated TCP listen ports for this stack (3080/3180 first when present), or `-`. */
    port: string;
    /** LaunchAgent label on macOS when inferable from the process ancestry, else `-`. */
    launchagent: string;
    /** `NEOTOMA_DATA_DIR` when visible on this PID or its nearest server stack peer, else `-`. */
    data_dir: string;
    /**
     * Likely log locations for this PID (deduped): event log file, app logs directory when distinct,
     * `neotoma api start --background` api.log under ~/.config/neotoma, optional MCP session log under
     * NEOTOMA_PROJECT_ROOT (mirrors `src/config.ts` + CLI conventions; best-effort).
     */
    log_paths: string[];
};
export type ProcessesCliHooks = {
    resolveOutputMode: () => OutputMode;
    writeOutput: (value: unknown, mode: OutputMode) => void;
    writeCliError: (err: unknown) => void;
};
export declare function parsePsSnapshotNodes(raw: string): PsProcessNode[];
/** Exported for unit tests: classify argv into a short label, or null if not Neotoma-related. */
export declare function classifyNeotomaProcess(args: string): string | null;
/**
 * Derive display categories from the process classifier label and full argv.
 * Exported for unit tests.
 */
export declare function deriveProcessCategories(label: string, command: string): string[];
/**
 * Heuristic dev / prod / mixed / unknown from argv and listen ports.
 * Exported for unit tests.
 */
export declare function inferProcessEnvHint(command: string, ports: readonly number[]): string;
/** Exported for tests. */
export declare function parsePsSnapshotForNeotoma(raw: string): NeotomaProcessRow[];
/** Parse `lsof -nP -iTCP -sTCP:LISTEN -F pn` lines into pid → listen port set. */
export declare function parseLsofPnOutput(raw: string): Map<number, Set<number>>;
/** Extract TCP port from lsof `-F n` value (e.g. `*:3080`, `127.0.0.1:18080`, `[::1]:8080`). */
export declare function extractTcpListenPortFromLsofNameField(value: string): number | null;
export declare function enrichProcessRowsWithListenPorts(rows: NeotomaProcessRow[]): NeotomaProcessRow[];
/** Recompute `env_hint` (uses listen ports) and `categories` after ports are known. */
export declare function finalizeNeotomaProcessRows(rows: NeotomaProcessRow[]): NeotomaProcessRow[];
export declare function scanNeotomaProcesses(): NeotomaProcessRow[];
/** Parse `/proc/<pid>/environ` (Linux). Exported for unit tests via buffer helper. */
export declare function parseProcEnvironBuffer(buf: Buffer): Map<string, string>;
/**
 * Extract `KEY=value` from a ps argv string (cross-env / inline env).
 * Paths with spaces are not captured (returns undefined).
 */
export declare function extractInlineEnvAssignment(command: string, key: string): string | undefined;
/** Map NEOTOMA_ENV-style values to short labels for the servers table. */
export declare function shortNeotomaEnvLabel(raw: string | undefined): string | undefined;
/**
 * macOS launchd hint: direct child of PID 1, LaunchAgents/Daemons paths, or known launchd entry scripts.
 * On non-macOS returns `-`.
 */
export declare function inferLaunchdCell(platform: NodeJS.Platform, ppid: number, command: string): string;
export declare function inferLaunchAgentLabel(platform: NodeJS.Platform, pid: number, ppid: number, command: string, psIndex: ReadonlyMap<number, PsProcessNode>): string;
/**
 * Whether resolved paths should use production layout (`logs_prod`, `events.prod.log`, …).
 * Mirrors `src/config.ts` `env === "production"` when `NEOTOMA_ENV` is unknown.
 */
export declare function inferIsProductionForLogs(envMap: Map<string, string> | null, command: string, neotoma_env: string, ports: readonly number[]): boolean;
/**
 * Best-effort log locations for a server PID (mirrors `src/config.ts` + `src/shared/local_transport.ts`
 * session log + CLI background api.log). Omits paths that cannot be inferred without `NEOTOMA_DATA_DIR`.
 */
export declare function resolveNeotomaServerLogPaths(input: {
    envMap: Map<string, string> | null;
    command: string;
    neotoma_env: string;
    ports: readonly number[];
    data_dir: string;
}): string[];
/** Subset of ports that are default Neotoma HTTP API candidates (3080 / 3180). */
export declare function neotomaApiListenPorts(ports: readonly number[]): number[];
/** All TCP listen ports for display: default API ports first, then ascending. */
export declare function formatListenPortsForServers(ports: readonly number[]): string;
/** Processes classified as Neotoma servers (any port; not limited to 3080/3180). */
export declare function filterNeotomaServerRows(rows: readonly NeotomaProcessRow[]): NeotomaProcessRow[];
export declare function buildNeotomaServerSummaries(rows: readonly NeotomaProcessRow[], options?: {
    psSnapshotRaw?: string;
    platform?: NodeJS.Platform;
}): NeotomaServerProcessSummary[];
export declare function parseWatchIntervalMs(raw: string | undefined, defaultMs?: number): number;
export declare function formatServersWatchSnapshot(summaries: NeotomaServerProcessSummary[], options: {
    intervalMs: number;
    refreshedAt?: Date;
}): string;
/** Word-wrap a command for a fixed-width COMMAND column (continuation lines align under column). */
export declare function wrapCommandForColumn(command: string, width: number): string[];
export declare function registerProcessesCommands(program: Command, hooks: ProcessesCliHooks): void;
export {};
//# sourceMappingURL=processes.d.ts.map