import type { AgentAllowlistEnforcement, AgentProvider, AgentSandbox, AgentSessionContract, AgentTarget, WorkflowStep } from "../types.js"; export type ProviderPromptChannel = "stdin" | "argv"; export interface ProviderCapabilities { /** Sandbox values the provider CLI accepts; empty when sandboxing is unsupported. */ sandbox: readonly AgentSandbox[]; /** Tool/command restrictions exposed by this adapter. Metadata-only means advisory, not provider-enforced. */ allowlist: ProviderAllowlistCapabilities; /** Whether the provider runs as a durable background agent instead of a one-shot process. */ durable: boolean; /** Whether the provider can be dispatched to a remote machine transport. */ remote: boolean; /** How the prompt reaches the provider process. */ promptChannel: ProviderPromptChannel; } export interface ProviderAllowlistCapabilities { tools: AgentAllowlistEnforcement; commands: AgentAllowlistEnforcement; } export interface AgentInvocation { command: string; args: string[]; /** Prompt delivered on stdin; unset only for argv-channel providers. */ stdin?: string; /** Executables of which at least one must exist besides the command itself. */ preflightAnyOf?: string[]; } export interface PreparedAgentInvocation { /** Invocation built from the first validated snapshot. */ invocation: AgentInvocation; /** Rebuild only cwd-dependent fields while reusing that same snapshot. */ forCwd(cwd: string): AgentInvocation; } export interface ProviderAdapter { provider: AgentProvider; capabilities: ProviderCapabilities; validate(target: AgentTarget, label?: string): void; buildInvocation(target: AgentTarget): AgentInvocation; prepareInvocation(target: AgentTarget): PreparedAgentInvocation; } export declare function effectiveAgentSandbox(target: AgentTarget): AgentSandbox | "provider-default"; export declare function agentSessionContract(target: AgentTarget, cwd?: string | undefined): AgentSessionContract | undefined; export declare function workflowStepAgentSessionContract(step: WorkflowStep): AgentSessionContract | undefined; export declare function agentSessionContractPrompt(target: AgentTarget, cwd?: string | undefined): string | undefined; export declare const PROVIDER_ADAPTERS: Record; export declare const AGENT_PROVIDERS: AgentProvider[]; export declare function providerAdapter(provider: AgentProvider): ProviderAdapter; /** Validate an untrusted or persisted agent target without relying on TypeScript-only shape guarantees. */ export declare function validateAgentTarget(target: unknown, label?: string): asserts target is AgentTarget; export interface SpawnCaptureOptions { cwd?: string; env?: NodeJS.ProcessEnv; timeoutMs: number; maxOutputBytes?: number; } export interface CapturedProcessResult { status: number | null; signal: NodeJS.Signals | null; stdout: string; stderr: string; error?: string; timedOut: boolean; } export declare function killProcessGroup(pgid: number): void; /** * Byte-bounded UTF-8 output accumulator shared by the capture paths * (spawnCapture here, executeTarget/executeRemoteSpec in executor.ts). * * - Callers feed decoded strings (`stream.setEncoding("utf8")` keeps * multi-byte sequences split across pipe chunks intact); the buffer never * decodes chunks itself. * - Truncation keeps at most `maxBytes` BYTES of tail, cutting at a UTF-8 * sequence boundary so the retained text never starts mid-character. * - The truncation marker reports the CUMULATIVE dropped byte count. * - The accumulated text is scrubbed BEFORE every cut: truncation can bisect * a credential so the surviving fragment no longer matches any scrub * pattern, while scrubbing first turns the intact token into [SCRUBBED] * and the cut then slices through the marker harmlessly (scrubSecrets is * idempotent, so store-time re-scrubbing stays safe). */ export declare class BoundedOutputBuffer { private readonly maxBytes; private text; private truncatedBytes; constructor(maxBytes: number); append(chunk: string): void; value(): string; } /** * Async replacement for short spawnSync calls: never blocks the event loop and * always enforces an explicit timeout that kills the child's process group. */ export declare function spawnCapture(command: string, args: string[], opts: SpawnCaptureOptions): Promise;