import { F as FeedbackTrajectoryStore } from '../feedback-trajectory-BxY0cKfs.js';
import { T as TraceStore } from '../store-BcFXE6LG.js';
import { z } from 'zod';
import { OpenAPIObject } from 'openapi3-ts/oas31';
import * as hono_types from 'hono/types';
import { ServerType } from '@hono/node-server';
import { Hono } from 'hono';
import '../control-runtime-Acf9CGhw.js';
import '../emitter-C2rqGH_l.js';
import '../schema-m0gsnbt3.js';
import '../dataset-BbGkaN2I.js';
import '../errors-CzMUYo7b.js';

declare const RubricDimensionSchema: z.ZodObject<{
    id: z.ZodString;
    description: z.ZodString;
    weight: z.ZodDefault<z.ZodNumber>;
    min: z.ZodDefault<z.ZodNumber>;
    max: z.ZodDefault<z.ZodNumber>;
}, z.core.$strip>;
declare const FailureModeSchema: z.ZodObject<{
    id: z.ZodString;
    description: z.ZodString;
}, z.core.$strip>;
declare const RubricSchema: z.ZodObject<{
    name: z.ZodString;
    description: z.ZodString;
    systemPrompt: z.ZodString;
    dimensions: z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        description: z.ZodString;
        weight: z.ZodDefault<z.ZodNumber>;
        min: z.ZodDefault<z.ZodNumber>;
        max: z.ZodDefault<z.ZodNumber>;
    }, z.core.$strip>>;
    failureModes: z.ZodDefault<z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        description: z.ZodString;
    }, z.core.$strip>>>;
    wins: z.ZodDefault<z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        description: z.ZodString;
    }, z.core.$strip>>>;
}, z.core.$strip>;
declare const JudgeRequestSchema: z.ZodObject<{
    rubricName: z.ZodOptional<z.ZodString>;
    rubric: z.ZodOptional<z.ZodObject<{
        name: z.ZodString;
        description: z.ZodString;
        systemPrompt: z.ZodString;
        dimensions: z.ZodArray<z.ZodObject<{
            id: z.ZodString;
            description: z.ZodString;
            weight: z.ZodDefault<z.ZodNumber>;
            min: z.ZodDefault<z.ZodNumber>;
            max: z.ZodDefault<z.ZodNumber>;
        }, z.core.$strip>>;
        failureModes: z.ZodDefault<z.ZodArray<z.ZodObject<{
            id: z.ZodString;
            description: z.ZodString;
        }, z.core.$strip>>>;
        wins: z.ZodDefault<z.ZodArray<z.ZodObject<{
            id: z.ZodString;
            description: z.ZodString;
        }, z.core.$strip>>>;
    }, z.core.$strip>>;
    content: z.ZodString;
    context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    model: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
declare const JudgeResultSchema: z.ZodObject<{
    composite: z.ZodNumber;
    dimensions: z.ZodRecord<z.ZodString, z.ZodNumber>;
    failureModes: z.ZodDefault<z.ZodArray<z.ZodString>>;
    wins: z.ZodDefault<z.ZodArray<z.ZodString>>;
    rationale: z.ZodString;
    rubricVersion: z.ZodString;
    model: z.ZodString;
    durationMs: z.ZodNumber;
}, z.core.$strip>;
declare const RubricInfoSchema: z.ZodObject<{
    name: z.ZodString;
    description: z.ZodString;
    dimensions: z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        description: z.ZodString;
        weight: z.ZodNumber;
    }, z.core.$strip>>;
    failureModes: z.ZodDefault<z.ZodArray<z.ZodString>>;
    rubricVersion: z.ZodString;
}, z.core.$strip>;
declare const ListRubricsResponseSchema: z.ZodObject<{
    rubrics: z.ZodArray<z.ZodObject<{
        name: z.ZodString;
        description: z.ZodString;
        dimensions: z.ZodArray<z.ZodObject<{
            id: z.ZodString;
            description: z.ZodString;
            weight: z.ZodNumber;
        }, z.core.$strip>>;
        failureModes: z.ZodDefault<z.ZodArray<z.ZodString>>;
        rubricVersion: z.ZodString;
    }, z.core.$strip>>;
}, z.core.$strip>;
declare const VersionResponseSchema: z.ZodObject<{
    package: z.ZodString;
    version: z.ZodString;
    wireVersion: z.ZodString;
    apiSurface: z.ZodArray<z.ZodString>;
}, z.core.$strip>;
declare const HealthResponseSchema: z.ZodObject<{
    status: z.ZodLiteral<"ok">;
    uptimeSec: z.ZodNumber;
}, z.core.$strip>;
/**
 * Minimal `TraceEvent` shape that the production runtime emits.
 * Matches `trace/schema.ts` `TraceEvent` but is duplicated here as a
 * wire schema so non-TypeScript clients can validate without depending
 * on internal types.
 */
