import { z } from "zod";
const ReviewModeSchema = z.enum(["core-axis", "full"]);
const ReviewTargetScopeKindSchema = z.enum(["file", "directory", "bundle"]);
const ExecutorRealizationSchema = z.enum(["codex", "mock", "ts_inline_http"]);
const ReviewResultProjectionLevelSchema = z.enum(["compact", "standard", "full"]);
const DeliberationModeSchema = z.enum([
    "controlled_lens_deliberation",
]);
const OntoReviewToolInputBaseSchema = z.object({
    target: z.string().min(1),
    intent: z.string().min(1),
    targetScopeKind: ReviewTargetScopeKindSchema.optional(),
    primaryRef: z.string().min(1).optional(),
    memberRefs: z.array(z.string().min(1)).optional(),
    bundleKind: z.string().min(1).optional(),
    diffRange: z.string().min(1).optional(),
    projectRoot: z.string().min(1).optional(),
    domain: z.string().min(1).optional(),
    noDomain: z.boolean().optional(),
    reviewMode: ReviewModeSchema.optional(),
    lensIds: z.array(z.string().min(1)).optional(),
    deliberation: DeliberationModeSchema.optional(),
    executorRealization: ExecutorRealizationSchema.optional(),
    confirmValueAlignment: z.boolean().optional(),
    prepareOnly: z.boolean().optional(),
    returnRunningAfterMs: z.number().int().min(0).optional(),
}).strict();
export const OntoReviewToolInputSchema = OntoReviewToolInputBaseSchema.refine((input) => !(input.domain && input.noDomain), {
    message: "Use either domain or noDomain, not both.",
});
export const OntoPrepareReviewToolInputSchema = OntoReviewToolInputBaseSchema.extend({
    prepareOnly: z.literal(true).default(true),
}).refine((input) => !(input.domain && input.noDomain), {
    message: "Use either domain or noDomain, not both.",
});
export const OntoReviewSessionInputSchema = z.object({
    sessionRoot: z.string().min(1),
    projectRoot: z.string().min(1).optional(),
});
export const OntoReviewStatusInputSchema = z.object({
    sessionRoot: z.string().min(1).optional(),
    projectRoot: z.string().min(1).optional(),
    latest: z.boolean().optional(),
    target: z.string().min(1).optional(),
    domain: z.string().min(1).optional(),
    requestHash: z.string().min(1).optional(),
    limit: z.number().int().min(1).max(20).optional(),
}).strict().refine((input) => (typeof input.sessionRoot === "string" || input.latest === true), {
    message: "Pass sessionRoot, or latest=true with optional target/domain/requestHash filters.",
});
export const OntoReviewResultInputSchema = OntoReviewSessionInputSchema.extend({
    projectionLevel: ReviewResultProjectionLevelSchema.optional(),
}).strict();
export const OntoReviewCancelToolInputSchema = OntoReviewSessionInputSchema.extend({
    reason: z.string().min(1).optional(),
}).strict();
export const OntoReviewContinueToolInputSchema = OntoReviewSessionInputSchema.extend({
    targetUnits: z.array(z.string().min(1)).optional(),
    requestText: z.string().min(1).optional(),
    executorRealization: ExecutorRealizationSchema.optional(),
}).strict();
export const OntoListDomainsToolInputSchema = z.object({
    projectRoot: z.string().min(1).optional(),
});
export const OntoListSourceProfilesToolInputSchema = z.object({
    projectRoot: z.string().min(1).optional(),
});
export const OntoObserveSourceToolInputSchema = z.object({
    targetRefs: z.array(z.string().min(1)).min(1),
    projectRoot: z.string().min(1).optional(),
    sessionRoot: z.string().min(1).optional(),
    profilesRoot: z.string().min(1).optional(),
    filesystemAllowedRoots: z.array(z.string().min(1)).optional(),
}).strict();
export const OntoReconstructToolInputSchema = OntoObserveSourceToolInputSchema.extend({
    intent: z.string().min(1),
    semanticAuthorRealization: z.enum(["mock", "direct_call"]).default("direct_call"),
    confirmationProviderRealization: z.enum(["mock", "direct_call"]).default("direct_call"),
}).strict();
export const OntoReconstructSessionInputSchema = z.object({
    sessionRoot: z.string().min(1),
    projectRoot: z.string().min(1).optional(),
}).strict();
const OntoValidateSourceObservationDirectiveToolInputSchema = z.object({
    directiveKind: z.literal("source_observation"),
    directivePath: z.string().min(1),
    sourceObservationsPath: z.string().min(1),
    outputPath: z.string().min(1).optional(),
    projectRoot: z.string().min(1).optional(),
}).strict();
const OntoValidateSeedCandidateToolInputSchema = z.object({
    directiveKind: z.literal("seed_candidate"),
    seedCandidatePath: z.string().min(1),
    sourceObservationsPath: z.string().min(1),
    sourceObservationDirectivePath: z.string().min(1).optional(),
    sourceObservationDirectiveValidationPath: z.string().min(1).optional(),
    outputPath: z.string().min(1).optional(),
    projectRoot: z.string().min(1).optional(),
}).strict();
export const OntoValidateReconstructDirectiveToolInputSchema = z.discriminatedUnion("directiveKind", [
    OntoValidateSourceObservationDirectiveToolInputSchema,
    OntoValidateSeedCandidateToolInputSchema,
]);
export const OntoToolNames = [
    "onto.review",
    "onto.prepare_review",
    "onto.review_continue",
    "onto.review_cancel",
    "onto.review_status",
    "onto.review_result",
    "onto.list_lenses",
    "onto.list_domains",
    "onto.list_source_profiles",
    "onto.observe_source",
    "onto.validate_reconstruct_directive",
    "onto.reconstruct",
    "onto.reconstruct_status",
    "onto.reconstruct_result",
];
