import type { BrowserLabScoringContext } from "./adapter-extension.js"; import type { TerminalProductScoringContext } from "./e2b-terminal-lab.js"; import type { LabBackend } from "./lab-engine.js"; import type { RunAdapterArtifact, RunAdapterScore, RunFeedbackCandidate, RunScorerProvenance } from "./run.js"; /** The read-model context a loaded scorer sees — the terminal or browser scoring context. The module * narrows it at runtime (`"product" in ctx` ⇒ terminal; `"backend" in ctx` ⇒ browser). */ export type AdapterScoringContext = TerminalProductScoringContext | BrowserLabScoringContext; /** * The adopter-facing scorer module contract (#316). Export any subset of these from a `.mjs` (or a * `.js`/`.cjs` whose package.json type matches) — named exports OR a single default object. The * loader wires ONLY these three; an exported `executor`/`env`/`provisionSubject`/`costProbe` is never * picked up (the whitelist is the scope guard). A module exporting NONE of them is a hard load error. */ export interface AdapterScorerModule { score?: (ctx: AdapterScoringContext) => RunAdapterScore | Promise; deriveFeedback?: (ctx: AdapterScoringContext) => RunFeedbackCandidate[] | Promise; /** Browser-route only; inert on the terminal route (TerminalProductLabHooks carries no artifacts seam). */ deriveArtifacts?: (ctx: BrowserLabScoringContext) => RunAdapterArtifact[] | Promise; } export type AdapterScorerLoadErrorCode = "HUMANISH_LAB_SCORER_BAD_REF" | "HUMANISH_LAB_SCORER_NOT_FOUND" | "HUMANISH_LAB_SCORER_LOAD_FAILED" | "HUMANISH_LAB_SCORER_NO_HOOKS" | "HUMANISH_LAB_SCORER_UNSUPPORTED_BACKEND"; export type AdapterScorerLoadResult = { ok: true; hooks: AdapterScorerModule; provenance: RunScorerProvenance; } | { ok: false; error: { code: AdapterScorerLoadErrorCode; message: string; }; }; /** * Resolve + load a config-declared scorer module. Resolution clones scenario.ref exactly * (prepareSelectedOutputDirectory → cwd-clamp → readContainedRegularFile), then `import()`s the * entry file in a BROAD try/catch. The digest is over the readContainedRegularFile ENTRY bytes. */ export declare function loadAdapterScorer(args: { cwd: string; ref: string; backend: LabBackend; source: "manifest" | "cli-flag"; }): Promise;