declare const TraceEventSchema: z.ZodObject<{
    eventId: z.ZodString;
    runId: z.ZodString;
    spanId: z.ZodOptional<z.ZodString>;
    kind: z.ZodEnum<{
        policy_violation: "policy_violation";
        custom: "custom";
        error: "error";
        log: "log";
        budget_decrement: "budget_decrement";
        budget_breach: "budget_breach";
        state_mutation: "state_mutation";
        redaction_applied: "redaction_applied";
    }>;
    timestamp: z.ZodNumber;
    payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
}, z.core.$strip>;
declare const TracesIngestRequestSchema: z.ZodObject<{
    events: z.ZodArray<z.ZodObject<{
        eventId: z.ZodString;
        runId: z.ZodString;
        spanId: z.ZodOptional<z.ZodString>;
        kind: z.ZodEnum<{
            policy_violation: "policy_violation";
            custom: "custom";
            error: "error";
            log: "log";
            budget_decrement: "budget_decrement";
            budget_breach: "budget_breach";
            state_mutation: "state_mutation";
            redaction_applied: "redaction_applied";
        }>;
        timestamp: z.ZodNumber;
        payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
    }, z.core.$strip>>;
}, z.core.$strip>;
declare const TracesIngestResponseSchema: z.ZodObject<{
    accepted: z.ZodNumber;
    rejected: z.ZodNumber;
    errors: z.ZodDefault<z.ZodArray<z.ZodObject<{
        eventId: z.ZodString;
        message: z.ZodString;
    }, z.core.$strip>>>;
}, z.core.$strip>;
declare const FeedbackLabelSchema: z.ZodObject<{
    id: z.ZodOptional<z.ZodString>;
    source: z.ZodEnum<{
        judge: "judge";
        system: "system";
        user: "user";
        policy: "policy";
        environment: "environment";
        metric: "metric";
    }>;
    kind: z.ZodEnum<{
        approve: "approve";
        reject: "reject";
        select: "select";
        edit: "edit";
        rank: "rank";
        rate: "rate";
        comment: "comment";
        metric_outcome: "metric_outcome";
        policy_block: "policy_block";
        revision_request: "revision_request";
    }>;
    value: z.ZodUnknown;
    reason: z.ZodOptional<z.ZodString>;
    severity: z.ZodOptional<z.ZodEnum<{
        error: "error";
        info: "info";
        critical: "critical";
        warning: "warning";
    }>>;
    createdAt: z.ZodString;
    metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
}, z.core.$strip>;
declare const FeedbackAttemptSchema: z.ZodObject<{
    id: z.ZodString;
    stepIndex: z.ZodNumber;
    artifactType: z.ZodEnum<{
        action: "action";
        decision: "decision";
        text: "text";
        code: "code";
        plan: "plan";
        research: "research";
        ui: "ui";
        data: "data";
        other: "other";
    }>;
    artifact: z.ZodUnknown;
    options: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
    proposedAction: z.ZodOptional<z.ZodObject<{
        type: z.ZodString;
        risk: z.ZodOptional<z.ZodEnum<{
            medium: "medium";
            low: "low";
            high: "high";
        }>>;
        costUsd: z.ZodOptional<z.ZodNumber>;
        externalSideEffect: z.ZodOptional<z.ZodBoolean>;
        requiresApproval: z.ZodOptional<z.ZodBoolean>;
        metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    }, z.core.$strip>>;
    feedback: z.ZodOptional<z.ZodArray<z.ZodObject<{
        id: z.ZodOptional<z.ZodString>;
        source: z.ZodEnum<{
            judge: "judge";
            system: "system";
            user: "user";
            policy: "policy";
            environment: "environment";
            metric: "metric";
        }>;
        kind: z.ZodEnum<{
            approve: "approve";
            reject: "reject";
            select: "select";
            edit: "edit";
            rank: "rank";
            rate: "rate";
            comment: "comment";
            metric_outcome: "metric_outcome";
            policy_block: "policy_block";
            revision_request: "revision_request";
        }>;
        value: z.ZodUnknown;
        reason: z.ZodOptional<z.ZodString>;
        severity: z.ZodOptional<z.ZodEnum<{
            error: "error";
            info: "info";
            critical: "critical";
            warning: "warning";
        }>>;
        createdAt: z.ZodString;
        metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    }, z.core.$strip>>>;
    createdAt: z.ZodString;
    metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
}, z.core.$strip>;
declare const FeedbackTrajectorySchema: z.ZodObject<{
    id: z.ZodString;
    projectId: z.ZodOptional<z.ZodString>;
    scenarioId: z.ZodOptional<z.ZodString>;
    task: z.ZodObject<{
        intent: z.ZodString;
        context: z.ZodOptional<z.ZodUnknown>;
    }, z.core.$strip>;
    attempts: z.ZodDefault<z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        stepIndex: z.ZodNumber;
        artifactType: z.ZodEnum<{
            action: "action";
            decision: "decision";
            text: "text";
            code: "code";
            plan: "plan";
            research: "research";
            ui: "ui";
            data: "data";
            other: "other";
        }>;
        artifact: z.ZodUnknown;
        options: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
        proposedAction: z.ZodOptional<z.ZodObject<{
            type: z.ZodString;
            risk: z.ZodOptional<z.ZodEnum<{
                medium: "medium";
                low: "low";
                high: "high";
            }>>;
            costUsd: z.ZodOptional<z.ZodNumber>;
            externalSideEffect: z.ZodOptional<z.ZodBoolean>;
            requiresApproval: z.ZodOptional<z.ZodBoolean>;
            metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
        }, z.core.$strip>>;
        feedback: z.ZodOptional<z.ZodArray<z.ZodObject<{
            id: z.ZodOptional<z.ZodString>;
            source: z.ZodEnum<{
                judge: "judge";
                system: "system";
                user: "user";
                policy: "policy";
                environment: "environment";
                metric: "metric";
            }>;
            kind: z.ZodEnum<{
                approve: "approve";
                reject: "reject";
                select: "select";
                edit: "edit";
                rank: "rank";
                rate: "rate";
                comment: "comment";
                metric_outcome: "metric_outcome";
                policy_block: "policy_block";
                revision_request: "revision_request";
            }>;
            value: z.ZodUnknown;
            reason: z.ZodOptional<z.ZodString>;
            severity: z.ZodOptional<z.ZodEnum<{
                error: "error";
                info: "info";
                critical: "critical";
                warning: "warning";
            }>>;
            createdAt: z.ZodString;
            metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
        }, z.core.$strip>>>;
        createdAt: z.ZodString;
        metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    }, z.core.$strip>>>;
    labels: z.ZodDefault<z.ZodArray<z.ZodObject<{
        id: z.ZodOptional<z.ZodString>;
        source: z.ZodEnum<{
            judge: "judge";
            system: "system";
            user: "user";
            policy: "policy";
            environment: "environment";
            metric: "metric";
        }>;
        kind: z.ZodEnum<{
            approve: "approve";
            reject: "reject";
            select: "select";
            edit: "edit";
            rank: "rank";
            rate: "rate";
            comment: "comment";
            metric_outcome: "metric_outcome";
            policy_block: "policy_block";
            revision_request: "revision_request";
        }>;
        value: z.ZodUnknown;
        reason: z.ZodOptional<z.ZodString>;
        severity: z.ZodOptional<z.ZodEnum<{
            error: "error";
            info: "info";
            critical: "critical";
            warning: "warning";
        }>>;
        createdAt: z.ZodString;
        metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    }, z.core.$strip>>>;
    outcome: z.ZodOptional<z.ZodObject<{
        success: z.ZodOptional<z.ZodBoolean>;
        score: z.ZodOptional<z.ZodNumber>;
        metrics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
        costUsd: z.ZodOptional<z.ZodNumber>;
        detail: z.ZodOptional<z.ZodString>;
        observedAt: z.ZodOptional<z.ZodString>;
        metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    }, z.core.$strip>>;
    split: z.ZodOptional<z.ZodEnum<{
        train: "train";
        dev: "dev";
        test: "test";
        holdout: "holdout";
    }>>;
    tags: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
    createdAt: z.ZodString;
    updatedAt: z.ZodOptional<z.ZodString>;
    metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
}, z.core.$strip>;
declare const FeedbackIngestResponseSchema: z.ZodObject<{
    id: z.ZodString;
    persisted: z.ZodBoolean;
}, z.core.$strip>;
type TraceEvent = z.infer<typeof TraceEventSchema>;
type TracesIngestRequest = z.infer<typeof TracesIngestRequestSchema>;
type TracesIngestResponse = z.infer<typeof TracesIngestResponseSchema>;
type FeedbackTrajectory = z.infer<typeof FeedbackTrajectorySchema>;
type FeedbackIngestResponse = z.infer<typeof FeedbackIngestResponseSchema>;
declare const ErrorResponseSchema: z.ZodObject<{
    error: z.ZodObject<{
        code: z.ZodString;
        message: z.ZodString;
        details: z.ZodOptional<z.ZodUnknown>;
    }, z.core.$strip>;
}, z.core.$strip>;
type RubricDimension = z.infer<typeof RubricDimensionSchema>;
type FailureMode = z.infer<typeof FailureModeSchema>;
type Rubric = z.infer<typeof RubricSchema>;
type JudgeRequest = z.infer<typeof JudgeRequestSchema>;
type JudgeResult = z.infer<typeof JudgeResultSchema>;
type RubricInfo = z.infer<typeof RubricInfoSchema>;
type ListRubricsResponse = z.infer<typeof ListRubricsResponseSchema>;
type VersionResponse = z.infer<typeof VersionResponseSchema>;
type ErrorResponse = z.infer<typeof ErrorResponseSchema>;
/**
 * Bump on any breaking change to a request/response schema.
 * Non-breaking (additive) changes don't require a bump.
 */
