New shared package: packages/palace/ (@bytelyst/palace) Modules: - types.ts — BasePalaceWingDoc, RoomDoc, MemoryDoc, TunnelDoc, KGTripleDoc, DiaryDoc - halls.ts — HallType union, HALL_PRESETS (notelett/mindlyst/coding), hallFromLabel() - cosine.ts — cosineSimilarity(), topKByCosine(), normalizeVector() - dedup.ts — isContentDuplicate(), isExactDuplicate(), findClosestMatch() - decay.ts — computeDecayedRelevance(), boostRelevance() - extraction.ts — buildExtractionPrompt(), parseExtractionResponse(), regexFallbackExtraction() - kg.ts — findContradictions(), mergeTriples(), isTripleCurrent() - wakeup.ts — buildWakeUpLayers(), truncateToTokenBudget(), WAKEUP_PRESETS - config.ts — palaceConfigSchema (Zod) 7 test files, 91 tests passing. Consumed by NoteLett, MindLyst, and future palace-enabled products.
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
/**
|
|
* Palace configuration schema — Zod-based env var validation.
|
|
*
|
|
* Products extend their backend config with these palace-specific vars.
|
|
*/
|
|
|
|
import { z } from 'zod';
|
|
|
|
export const palaceConfigSchema = z.object({
|
|
PALACE_ENABLED: z
|
|
.enum(['true', 'false'])
|
|
.default('true')
|
|
.transform(v => v === 'true'),
|
|
|
|
PALACE_WAKE_UP_BUDGET: z.coerce.number().default(800),
|
|
|
|
PALACE_DEDUP_THRESHOLD: z.coerce.number().min(0).max(1).default(0.9),
|
|
|
|
PALACE_RELEVANCE_HALF_LIFE_DAYS: z.coerce.number().min(1).default(30),
|
|
|
|
PALACE_MAX_MEMORIES_PER_SEARCH: z.coerce.number().min(1).default(20),
|
|
|
|
PALACE_EXTRACTION_MAX_CHARS: z.coerce.number().min(100).default(6000),
|
|
});
|
|
|
|
export type PalaceConfig = z.infer<typeof palaceConfigSchema>;
|
|
|
|
/**
|
|
* Parse palace config from environment.
|
|
* Products typically merge this with their own config schema.
|
|
*/
|
|
export function parsePalaceConfig(
|
|
env: Record<string, string | undefined> = process.env as Record<string, string | undefined>
|
|
): PalaceConfig {
|
|
return palaceConfigSchema.parse(env);
|
|
}
|