import { z } from "zod";
const SkillCategorySchema = z.enum([
  "tool",
  // Tool-specific patterns
  "workflow",
  // Process/workflow improvements
  "correction",
  // User corrections to remember
  "pattern",
  // Code/architecture patterns
  "preference",
  // User preferences
  "pitfall",
  // Things to avoid
  "optimization"
  // Performance/efficiency tips
]);
const SkillPrioritySchema = z.enum([
  "critical",
  // Always include in context
  "high",
  // Include when relevant
  "medium",
  // Include if space permits
  "low"
  // Archive/reference only
]);
const SkillSchema = z.object({
  id: z.string().uuid(),
  // Content
  content: z.string().min(1).max(5e3),
  summary: z.string().max(500).optional(),
  // Classification
  category: SkillCategorySchema,
  priority: SkillPrioritySchema.default("medium"),
  tags: z.array(z.string()).default([]),
  // Context
  tool: z.string().optional(),
  // Related tool name
  project: z.string().optional(),
  // Project context
  language: z.string().optional(),
  // Programming language
  framework: z.string().optional(),
  // Framework context
  // Validation tracking
  validatedCount: z.number().int().min(0).default(0),
  lastValidated: z.string().datetime().optional(),
  // Lifecycle
  createdAt: z.string().datetime(),
  updatedAt: z.string().datetime(),
  expiresAt: z.string().datetime().optional(),
  // Source tracking
  source: z.enum(["correction", "observation", "explicit", "inferred"]),
  sessionId: z.string().optional()
});
const CreateSkillSchema = SkillSchema.omit({
  id: true,
  createdAt: true,
  updatedAt: true,
  validatedCount: true
});
const UpdateSkillSchema = SkillSchema.partial().extend({
  id: z.string().uuid()
});
const JournalEntryTypeSchema = z.enum([
  "decision",
  // Architectural/design decision
  "correction",
  // User corrected agent behavior
  "blocker",
  // Issue encountered
  "resolution",
  // How an issue was resolved
  "observation",
  // Noticed pattern or behavior
  "outcome"
  // Result of an action
]);
const JournalEntrySchema = z.object({
  id: z.string().uuid(),
  sessionId: z.string(),
  type: JournalEntryTypeSchema,
  // Content
  title: z.string().max(200),
  content: z.string().max(5e3),
  // Context
  context: z.object({
    file: z.string().optional(),
    tool: z.string().optional(),
    command: z.string().optional()
  }).optional(),
  // Outcome tracking
  outcome: z.enum(["success", "failure", "partial", "pending"]).optional(),
  // Timestamps
  createdAt: z.string().datetime(),
  // Link to promoted skill
  promotedToSkillId: z.string().uuid().optional()
});
const SessionSummarySchema = z.object({
  sessionId: z.string(),
  startedAt: z.string().datetime(),
  endedAt: z.string().datetime().optional(),
  // Stats
  entriesCount: z.number().int().min(0),
  correctionsCount: z.number().int().min(0),
  decisionsCount: z.number().int().min(0),
  // Key learnings from this session
  keyLearnings: z.array(z.string()).default([]),
  // Skills promoted from this session
  promotedSkillIds: z.array(z.string().uuid()).default([])
});
const SkillQuerySchema = z.object({
  // Filter by classification
  categories: z.array(SkillCategorySchema).optional(),
  priorities: z.array(SkillPrioritySchema).optional(),
  tags: z.array(z.string()).optional(),
  // Filter by context
  tool: z.string().optional(),
  project: z.string().optional(),
  language: z.string().optional(),
  framework: z.string().optional(),
  // Filter by validation
  minValidatedCount: z.number().int().min(0).optional(),
  // Pagination
  limit: z.number().int().min(1).max(100).default(50),
  offset: z.number().int().min(0).default(0),
  // Sorting
  sortBy: z.enum(["priority", "validatedCount", "createdAt", "updatedAt"]).default("priority"),
  sortOrder: z.enum(["asc", "desc"]).default("desc")
});
const REDIS_KEYS = {
  // Skills (namespaced by user)
  skill: (userId, id) => `user:${userId}:skill:${id}`,
  skillsByTool: (userId, tool) => `user:${userId}:skills:tool:${tool}`,
  skillsByCategory: (userId, category) => `user:${userId}:skills:category:${category}`,
  skillsByTag: (userId, tag) => `user:${userId}:skills:tag:${tag}`,
  skillsRecent: (userId) => `user:${userId}:skills:recent`,
  skillsValidated: (userId) => `user:${userId}:skills:validated`,
  // Session journal (namespaced by user)
  journalEntry: (userId, id) => `user:${userId}:journal:entry:${id}`,
  journalSession: (userId, sessionId) => `user:${userId}:journal:session:${sessionId}`,
  journalRecent: (userId) => `user:${userId}:journal:recent`,
  // Session tracking (namespaced by user)
  sessionSummary: (userId, sessionId) => `user:${userId}:session:summary:${sessionId}`,
  sessionsActive: (userId) => `user:${userId}:sessions:active`,
  // Promotion tracking (namespaced by user)
  promotionCandidates: (userId) => `user:${userId}:skills:promotion:candidates`,
  // Locks (global)
  syncLock: (resource) => `lock:skill:${resource}`
};
const CACHE_TTL = {
  // Base skill TTL: 7 days minimum
  skillBase: 604800,
  // 7 days
  // Max skill TTL: 90 days for frequently used skills
  skillMax: 7776e3,
  // 90 days
  // TTL increment per validation/use: +7 days
  skillIncrement: 604800,
  // 7 days
  skillIndex: 86400,
  // 1 day (was 1 hour)
  session: 604800,
  // 7 days
  journal: 2592e3,
  // 30 days
  lock: 30
  // 30 seconds
};
function calculateSkillTTL(validatedCount) {
  const ttl = CACHE_TTL.skillBase + validatedCount * CACHE_TTL.skillIncrement;
  return Math.min(ttl, CACHE_TTL.skillMax);
}
export {
  CACHE_TTL,
  CreateSkillSchema,
  JournalEntrySchema,
  JournalEntryTypeSchema,
  REDIS_KEYS,
  SessionSummarySchema,
  SkillCategorySchema,
  SkillPrioritySchema,
  SkillQuerySchema,
  SkillSchema,
  UpdateSkillSchema,
  calculateSkillTTL
};
//# sourceMappingURL=types.js.map