declare const WIRE_VERSION = "1.0.0";
/**
 * Stable hash of a rubric. Used to make scores comparable across runs:
 * if the rubricVersion matches, the rubric was identical.
 */
declare function hashRubric(rubric: Rubric): string;

/**
 * Pure handler functions — the "business logic" behind every wire-protocol
 * method. The HTTP server (`server.ts`) and the stdio RPC (`rpc.ts`) both
 * call these. Tests call these directly without spinning a server.
 *
 * Each handler:
 *   - Takes a parsed request (already Zod-validated by the transport).
 *   - Returns a result that matches the response schema.
 *   - Throws `WireError` for caller-fixable errors (404, 400, 422).
 *   - Lets unexpected errors bubble — the transport maps them to 500.
 */

/** Caller-fixable error. The transport renders this to 4xx + ErrorResponse. */
declare class WireError extends Error {
    readonly code: string;
    readonly status: number;
    readonly details?: unknown | undefined;
    constructor(code: string, message: string, status?: number, details?: unknown | undefined);
}
declare function handleJudge(req: JudgeRequest): Promise<JudgeResult>;
declare function handleListRubrics(): ListRubricsResponse;
declare function handleVersion(): VersionResponse;
/**
 * Pluggable stores the wire layer routes ingestion writes into. Both
 * are optional — when omitted, the corresponding endpoint returns 503.
 *
 * Production deployments wire a `FileSystemTraceStore` and
 * `FileSystemFeedbackTrajectoryStore` here. Tests substitute in-memory
 * stores.
 */
