import { z } from "zod";
import { ReasoningEffortSchema, RiskLevelSchema } from "../types.js";
import { APP_VERSION } from "../version.js";
const MessageSchema = z.custom((value) => {
    if (!value || typeof value !== "object")
        return false;
    const role = value.role;
    return typeof role === "string";
});
const CheckpointSchema = z.object({
    version: z.literal(1),
    createdAt: z.string(),
    appVersion: z.string(),
    personaId: z.string(),
    reasoning: ReasoningEffortSchema.optional(),
    riskLevel: RiskLevelSchema,
    history: z.array(MessageSchema),
});
export function createCheckpoint(args) {
    return {
        version: 1,
        createdAt: args.createdAt ?? new Date().toISOString(),
        appVersion: args.appVersion ?? APP_VERSION,
        personaId: args.personaId,
        reasoning: args.reasoning,
        riskLevel: args.riskLevel,
        history: args.history,
    };
}
export function parseCheckpoint(raw) {
    const parsed = JSON.parse(raw);
    return CheckpointSchema.parse(parsed);
}
//# sourceMappingURL=checkpoint.js.map