import type { GateOutcome, WorkerClaim, WorkerRequest } from "../autonomy/contracts.ts"; import { type EvidenceFindingDraft } from "../autonomy/evidence-finding-projection.ts"; import type { LaneTerminalStatus } from "../autonomy/lane-tracker.ts"; import type { WorkerRole } from "../orchestration/contracts.ts"; import { buildVerifierSystemPrompt, buildWorkerSystemPrompt, WORKER_LANE_SYSTEM_PROMPT, WORKER_OPERATOR_LANE_SYSTEM_PROMPT, WORKER_WRITE_LANE_SYSTEM_PROMPT } from "../provider-prompt-contracts.ts"; import { type AppliedActionsReport, type RejectedWorkerActions, type WorkerAction } from "./worker-actions.ts"; export { buildVerifierSystemPrompt, buildWorkerSystemPrompt, WORKER_LANE_SYSTEM_PROMPT, WORKER_OPERATOR_LANE_SYSTEM_PROMPT, WORKER_WRITE_LANE_SYSTEM_PROMPT, }; /** * Pure execution for one bounded specialist delegation: bounded isolated completion -> * parse -> untrusted `WorkerClaim` -> parent validation via {@link validateWorkerClaim}. * * The injected completion may be a bounded worker tool loop. Its tool surface is built and gated by * the host; this module keeps the structured-output contract and treats every claim as untrusted * until parent validation succeeds. */ export interface WorkerCompletion { text: string; costUsd: number; stopReason: string; /** Files successfully changed by the worker tool loop before it produced the final JSON. */ changedFiles?: readonly string[]; /** Capability refusals or execution failures observed inside the worker tool loop. */ blockers?: readonly string[]; } export interface WorkerRunnerOptions { request: WorkerRequest; /** Budget for this delegation; undefined disables this bound, while zero permits only free work. */ maxUsd?: number; /** Wall-clock budget in milliseconds; 0 disables. */ maxWallClockMs: number; /** * Pre-allocated spawned-usage report id. Always stamped on the claim so parent validation can * enforce the cost-visibility invariant (a completed claim without a usage report is blocked). */ usageReportId: string; complete: (args: { systemPrompt: string; userPrompt: string; signal: AbortSignal; }) => Promise; /** Live successful worker-tool mutations, including writes completed before timeout/cancellation. */ getChangedFiles?: () => readonly string[]; signal?: AbortSignal; now?: () => string; /** Enables the WRITE lane: only honored when the request envelope grants "filesystem.write". The * runner applies the worker's structured actions through the envelope path scope; refusals * and failures become blockers, never silent drops. */ applyActions?: (actions: readonly WorkerAction[]) => AppliedActionsReport; /** Enables the constrained direct-argv operator role prompt. */ processCapable?: boolean; /** Session cwd — the baseline for relative changed-file and envelope paths in parent * validation. Defaults to process.cwd(). */ cwd?: string; /** Turns the worker into a read-only semantic verifier for this exact durable task. */ verificationSubjectTaskId?: string; } export interface WorkerRunOutcome { claim: WorkerClaim; /** Parent-review verdict from {@link validateWorkerClaim}; worker output stays untrusted. */ acceptance: GateOutcome; accepted: boolean; laneStatus: LaneTerminalStatus; reasonCode: string; /** Underlying executor error for bounded failures; drives the in-process retry decision. */ reasonDetail?: string; costUsd: number; /** * Set by the caller (worker-delegation-controller.ts admission), never by runWorker itself, when * a pin policy is active, the effective role has no pin, and the caller requested an explicit * model — i.e. the owner's model pin was evaded, not merely inapplicable. Diagnostics only. */ modelPinBypass?: WorkerRole; } export declare function buildWorkerUserPrompt(request: WorkerRequest): string; export interface ParsedWorkerOutput { summary: string; status: "completed" | "blocked"; blockers: string[]; findings: EvidenceFindingDraft[]; actions: WorkerAction[]; /** Present when the model emitted an action list that cannot safely reach execution. */ actionRejection?: RejectedWorkerActions; verdict?: "accepted" | "rejected"; reasonCodes: string[]; } export declare function parseWorkerOutput(text: string): ParsedWorkerOutput | undefined; export declare function runWorker(options: WorkerRunnerOptions): Promise; //# sourceMappingURL=worker-runner.d.ts.map