@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
73 lines • 3.67 kB
TypeScript
/**
* Built-in LSP Server Definitions
*
* Defines how to locate language servers and build command strings for supported languages.
* Server definitions are pure data — they don't spawn processes themselves.
* The LSPClient uses a SandboxProcessManager to spawn from these command strings.
*/
import type { CustomLSPServer, LSPConfig, LSPServerDef } from './types.js';
/**
* Walk up from a starting directory looking for any of the given markers.
* Returns the first directory that contains a marker, or null.
*/
export declare function walkUp(startDir: string, markers: string[]): string | null;
/**
* Async version of walkUp that uses a filesystem's exists() method.
* Works with any filesystem (local, S3, GCS, composite) that implements exists().
*/
export declare function walkUpAsync(startDir: string, markers: string[], fs: {
exists(path: string): Promise<boolean>;
}): Promise<string | null>;
/**
* Find a project root by walking up from a starting directory.
* Uses default markers (tsconfig.json, package.json, go.mod, etc.).
* Used by Workspace to resolve the default LSP root at construction time.
*/
export declare function findProjectRoot(startDir: string): string | null;
/**
* Async version of findProjectRoot that uses a filesystem's exists() method.
* Works with any filesystem (local, S3, GCS, composite) that implements exists().
*/
export declare function findProjectRootAsync(startDir: string, fs: {
exists(path: string): Promise<boolean>;
}): Promise<string | null>;
/**
* Build an extension → language ID map from custom server definitions.
* Each extension is mapped to the first language ID of the server that declares it.
*
* When multiple servers declare the same extension, the last server wins
* (iteration order of `Object.values`). A warning is emitted on collision
* so the user can spot misconfiguration.
*/
export declare function buildCustomExtensions(servers?: Record<string, CustomLSPServer>): Record<string, string>;
/**
* Build a set of server definitions that incorporate LSP config overrides.
*
* Resolution order per server:
* 1. `config.binaryOverrides[id]` — explicit binary command override
* 2. Project `node_modules/.bin/` binary
* 3. `process.cwd()` `node_modules/.bin/` binary
* 4. `config.searchPaths` `node_modules/.bin/` binary lookup
* 5. Global PATH lookup (system-installed binaries)
* 6. `config.packageRunner` — package runner fallback (off by default)
*
* `config.searchPaths` also extends TypeScript module resolution
* (used to locate typescript/lib/tsserver.js when it lives outside the project).
*
* When `config.servers` is provided, custom servers are merged after built-in
* definitions. Custom servers with the same ID as a built-in will replace it.
*/
export declare function buildServerDefs(config?: LSPConfig): Record<string, LSPServerDef>;
/**
* Built-in LSP server definitions with no config overrides.
* Use `buildServerDefs(config)` when you need binaryOverrides, searchPaths, or packageRunner.
*/
export declare const BUILTIN_SERVERS: Record<string, LSPServerDef>;
/**
* Get all server definitions that can handle the given file.
* Filters by language ID match only — the manager resolves the root and checks command availability.
* Pass `defs` to use config-aware server definitions from `buildServerDefs()`.
* Pass `customExtensions` to recognize file extensions registered by custom servers.
*/
export declare function getServersForFile(filePath: string, disabledServers?: string[], defs?: Record<string, LSPServerDef>, customExtensions?: Record<string, string>): LSPServerDef[];
//# sourceMappingURL=servers.d.ts.map