import { CodeSurface } from '@tangle-network/agent-eval/campaign';
import { AgentCandidateCodeDisabled, AgentCandidateCodeNoOp, AgentCandidateGitHubRepository, AgentProfile, AgentProfileDiff, AgentCandidateProfile, AgentCandidateExecution, AgentCandidateKnowledge, AgentCandidateMemoryPolicy, AgentCandidateLineage, Sha256Digest, AgentCandidateArtifactRef, AgentCandidateWorkspaceSnapshotEvidence } from '@tangle-network/agent-interface';
import { a9 as sealAgentCandidateBundle, a0 as PreparedAgentCandidateExecution, j as AgentCandidateExecutionClaim, l as AgentCandidateExecutionClaimStore, k as AgentCandidateExecutionClaimResult, i as AgentCandidateExecutionAttemptRef, h as AgentCandidateExecutionAttemptRecord, p as AgentCandidateExecutionLease, r as AgentCandidateExecutionPhaseResult, v as AgentCandidateExecutionTerminalResult, t as AgentCandidateExecutionStageResult, o as AgentCandidateExecutionFinishResult, s as AgentCandidateExecutionRecoveryEvidence, M as AgentCandidateOutputArtifactPort, N as AgentCandidateOutputPurpose, L as AgentCandidateModelPort, R as AgentCandidateProtectedModelReservation, O as AgentCandidateProtectedModelActivation, S as AgentCandidateProtectedModelSettlement, z as AgentCandidateExecutorPort, b as AgentCandidateExecutionPorts, W as AgentCandidateVerificationPorts, a5 as VerifiedAgentCandidate, G as AgentCandidateExecutorWorkspaceFile, X as AgentCandidateWorkspacePort } from '../prepare-DIeVgQG3.js';
export { d as AgentCandidateArtifactPort, e as AgentCandidateBenchmarkGraderIdentity, f as AgentCandidateBenchmarkGraderPort, A as AgentCandidateBundleInput, g as AgentCandidateContainerPort, m as AgentCandidateExecutionCleanupHandles, n as AgentCandidateExecutionFailureClass, q as AgentCandidateExecutionPhase, u as AgentCandidateExecutionTerminalRecord, w as AgentCandidateExecutionUsage, x as AgentCandidateExecutorFinalCapture, y as AgentCandidateExecutorMemoryCapture, B as AgentCandidateExecutorProfileFile, C as AgentCandidateExecutorRequest, D as AgentCandidateExecutorStopRequest, F as AgentCandidateExecutorTaskOutcomeCapture, H as AgentCandidateExecutorWorkspaceInput, I as AgentCandidateMemoryPort, J as AgentCandidateMemoryResetResult, K as AgentCandidateModelLimits, Q as AgentCandidateProtectedModelCall, T as AgentCandidateProtectedRunCapture, U as AgentCandidateRepositoryPort, V as AgentCandidateRetryRejection, c as AgentCandidateRunFinalization, a as AgentCandidateTaskExecution, Y as CANDIDATE_TRACE_ENV, Z as CANDIDATE_TRACE_TAGS, _ as CanonicalCandidateDocument, E as ExecutePreparedAgentCandidateOptions, $ as InMemoryAgentCandidateExecutionClaimStore, P as PrepareAgentCandidateExecutionOptions, a1 as PreparedAgentCandidateInstruction, a2 as PreparedAgentCandidateLaunch, a3 as PreparedAgentCandidateTrace, a4 as ResolvedAgentCandidateContainer, a6 as VerifiedAgentCandidateTaskOutcome, a7 as executePreparedAgentCandidate, a8 as prepareAgentCandidateExecution } from '../prepare-DIeVgQG3.js';
import { TraceStore } from '@tangle-network/agent-eval';

