@sema-agent/core
Version:
Stateless, task-oriented AI agent core
59 lines (58 loc) • 4.35 kB
TypeScript
/**
* PrepareTask's LSP phase, verbatim from the driver: the manager fold (spec > deps), the
* LSP tool mount over the per-task env with its git-ignore filter and the leg's read face, the diagnostics lane behind its
* four preconditions (a manager whose sessions feed a registry, write-capable hands, not opted out), the run-scoped
* registry key, and the edit nudge (raw path → the SAME resolution the tool leg uses → registry reset +
* session didChange through the read face). No manager, or no read face (a hands-less leg; the manifest still reports the
* seat, `mounted: false`), ⇒ nothing mounts and both lane seats are undefined. The interface is the dependency list the
* segment had implicitly.
*
* SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await, so the phase adds no yield between the
* fork-governance note before it and the memory trio's occupancy read after it (a stretch
* with no await is extracted as a sync function — an `async` wrapper would open a microtask window).
* Read-stability of the host handles for the call: {@link RunInternals} (`@contract prepare.deps-read-stable`).
*/
import type { ExecutionEnv } from "../../internal/harness.js";
import { type LspListedWithholding, type LspReadFace } from "../lsp.js";
import type { LspDiagnosticsRegistry } from "../lsp-diagnostics.js";
import type { RunnerDeps, TaskSpec } from "../types.js";
import { RosterBuilder } from "../tool-roster.js";
export interface PrepareLspInput {
/** borrowed-readonly — the REBOUND spec. Read: `lspManager` (the per-task manager, outranks the deployment's),
* `lspDiagnostics` (the lane's opt-out), `handsReadOnly` (a read-only run has no lane). Never mutated. */
spec: Pick<TaskSpec, "lspManager" | "lspDiagnostics" | "handsReadOnly">;
/** borrowed-readonly — the deployment's manager seat (read only when the spec carries none). */
deps: Pick<RunnerDeps, "lspManager">;
/** borrowed-readonly — the run's resolved env: the tool's in-env server and git-ignore filter, and the
* session lookup the nudge performs. */
executionEnv: ExecutionEnv;
/** borrowed-readonly — the SETTLED task root: the tool's git-ignore root. */
taskRootFinal: string;
/** borrowed-readonly — the leg's read face (the hands phase's root, read roots, deny table, containment face, tracked
* cwd and file read station admission), present exactly when hands mounted: LSP mounts only under it, and the tool,
* the nudge and the diagnostics lane read every file through it. */
readFace: LspReadFace | undefined;
/** borrowed-readonly — the acquired session id: the run's key into the deployment-shared registry. */
sessionId: string;
/** borrowed-mutable — the run's roster builder (identity is the contract). Writer here: ONE mount (the LSP tool)
* when a manager and a read face exist. */
roster: RosterBuilder;
/** borrowed-mutable — the env-hand membership set the read-posture observer projects; writer here: `add("LSP")`
* on the mount. */
envHandToolNames: Set<string>;
}
export interface PrepareLspResult {
/** borrowed-readonly — the manager's diagnostics registry when the lane is live, else undefined (the
* registry is a DEPLOYMENT object shared by every task; this run reads and resets it under its own key). */
lspDiagnostics: LspDiagnosticsRegistry | undefined;
/** owned — the edit nudge (raw path in), or undefined when the lane is not live. */
nudgeLspOnEdit: ((rawPath: string) => void) | undefined;
/** owned — the files of a drain the read face withholds (`lspListedWithheld`: every view, fail-closed; kept files
* absent), or undefined when the lane is not live. */
withheldDiagnosticsOf: ((uris: readonly string[]) => Promise<ReadonlyMap<string, LspListedWithholding>>) | undefined;
/** borrowed-readonly — the run's registry key (= the session id): one run per session, released at the terminal. */
lspRunIdent: string;
/** Did a MANAGER seat resolve? The manifest's LSP-section presence condition, from the ONE fold that decided the mount. */ managerWired: boolean;
}
/** The M8 phase body — prepareTask's LSP stretch, verbatim (see the module header). */
export declare function prepareLsp(input: PrepareLspInput): PrepareLspResult;