UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

57 lines (56 loc) • 3.95 kB
/** * 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, 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). No manager ⇒ 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 { LspDiagnosticsRegistry } from "../lsp-diagnostics.js"; import type { RunnerDeps, TaskSpec } from "../types.js"; import type { Prepared } from "./contracts.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, and the nudge's resolution base when * no cwd is tracked. */ taskRootFinal: string; /** borrowed-readonly — whether a real fs env is present (the lane's hands precondition). */ handsEnabled: boolean; /** borrowed-readonly — the acquired session id: the run's key into the deployment-shared registry. */ sessionId: string; /** borrowed-readonly — the tracked-cwd cell the hands band writes; the nudge READS `current` per call as its * resolution base (identity is the contract — the band's `cd` handling writes this exact cell). */ handsCwdRef: Prepared["cwdRef"]; /** borrowed-mutable — the run's roster builder (identity is the contract). Writer here: ONE mount (the LSP tool) * when a manager exists. */ 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; /** 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;