/** A complete profile that can be frozen without losing behavior. */
type AgentCandidateProfileSource = {
    kind: 'profile';
    profile: AgentProfile;
} | {
    kind: 'profile-diffs';
    base: AgentProfile;
    /** Applied in order. Each exact diff is content-addressed into lineage. */
    diffs: readonly AgentProfileDiff[];
} | {
    kind: 'candidate-profile';
    /** Already converted to the closed, secret-free candidate profile contract. */
    profile: AgentCandidateProfile;
};
/** The only accepted path from an agent-eval code candidate to executable bytes. */
interface AgentCandidateCodeSurfaceSource {
    kind: 'code-surface';
    surface: CodeSurface;
    repository: AgentCandidateGitHubRepository;
    /** Optional parent directory used to resolve a relative `surface.worktreeRef`. */
    worktreeDir?: string;
}
/** Explicit control/no-op code or one finalized CodeSurface whose bytes must still verify. */
type AgentCandidateCodeSource = AgentCandidateCodeDisabled | AgentCandidateCodeNoOp | AgentCandidateCodeSurfaceSource;
/** Complete measured surfaces and execution policy compiled into one candidate bundle. */
interface BuildAgentCandidateBundleInput {
    profile: AgentCandidateProfileSource;
    code: AgentCandidateCodeSource;
    execution: AgentCandidateExecution;
    knowledge?: AgentCandidateKnowledge;
    memory: AgentCandidateMemoryPolicy;
    /** `profileDiffIds` is derived from `profile`; callers cannot contradict it. */
    lineage: Omit<AgentCandidateLineage, 'profileDiffIds'>;
}
/**
 * Compile one measured profile/code candidate into the immutable execution
 * contract. Code bytes are re-read and verified by agent-eval before they are
 * embedded. The returned bundle is schema-validated, canonically digested, and
 * deeply immutable; call `verifyAgentCandidateBundle` at the execution boundary
 * to re-read external knowledge, memory, repository, and workspace artifacts.
 */
declare function buildAgentCandidateBundle(input: BuildAgentCandidateBundleInput): ReturnType<typeof sealAgentCandidateBundle>;

/** Extract the complete durable claim from a prepared execution. */
declare function candidateExecutionClaim(prepared: PreparedAgentCandidateExecution): AgentCandidateExecutionClaim;

interface FileAgentCandidateExecutionClaimStoreOptions {
    /** Evaluator-owned directory shared by every process allowed to execute candidates. */
    directory: string;
    /** Testable evaluator clock; defaults to `Date.now`. */
    now?: () => number;
}
/** Cross-process lifecycle implemented as fsynced, create-if-absent records. */
declare class FileAgentCandidateExecutionClaimStore implements AgentCandidateExecutionClaimStore {
    private readonly directory;
    private readonly now;
    constructor(options: FileAgentCandidateExecutionClaimStoreOptions);
    tryClaim(requested: AgentCandidateExecutionClaim): Promise<AgentCandidateExecutionClaimResult>;
    getAttempt(requestedAttempt: AgentCandidateExecutionAttemptRef): Promise<AgentCandidateExecutionAttemptRecord | undefined>;
    markCandidateMayRun(requestedLease: AgentCandidateExecutionLease): Promise<AgentCandidateExecutionPhaseResult>;
    stageTerminal(requestedLease: AgentCandidateExecutionLease, result: AgentCandidateExecutionTerminalResult): Promise<AgentCandidateExecutionStageResult>;
    finish(requestedLease: AgentCandidateExecutionLease, requestedTerminalDigest: Sha256Digest): Promise<AgentCandidateExecutionFinishResult>;
    recoverExpired(requestedAttempt: AgentCandidateExecutionAttemptRef, evidence: AgentCandidateExecutionRecoveryEvidence): Promise<AgentCandidateExecutionFinishResult>;
    private storedAttempt;
    private transitionState;
    private retryFailure;
    private ownerPublication;
    private claimPath;
    private terminalPath;
    private transitionPath;
}

interface DisposePreparedAgentCandidateOptions {
    cleanupTimeoutMs?: number;
}
/** Revoke reservations held by a prepared candidate that will not be executed. */
declare function disposePreparedAgentCandidateExecution(prepared: PreparedAgentCandidateExecution, options?: DisposePreparedAgentCandidateOptions): Promise<{
    disposed: true;
}>;

