/**
 * @fileoverview Shared helper functions for route modules.
 *
 * Contains pure functions extracted from server.ts and a session lookup helper
 * that replaces ~43 inline not-found checks across route handlers.
 */
import type { z } from 'zod';
import { Session } from '../session.js';
import type { SessionPort } from './ports/session-port.js';
import type { EventPort } from './ports/event-port.js';
export declare const CASES_DIR: string;
export declare const SETTINGS_PATH: string;
/**
 * Validates that a path component doesn't escape the base directory.
 * Returns the resolved full path, or null if the path is a traversal attempt.
 */
export declare function validatePathWithinBase(name: string, baseDir: string): string | null;
/**
 * Reads and parses a JSON config file, returning a default value on ENOENT.
 * Logs an error for any I/O failure other than a missing file.
 */
export declare function readJsonConfig<T>(filePath: string, logLabel: string, defaultValue: T): Promise<T>;
/**
 * Validates that a file path (possibly containing symlinks) resolves to a location
 * within the given session working directory. Returns the resolved and relative paths,
 * or null if the path escapes the directory or doesn't exist.
 */
export declare function validateSessionFilePath(sessionWorkingDir: string, filePath: string): {
    resolvedPath: string;
    relativePath: string;
} | null;
/**
 * Look up a session by ID or throw a structured error.
 * Replaces the pattern: `const session = sessions.get(id); if (!session) return createErrorResponse(...)`.
 */
export declare function findSessionOrFail(ctx: SessionPort, sessionId: string): Session;
/**
 * Parse and validate a request body against a Zod schema, or throw a structured 400 error.
 * Replaces the repeated pattern: `const r = Schema.safeParse(body); if (!r.success) return createErrorResponse(...)`.
 */
export declare function parseBody<T>(schema: z.ZodType<T>, body: unknown, errorMessage?: string): T;
/**
 * Persist session state and broadcast a SessionUpdated event.
 * Replaces the repeated two-line pattern across route handlers.
 */
export declare function persistAndBroadcastSession(ctx: SessionPort & EventPort, session: Session): void;
/**
 * Formats uptime in seconds to a human-readable string (e.g., "1d 2h 30m 15s").
 */
export declare function formatUptime(seconds: number): string;
/**
 * Sanitizes hook event data before broadcasting via SSE.
 * Extracts only relevant fields and limits total size to prevent
 * oversized payloads from being broadcast to all connected clients.
 */
export declare function sanitizeHookData(data: Record<string, unknown> | null | undefined): Record<string, unknown>;
/**
 * Toggles a service (watcher/manager) on or off based on an enabled flag.
 * Logs start/stop to console with the given label. Runs an optional callback after starting.
 */
export declare function toggleService(enabled: boolean, service: {
    isRunning(): boolean;
    start(): void;
    stop(): void;
}, label: string, onStart?: () => void): void;
/**
 * Auto-configure Ralph tracker for a session.
 *
 * Priority order:
 * 1. .claude/ralph-loop.local.md (official Ralph Wiggum plugin state)
 * 2. CLAUDE.md <promise> tags (fallback)
 *
 * The ralph-loop.local.md file has priority because it contains
 * the exact configuration from an active Ralph loop session.
 */
export declare function autoConfigureRalph(session: Session, workingDir: string, ctx: EventPort): void;
//# sourceMappingURL=route-helpers.d.ts.map