UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

39 lines (38 loc) • 2.77 kB
import type { LspOperation, LspRequestParams, LspResult } from "./lsp.js"; /** * file:// URI for an absolute path (verified on a Windows host): this serves TWO lanes — * TOC host files (NodeLspManager, host semantics correct) AND remote WS-lane container paths * (E2B/kata sidecar, Linux form). `pathToFileURL` is HOST-platform-semantic: on a win32 host it * parses a remote `/home/user/x.ts` as drive-relative → `file:///C:/home/user/x.ts` → the remote * LSP server gets a nonexistent URI (breaking the remote lane on a win32 host entirely). Structural * form detection instead (same philosophy as the fs-safety dual-family fix — paths come from the * ExecutionEnv and may be of the OTHER family than the host, so never key on process.platform): * POSIX-form absolutes are hand-assembled (percent-encoded per segment, no host path module); * drive-letter form keeps `pathToFileURL` (CC parity for Windows files). On a POSIX host the * hand-assembled branch matches `pathToFileURL(p).href` for typical paths (common characters like * spaces encode identically; exotic characters follow the stricter encodeURIComponent form, and LSP * servers accept both). */ export declare function pathToUri(p: string): string; /** * [K-PLATFORM-SWEEP] MINOR#5: structural inverse of {@link pathToUri} — the naive `file://` prefix strip * left win-form URIs as `/C:/x` (never matching the didOpen keys) and never percent-decoded (a space in a * filename broke the staleness map). Form-detected, never host `fileURLToPath` (cross-family lanes). */ export declare function uriToPath(uri: string): string; /** The follow-up method for the 2-step call ops (issued by the session after prepareCallHierarchy). */ export declare function callHierarchyMethod(op: "incomingCalls" | "outgoingCalls"): string; /** The LSP method + params for an op (incoming/outgoing FIRST issue prepareCallHierarchy — the session 2-steps). */ export declare function buildRequest(op: LspOperation, params: LspRequestParams): { method: string; params: unknown; } | undefined; /** * @param fallbackUri the QUERIED document's URI — required for `documentSymbol`, whose standard reply shape * (`DocumentSymbol[]`: name/range/selectionRange/children, NO uri and NO location) carries no location of its * own. Without it every symbol of that shape was dropped and a perfectly good reply rendered as "No results." * (HRD-LSP-6 — gopls/rust-analyzer/pyright all answer in that shape). Deliberately NOT applied to * `workspaceSymbol`/call-hierarchy: those shapes always carry their own uri, and substituting the queried * file's would attribute a symbol to the wrong file. */ export declare function parseResult(op: LspOperation, raw: unknown, fallbackUri?: string): LspResult;