interface IngestionStores {
    traceStore?: TraceStore;
    feedbackStore?: FeedbackTrajectoryStore;
}
/**
 * `POST /v1/traces/ingest` — accept a batch of `TraceEvent`s from the
 * production runtime. Best-effort: each event is appended independently;
 * one bad event does not poison the batch.
 *
 * Idempotency: the underlying store is append-only; consumers retrying
 * the same payload will get duplicate events. Consumers should
 * de-duplicate by `eventId` downstream — production traces frequently
 * land via at-least-once buses (Kafka, SQS) where dedup is unavoidable.
 */
declare function handleTracesIngest(req: TracesIngestRequest, stores: IngestionStores): Promise<TracesIngestResponse>;
/**
 * `POST /v1/feedback` — accept a single `FeedbackTrajectory` from the
 * production runtime. Idempotent on `id`: re-posting the same trajectory
 * replaces the prior record.
 */
declare function handleFeedbackIngest(req: FeedbackTrajectory, stores: IngestionStores): Promise<FeedbackIngestResponse>;

declare function buildOpenApi(packageVersion: string): OpenAPIObject;

interface RpcRequest {
    method: 'judge' | 'listRubrics' | 'version';
    params?: unknown;
}
interface RpcSuccess {
    result: unknown;
}
interface RpcError {
    error: {
        code: string;
        message: string;
        details?: unknown;
    };
}
declare function dispatchRpc(req: RpcRequest): Promise<RpcSuccess | RpcError>;
/** Read one JSON request from stdin, write one JSON response to stdout. */
declare function runRpcOnce(method?: string): Promise<number>;
/** Read JSONL requests from stdin, write JSONL responses to stdout. */
declare function runRpcBatch(method?: string): Promise<number>;

