Spaces:
Runtime error
Runtime error
File size: 1,441 Bytes
cd8bd0a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import { z } from "zod";
import { MemoryType } from "./types";
/**
* MemoryConfig schema - validates memory system configuration settings
*/
export const MemoryConfigSchema = z.object({
enabled: z.boolean(),
maxTokens: z.number().int().nonnegative(),
retrievalStrategy: z.enum(["exact", "semantic", "hybrid"]).optional(),
autoSummarize: z.boolean(),
persistAcrossModels: z.boolean(),
retentionDays: z.number().int().positive(),
scope: z.enum(["session", "apiKey", "global"]).optional(),
});
/**
* MemoryCreateInput schema - validates input for creating new memories
*/
export const MemoryCreateInputSchema = z
.object({
type: z.nativeEnum(MemoryType),
key: z.string().min(1),
content: z.string().min(1),
metadata: z.record(z.string(), z.unknown()).optional(),
})
.strict();
/**
* MemoryUpdateInput schema - validates input for partially updating existing memories
*/
export const MemoryUpdateInputSchema = z
.object({
type: z.nativeEnum(MemoryType).optional(),
key: z.string().min(1).optional(),
content: z.string().min(1).optional(),
metadata: z.record(z.string(), z.unknown()).optional(),
})
.strict();
/**
* Exported schema types for TypeScript references
*/
export type MemoryConfig = z.infer<typeof MemoryConfigSchema>;
export type MemoryCreateInput = z.infer<typeof MemoryCreateInputSchema>;
export type MemoryUpdateInput = z.infer<typeof MemoryUpdateInputSchema>;
|