/** Persist evaluator evidence, read it back, and bind the returned locator to the exact bytes. */
declare function persistCandidateOutputArtifact(port: AgentCandidateOutputArtifactPort, input: {
    executionId: string;
    purpose: AgentCandidateOutputPurpose;
    bytes: Uint8Array;
    signal?: AbortSignal;
}): Promise<AgentCandidateArtifactRef>;

/** Parse a complete profile without silently discarding unsupported fields. */
declare function parseExactAgentProfile(input: unknown, label: string): AgentProfile;
/** Parse a profile diff without silently discarding unsupported fields. */
declare function parseExactAgentProfileDiff(input: unknown, label: string): AgentProfileDiff;
/** Apply one exact diff and reject any value that cannot be preserved canonically. */
declare function applyExactAgentProfileDiff(baseInput: unknown, diffInput: unknown, label: string): AgentProfile;

type AgentCandidateModelGrantReserveInput = Parameters<AgentCandidateModelPort['reserveGrant']>[0];
type AgentCandidateModelGrantActivateInput = Parameters<AgentCandidateModelPort['activateGrant']>[0];
type AgentCandidateModelGrantSettleInput = Parameters<AgentCandidateModelPort['settleGrant']>[0];
/** Secret-free response from the service's reservation endpoint. */
type AgentCandidateModelGrantReservation = AgentCandidateProtectedModelReservation;
/**
 * Narrow transport contract for a service that owns scoped model credentials
 * and the authoritative per-call usage ledger.
 *
 * An HTTP client can bind these methods to control-plane endpoints. Keeping
 * transport out of the runtime prevents parent credentials, endpoint paths,
 * and retry policy from becoming part of the portable candidate contract.
 */
interface AgentCandidateModelGrantClient {
    reserve(input: AgentCandidateModelGrantReserveInput): Promise<AgentCandidateModelGrantReservation>;
    activate(input: AgentCandidateModelGrantActivateInput): Promise<AgentCandidateProtectedModelActivation>;
    settle(input: AgentCandidateModelGrantSettleInput): Promise<AgentCandidateProtectedModelSettlement>;
}
interface CreateProtectedAgentCandidateModelPortOptions {
    client: AgentCandidateModelGrantClient;
    /** Catalog/snapshot resolution stays separate from credential issuance. */
    resolveModel: AgentCandidateModelPort['resolve'];
    /** The only public DNS name candidate processes may reach for inference. */
    gatewayDomain: string;
    /** Exact environment names the activation endpoint must return, no more or fewer. */
    activationEnvNames: readonly string[];
}
/**
 * Bind a protected model-grant service to the immutable candidate runtime.
 *
 * The service remains the authority for expiry, admission, revocation, and
 * metering. This adapter independently checks every response before allowing
 * it to cross into candidate execution or durable receipt finalization.
 */
declare function createProtectedAgentCandidateModelPort(options: CreateProtectedAgentCandidateModelPortOptions): AgentCandidateModelPort;

interface RecoverExpiredAgentCandidateOptions {
    attempt: AgentCandidateExecutionAttemptRef;
    claimStore: AgentCandidateExecutionClaimStore;
    executor: AgentCandidateExecutorPort;
    traceStore: TraceStore;
    ports: Pick<AgentCandidateExecutionPorts, 'models' | 'memory'>;
    outputArtifacts: AgentCandidateOutputArtifactPort;
    cleanupTimeoutMs?: number;
    /** Evaluator clock; must be the same clock used by the claim store. */
    now?: () => number;
}
/** Close an expired crashed attempt from persisted non-secret handles, then record failure. */
declare function recoverExpiredAgentCandidateExecution(options: RecoverExpiredAgentCandidateOptions): Promise<AgentCandidateExecutionFinishResult>;

/** Verifies every digest, resource, workspace, and Git object in a candidate bundle. */
declare function verifyAgentCandidateBundle(input: unknown, ports: AgentCandidateVerificationPorts): Promise<VerifiedAgentCandidate>;