/**
 * Built-in rubrics shipped with agent-eval.
 *
 * A rubric is a set of scoring axes plus a system prompt that tells the
 * judging LLM how to grade against those axes. Built-in rubrics are
 * curated for use cases that recur across Tangle projects — call them
 * by name from any client.
 *
 * Adding a rubric:
 *   1. Define the Rubric object below with a clear `description` and
 *      named `dimensions`.
 *   2. Register it in `BUILTIN_RUBRICS` at the bottom.
 *   3. Add a test in `tests/wire/rubrics.test.ts`.
 *
 * Custom rubrics: callers pass `rubric` inline to /v1/judge instead of
 * `rubricName` — see schemas.ts.
 */

declare const BUILTIN_RUBRICS: Record<string, Rubric>;
/** Get a built-in rubric by name, or undefined. */
declare function getBuiltinRubric(name: string): Rubric | undefined;
/** List built-in rubrics with their stable versions. */
declare function listBuiltinRubrics(): {
    name: string;
    description: string;
    dimensions: {
        id: string;
        description: string;
        weight: number;
    }[];
    failureModes: string[];
    rubricVersion: string;
}[];

interface CreateAppOptions {
    /** Stores wired to the ingestion endpoints. */
    stores?: IngestionStores;
    /**
     * Bearer-token auth. When provided, every endpoint EXCEPT `/healthz`
     * and `/v1/version` requires `Authorization: Bearer <token>`. The
     * token may be a static string OR a function for time-bounded /
     * rotating tokens.
     *
     * Recommended for any server that accepts ingestion writes from the
     * public internet. Read-only deployments may omit it.
     */
    auth?: {
        bearer: string | ((token: string) => boolean | Promise<boolean>);
    };
}
declare function createApp(opts?: CreateAppOptions): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
interface ServeOptions extends CreateAppOptions {
    /** Default 5005. */
    port?: number;
    /** Default '127.0.0.1'. Set to '0.0.0.0' to listen on all interfaces. */
    host?: string;
}
declare function startServer(opts?: ServeOptions): ServerType;
interface StartedServer {
    server: ServerType;
    /** The OS-assigned port. When opts.port was 0, this is the actual port the
     *  kernel bound — callers that need to dial back (smoke tests, sidecars
     *  registering with a parent) read this rather than guessing a free port. */
    port: number;
    /** Resolved host the server bound to (defaults to 127.0.0.1). */
    host: string;
    /** Close the server. Resolves once active connections have drained. */
    close(): Promise<void>;
}
/**
 * Promise-returning variant of `startServer` that resolves once the server is
 * listening and surfaces the resolved bound port. Use this from smoke tests
 * (`startServerAsync({ port: 0 })`) and any caller that needs to dial back.
 */
declare function startServerAsync(opts?: ServeOptions): Promise<StartedServer>;

export { BUILTIN_RUBRICS, type ErrorResponse, ErrorResponseSchema, type FailureMode, FailureModeSchema, FeedbackAttemptSchema, type FeedbackIngestResponse, FeedbackIngestResponseSchema, FeedbackLabelSchema, type FeedbackTrajectory, FeedbackTrajectorySchema, HealthResponseSchema, type IngestionStores, type JudgeRequest, JudgeRequestSchema, type JudgeResult, JudgeResultSchema, type ListRubricsResponse, ListRubricsResponseSchema, type Rubric, type RubricDimension, RubricDimensionSchema, type RubricInfo, RubricInfoSchema, RubricSchema, type ServeOptions, type StartedServer, type TraceEvent, TraceEventSchema, type TracesIngestRequest, TracesIngestRequestSchema, type TracesIngestResponse, TracesIngestResponseSchema, type VersionResponse, VersionResponseSchema, WIRE_VERSION, WireError, buildOpenApi, createApp, dispatchRpc, getBuiltinRubric, handleFeedbackIngest, handleJudge, handleListRubrics, handleTracesIngest, handleVersion, hashRubric, listBuiltinRubrics, runRpcBatch, runRpcOnce, startServer, startServerAsync };
