LSP Integration

Give agents code intelligence via Language Server Protocol — definitions, references, hover, diagnostics, and symbols.

The LSP integration connects agents to language servers for rich code intelligence. When enabled, the agent gets an LSP tool that can query definitions, references, hover information, document symbols, and workspace symbols.

Configuration

import { Agent } from "noumen";
import { LocalSandbox } from "noumen/local";

const code = new Agent({
  provider,
  sandbox: LocalSandbox({ cwd: "/my/project" }),
  options: {
    lsp: {
      typescript: {
        command: "typescript-language-server",
        args: ["--stdio"],
        fileExtensions: [".ts", ".tsx", ".js", ".jsx"],
      },
      python: {
        command: "pyright-langserver",
        args: ["--stdio"],
        fileExtensions: [".py"],
      },
    },
  },
});

LspServerConfig

interface LspServerConfig {
  command: string;              // Command to start the server
  args?: string[];              // Arguments to pass
  rootUri?: string;             // Workspace root URI
  fileExtensions: string[];     // Extensions this server handles
  env?: Record<string, string>; // Environment variables
}

LSP operations

The LSP tool supports these operations:

OperationDescription
goToDefinitionJump to the definition of a symbol at a given position.
findReferencesFind all references to a symbol.
hoverGet hover information (type signatures, documentation).
documentSymbolList all symbols in a file.
workspaceSymbolSearch for symbols across the workspace.

DiagnosticRegistry

The DiagnosticRegistry collects diagnostics (errors, warnings) published by language servers:

import { DiagnosticRegistry } from "noumen/lsp";

const registry = new DiagnosticRegistry();
// Diagnostics are registered automatically by LspServerManager
const diagnostics = registry.peek(); // read without clearing
registry.flush(); // read and clear

Types

interface LspDiagnostic {
  filePath: string;
  line: number;
  character: number;
  severity: "error" | "warning" | "info" | "hint";
  message: string;
  source?: string;
}

interface LspLocation {
  filePath: string;
  line: number;
  character: number;
}

interface LspSymbol {
  name: string;
  kind: string;
  location: LspLocation;
  containerName?: string;
}