interface AgentCandidateWorkspaceArchiveLimits {
    maxArchiveBytes: number;
    maxEmbeddedArtifactBytes: number;
    maxFiles: number;
    maxFileBytes: number;
    maxTotalFileBytes: number;
    maxPathBytes: number;
    maxRepositoryBundleBytes: number;
}
interface CaptureAgentCandidateWorkspaceOptions {
    /** Include Git HEAD so task preparation can prove its exact commit and tree. */
    includeRepository?: boolean;
    limits?: Partial<AgentCandidateWorkspaceArchiveLimits>;
    /** Use the evaluator-owned artifact store when manifest or archive bytes should not be embedded. */
    artifactPersistence?: {
        executionId: string;
        outputArtifacts: AgentCandidateOutputArtifactPort;
        signal?: AbortSignal;
    };
}
interface CreateAgentCandidateWorkspacePortOptions {
    limits?: Partial<AgentCandidateWorkspaceArchiveLimits>;
}
interface CapturedAgentCandidateWorkspace {
    readonly snapshot: AgentCandidateWorkspaceSnapshotEvidence;
    /** Caller-owned bytes accepted by createAgentCandidateWorkspacePort. */
    readonly archive: Uint8Array;
}
/** Capture one exact regular-file workspace for immutable candidate execution. */
declare function captureAgentCandidateWorkspace(rootInput: string, options?: CaptureAgentCandidateWorkspaceOptions): Promise<CapturedAgentCandidateWorkspace>;
/** Capture detached files returned by a remote executor into the standard archive. */
declare function captureAgentCandidateWorkspaceFiles(input: readonly AgentCandidateExecutorWorkspaceFile[], options?: Omit<CaptureAgentCandidateWorkspaceOptions, 'includeRepository'>): Promise<CapturedAgentCandidateWorkspace>;
/** Create the standard bounded materializer for candidate execution ports. */
declare function createAgentCandidateWorkspacePort(options?: CreateAgentCandidateWorkspacePortOptions): AgentCandidateWorkspacePort;

export { type AgentCandidateCodeSource, type AgentCandidateCodeSurfaceSource, AgentCandidateExecutionAttemptRecord, AgentCandidateExecutionAttemptRef, AgentCandidateExecutionClaim, AgentCandidateExecutionClaimResult, AgentCandidateExecutionClaimStore, AgentCandidateExecutionFinishResult, AgentCandidateExecutionLease, AgentCandidateExecutionPhaseResult, AgentCandidateExecutionPorts, AgentCandidateExecutionRecoveryEvidence, AgentCandidateExecutionStageResult, AgentCandidateExecutionTerminalResult, AgentCandidateExecutorPort, AgentCandidateExecutorWorkspaceFile, type AgentCandidateModelGrantActivateInput, type AgentCandidateModelGrantClient, type AgentCandidateModelGrantReservation, type AgentCandidateModelGrantReserveInput, type AgentCandidateModelGrantSettleInput, AgentCandidateModelPort, AgentCandidateOutputArtifactPort, AgentCandidateOutputPurpose, type AgentCandidateProfileSource, AgentCandidateProtectedModelActivation, AgentCandidateProtectedModelReservation, AgentCandidateProtectedModelSettlement, AgentCandidateVerificationPorts, type AgentCandidateWorkspaceArchiveLimits, AgentCandidateWorkspacePort, type BuildAgentCandidateBundleInput, type CaptureAgentCandidateWorkspaceOptions, type CapturedAgentCandidateWorkspace, type CreateAgentCandidateWorkspacePortOptions, type CreateProtectedAgentCandidateModelPortOptions, type DisposePreparedAgentCandidateOptions, FileAgentCandidateExecutionClaimStore, type FileAgentCandidateExecutionClaimStoreOptions, PreparedAgentCandidateExecution, type RecoverExpiredAgentCandidateOptions, VerifiedAgentCandidate, applyExactAgentProfileDiff, buildAgentCandidateBundle, candidateExecutionClaim, captureAgentCandidateWorkspace, captureAgentCandidateWorkspaceFiles, createAgentCandidateWorkspacePort, createProtectedAgentCandidateModelPort, disposePreparedAgentCandidateExecution, parseExactAgentProfile, parseExactAgentProfileDiff, persistCandidateOutputArtifact, recoverExpiredAgentCandidateExecution, sealAgentCandidateBundle, verifyAgentCandidateBundle };
