UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

73 lines (72 loc) 2.48 kB
/** * Server Utilities for NeuroLink CLI * Shared utility functions for server management commands (serve.ts and server.ts) */ /** * Get the base directory for NeuroLink state files * @returns Path to ~/.neurolink directory */ export declare function getNeuroLinkDir(): string; /** * Ensure the NeuroLink state directory exists * Creates ~/.neurolink if it doesn't exist */ export declare function ensureStateDir(): void; /** * Check if a process with the given PID is currently running * * Uses `process.kill(pid, 0)` which tests if a process exists without sending a signal. * * **Platform Behavior:** * - **Unix/Linux/macOS**: Returns `true` if process exists, `false` if not. * If the process exists but belongs to another user, returns `true` (via EPERM check). * - **Windows**: Behavior differs - `process.kill(pid, 0)` may throw even for existing * processes if they are system processes or have restricted access. This function * handles EPERM by returning `true`, but other Windows-specific errors may occur. * For more reliable Windows process detection, consider using `tasklist` command. * * @param pid - Process ID to check * @returns true if the process is running, false otherwise */ export declare function isProcessRunning(pid: number): boolean; /** * Format a duration in milliseconds to a human-readable uptime string * @param ms - Duration in milliseconds * @returns Formatted string like "2d 5h 30m" or "45m 30s" */ export declare function formatUptime(ms: number): string; /** * Generic state file manager for server state persistence * @template T - Type of the state object */ export declare class StateFileManager<T> { private filePath; /** * Create a new state file manager * @param filename - Name of the state file (e.g., "serve-state.json") * @param baseDir - Optional base directory (defaults to ~/.neurolink) */ constructor(filename: string, baseDir?: string); /** * Get the full path to the state file */ getFilePath(): string; /** * Save state to the state file * @param state - State object to save */ save(state: T): void; /** * Load state from the state file * @returns The state object, or null if the file doesn't exist or is invalid */ load(): T | null; /** * Clear (delete) the state file */ clear(): void; /** * Check if state file exists */ exists(): boolean; }