@stackmemoryai/stackmemory 0.5.31 → 0.5.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/claude-sm.js +199 -16
- package/dist/cli/claude-sm.js.map +2 -2
- package/dist/cli/commands/context.js +0 -11
- package/dist/cli/commands/context.js.map +2 -2
- package/dist/cli/commands/linear.js +1 -14
- package/dist/cli/commands/linear.js.map +2 -2
- package/dist/cli/commands/login.js +32 -10
- package/dist/cli/commands/login.js.map +2 -2
- package/dist/cli/commands/migrate.js +80 -22
- package/dist/cli/commands/migrate.js.map +2 -2
- package/dist/cli/commands/model.js +533 -0
- package/dist/cli/commands/model.js.map +7 -0
- package/dist/cli/commands/ralph.js +93 -28
- package/dist/cli/commands/ralph.js.map +2 -2
- package/dist/cli/commands/service.js +10 -3
- package/dist/cli/commands/service.js.map +2 -2
- package/dist/cli/commands/skills.js +60 -10
- package/dist/cli/commands/skills.js.map +2 -2
- package/dist/cli/commands/sms-notify.js +342 -22
- package/dist/cli/commands/sms-notify.js.map +3 -3
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +2 -2
- package/dist/core/context/dual-stack-manager.js +23 -7
- package/dist/core/context/dual-stack-manager.js.map +2 -2
- package/dist/core/context/frame-database.js +33 -5
- package/dist/core/context/frame-database.js.map +2 -2
- package/dist/core/context/frame-digest.js +6 -1
- package/dist/core/context/frame-digest.js.map +2 -2
- package/dist/core/context/frame-manager.js +56 -9
- package/dist/core/context/frame-manager.js.map +2 -2
- package/dist/core/context/permission-manager.js +0 -11
- package/dist/core/context/permission-manager.js.map +2 -2
- package/dist/core/context/recursive-context-manager.js +15 -9
- package/dist/core/context/recursive-context-manager.js.map +2 -2
- package/dist/core/context/shared-context-layer.js +0 -11
- package/dist/core/context/shared-context-layer.js.map +2 -2
- package/dist/core/context/validation.js +6 -1
- package/dist/core/context/validation.js.map +2 -2
- package/dist/core/models/fallback-monitor.js +229 -0
- package/dist/core/models/fallback-monitor.js.map +7 -0
- package/dist/core/models/model-router.js +331 -0
- package/dist/core/models/model-router.js.map +7 -0
- package/dist/hooks/claude-code-whatsapp-hook.js +197 -0
- package/dist/hooks/claude-code-whatsapp-hook.js.map +7 -0
- package/dist/hooks/linear-task-picker.js +1 -1
- package/dist/hooks/linear-task-picker.js.map +2 -2
- package/dist/hooks/schemas.js +55 -1
- package/dist/hooks/schemas.js.map +2 -2
- package/dist/hooks/session-summary.js +5 -1
- package/dist/hooks/session-summary.js.map +2 -2
- package/dist/hooks/sms-action-runner.js +12 -1
- package/dist/hooks/sms-action-runner.js.map +2 -2
- package/dist/hooks/sms-notify.js +4 -2
- package/dist/hooks/sms-notify.js.map +2 -2
- package/dist/hooks/sms-webhook.js +23 -2
- package/dist/hooks/sms-webhook.js.map +2 -2
- package/dist/hooks/whatsapp-commands.js +376 -0
- package/dist/hooks/whatsapp-commands.js.map +7 -0
- package/dist/hooks/whatsapp-scheduler.js +317 -0
- package/dist/hooks/whatsapp-scheduler.js.map +7 -0
- package/dist/hooks/whatsapp-sync.js +375 -0
- package/dist/hooks/whatsapp-sync.js.map +7 -0
- package/package.json +2 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/core/context/recursive-context-manager.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Recursive Context Manager for RLM\n * \n * Handles context chunking, decomposition, and distribution\n * for recursive agent execution\n */\n\nimport { DualStackManager } from './dual-stack-manager.js';\nimport { ContextRetriever } from '../retrieval/context-retriever.js';\nimport { logger } from '../monitoring/logger.js';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { SubagentType } from '../../skills/recursive-agent-orchestrator.js';\n\nexport interface ContextChunk {\n id: string;\n type: 'code' | 'frame' | 'documentation' | 'test' | 'config';\n content: string;\n metadata: {\n filePath?: string;\n frameId?: string;\n language?: string;\n size: number;\n score: number;\n timestamp?: Date;\n };\n boundaries: {\n start?: number;\n end?: number;\n overlap?: number;\n };\n}\n\nexport interface ChunkingStrategy {\n type: 'file' | 'semantic' | 'size' | 'time';\n maxChunkSize: number;\n overlapSize: number;\n priorityThreshold: number;\n}\n\nexport interface AgentContextConfig {\n agent: SubagentType;\n maxTokens: number;\n priorityWeights: {\n recent: number;\n relevant: number;\n dependency: number;\n error: number;\n test: number;\n };\n includeTypes: string[];\n excludeTypes: string[];\n}\n\n/**\n * Manages context for recursive agent execution\n */\nexport class RecursiveContextManager {\n private dualStackManager: DualStackManager;\n private contextRetriever: ContextRetriever;\n \n // Context cache for sharing between agents\n private sharedContextCache: Map<string, ContextChunk[]> = new Map();\n \n // Agent-specific configurations\n private agentConfigs: Map<SubagentType, AgentContextConfig>;\n \n constructor(\n dualStackManager: DualStackManager,\n contextRetriever: ContextRetriever\n ) {\n this.dualStackManager = dualStackManager;\n this.contextRetriever = contextRetriever;\n this.agentConfigs = this.initializeAgentConfigs();\n }\n \n /**\n * Initialize agent-specific context configurations\n */\n private initializeAgentConfigs(): Map<SubagentType, AgentContextConfig> {\n const configs = new Map<SubagentType, AgentContextConfig>();\n \n // Planning agent needs broad context\n configs.set('planning', {\n agent: 'planning',\n maxTokens: 20000,\n priorityWeights: {\n recent: 0.3,\n relevant: 0.4,\n dependency: 0.2,\n error: 0.05,\n test: 0.05,\n },\n includeTypes: ['frame', 'documentation', 'config'],\n excludeTypes: [],\n });\n \n // Code agent needs implementation context\n configs.set('code', {\n agent: 'code',\n maxTokens: 30000,\n priorityWeights: {\n recent: 0.2,\n relevant: 0.5,\n dependency: 0.2,\n error: 0.05,\n test: 0.05,\n },\n includeTypes: ['code', 'frame', 'test'],\n excludeTypes: ['documentation'],\n });\n \n // Testing agent needs code and existing tests\n configs.set('testing', {\n agent: 'testing',\n maxTokens: 25000,\n priorityWeights: {\n recent: 0.1,\n relevant: 0.3,\n dependency: 0.1,\n error: 0.1,\n test: 0.4,\n },\n includeTypes: ['code', 'test', 'frame'],\n excludeTypes: ['documentation', 'config'],\n });\n \n // Linting agent needs code and config\n configs.set('linting', {\n agent: 'linting',\n maxTokens: 15000,\n priorityWeights: {\n recent: 0.2,\n relevant: 0.4,\n dependency: 0.1,\n error: 0.2,\n test: 0.1,\n },\n includeTypes: ['code', 'config'],\n excludeTypes: ['documentation', 'test'],\n });\n \n // Review agent needs comprehensive context\n configs.set('review', {\n agent: 'review',\n maxTokens: 25000,\n priorityWeights: {\n recent: 0.3,\n relevant: 0.3,\n dependency: 0.1,\n error: 0.2,\n test: 0.1,\n },\n includeTypes: ['code', 'test', 'frame', 'documentation'],\n excludeTypes: [],\n });\n \n // Context agent for searching\n configs.set('context', {\n agent: 'context',\n maxTokens: 10000,\n priorityWeights: {\n recent: 0.1,\n relevant: 0.6,\n dependency: 0.2,\n error: 0.05,\n test: 0.05,\n },\n includeTypes: ['frame', 'documentation'],\n excludeTypes: [],\n });\n \n // Improvement agent needs review context\n configs.set('improve', {\n agent: 'improve',\n maxTokens: 30000,\n priorityWeights: {\n recent: 0.3,\n relevant: 0.4,\n dependency: 0.1,\n error: 0.15,\n test: 0.05,\n },\n includeTypes: ['code', 'test', 'frame'],\n excludeTypes: ['documentation'],\n });\n \n // Publish agent needs build/config context\n configs.set('publish', {\n agent: 'publish',\n maxTokens: 15000,\n priorityWeights: {\n recent: 0.4,\n relevant: 0.2,\n dependency: 0.1,\n error: 0.2,\n test: 0.1,\n },\n includeTypes: ['config', 'frame'],\n excludeTypes: ['code', 'test'],\n });\n \n return configs;\n }\n \n /**\n * Prepare context for a specific agent type\n */\n async prepareAgentContext(\n agentType: SubagentType,\n baseContext: Record<string, any>,\n maxTokens: number\n ): Promise<Record<string, any>> {\n const config = this.agentConfigs.get(agentType);\n if (!config) {\n throw new Error(`Unknown agent type: ${agentType}`);\n }\n \n logger.debug(`Preparing context for ${agentType} agent`, { maxTokens });\n \n // Collect relevant chunks\n const chunks = await this.collectRelevantChunks(\n baseContext,\n config,\n maxTokens\n );\n \n // Sort by priority\n const sortedChunks = this.prioritizeChunks(chunks, config.priorityWeights);\n \n // Fit within token budget\n const selectedChunks = this.fitChunksToTokenBudget(\n sortedChunks,\n maxTokens\n );\n \n // Build agent context\n const agentContext: Record<string, any> = {\n ...baseContext,\n chunks: selectedChunks.map(c => ({\n type: c.type,\n content: c.content,\n metadata: c.metadata,\n })),\n };\n \n // Cache for potential reuse\n this.sharedContextCache.set(`${agentType}-${Date.now()}`, selectedChunks);\n \n logger.debug(`Prepared context for ${agentType}`, {\n chunksSelected: selectedChunks.length,\n totalSize: selectedChunks.reduce((sum, c) => sum + c.metadata.size, 0),\n });\n \n return agentContext;\n }\n \n /**\n * Chunk large codebase for processing\n */\n async chunkCodebase(\n rootPath: string,\n strategy: ChunkingStrategy\n ): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n \n logger.info('Chunking codebase', { rootPath, strategy: strategy.type });\n \n switch (strategy.type) {\n case 'file':\n chunks.push(...await this.chunkByFile(rootPath, strategy));\n break;\n \n case 'semantic':\n chunks.push(...await this.chunkBySemantic(rootPath, strategy));\n break;\n \n case 'size':\n chunks.push(...await this.chunkBySize(rootPath, strategy));\n break;\n \n default:\n throw new Error(`Unknown chunking strategy: ${strategy.type}`);\n }\n \n logger.info('Codebase chunked', {\n totalChunks: chunks.length,\n totalSize: chunks.reduce((sum, c) => sum + c.metadata.size, 0),\n });\n \n return chunks;\n }\n \n /**\n * Chunk by file boundaries\n */\n private async chunkByFile(\n rootPath: string,\n strategy: ChunkingStrategy\n ): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n const files = await this.walkDirectory(rootPath);\n \n for (const file of files) {\n const content = await fs.promises.readFile(file, 'utf-8');\n \n // Skip files larger than max chunk size\n if (content.length > strategy.maxChunkSize) {\n // Split large files\n const fileChunks = this.splitLargeFile(file, content, strategy);\n chunks.push(...fileChunks);\n } else {\n chunks.push({\n id: `file-${path.basename(file)}`,\n type: 'code',\n content,\n metadata: {\n filePath: file,\n language: this.detectLanguage(file),\n size: content.length,\n score: 0.5,\n },\n boundaries: {\n start: 0,\n end: content.length,\n },\n });\n }\n }\n \n return chunks;\n }\n \n /**\n * Chunk by semantic boundaries (classes, functions)\n */\n private async chunkBySemantic(\n rootPath: string,\n strategy: ChunkingStrategy\n ): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n const files = await this.walkDirectory(rootPath);\n \n for (const file of files) {\n const content = await fs.promises.readFile(file, 'utf-8');\n const language = this.detectLanguage(file);\n \n // Extract semantic units based on language\n const semanticUnits = this.extractSemanticUnits(content, language);\n \n for (const unit of semanticUnits) {\n if (unit.content.length <= strategy.maxChunkSize) {\n chunks.push({\n id: `semantic-${file}-${unit.name}`,\n type: 'code',\n content: unit.content,\n metadata: {\n filePath: file,\n language,\n size: unit.content.length,\n score: unit.importance,\n },\n boundaries: {\n start: unit.start,\n end: unit.end,\n },\n });\n }\n }\n }\n \n return chunks;\n }\n \n /**\n * Chunk by fixed size with overlap\n */\n private async chunkBySize(\n rootPath: string,\n strategy: ChunkingStrategy\n ): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n const files = await this.walkDirectory(rootPath);\n \n for (const file of files) {\n const content = await fs.promises.readFile(file, 'utf-8');\n const lines = content.split('\\n');\n \n let currentChunk = '';\n let startLine = 0;\n \n for (let i = 0; i < lines.length; i++) {\n currentChunk += lines[i] + '\\n';\n \n if (currentChunk.length >= strategy.maxChunkSize) {\n chunks.push({\n id: `size-${file}-${startLine}`,\n type: 'code',\n content: currentChunk,\n metadata: {\n filePath: file,\n language: this.detectLanguage(file),\n size: currentChunk.length,\n score: 0.5,\n },\n boundaries: {\n start: startLine,\n end: i,\n overlap: strategy.overlapSize,\n },\n });\n \n // Move window with overlap\n const overlapLines = Math.floor(strategy.overlapSize / 50); // Estimate lines\n startLine = Math.max(0, i - overlapLines);\n currentChunk = lines.slice(startLine, i + 1).join('\\n');\n }\n }\n \n // Add remaining chunk\n if (currentChunk.trim()) {\n chunks.push({\n id: `size-${file}-${startLine}`,\n type: 'code',\n content: currentChunk,\n metadata: {\n filePath: file,\n language: this.detectLanguage(file),\n size: currentChunk.length,\n score: 0.5,\n },\n boundaries: {\n start: startLine,\n end: lines.length - 1,\n },\n });\n }\n }\n \n return chunks;\n }\n \n /**\n * Collect relevant chunks for agent context\n */\n private async collectRelevantChunks(\n baseContext: Record<string, any>,\n config: AgentContextConfig,\n maxTokens: number\n ): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n \n // Get recent frames\n if (config.includeTypes.includes('frame')) {\n const recentFrames = await this.getRecentFrameChunks(10);\n chunks.push(...recentFrames);\n }\n \n // Get relevant code files\n if (config.includeTypes.includes('code') && baseContext.files) {\n const codeChunks = await this.getCodeChunks(baseContext.files);\n chunks.push(...codeChunks);\n }\n \n // Get test files\n if (config.includeTypes.includes('test') && baseContext.testFiles) {\n const testChunks = await this.getTestChunks(baseContext.testFiles);\n chunks.push(...testChunks);\n }\n \n // Search for relevant context\n if (baseContext.query) {\n const searchResults = await this.contextRetriever.retrieve({\n query: baseContext.query,\n limit: 20,\n });\n \n for (const result of searchResults) {\n chunks.push({\n id: `search-${result.frameId}`,\n type: 'frame',\n content: result.content,\n metadata: {\n frameId: result.frameId,\n size: result.content.length,\n score: result.score,\n timestamp: new Date(result.timestamp),\n },\n boundaries: {},\n });\n }\n }\n \n // Check shared cache for relevant chunks\n const cachedChunks = this.getRelevantCachedChunks(config.agent);\n chunks.push(...cachedChunks);\n \n return chunks;\n }\n \n /**\n * Prioritize chunks based on agent weights\n */\n private prioritizeChunks(\n chunks: ContextChunk[],\n weights: AgentContextConfig['priorityWeights']\n ): ContextChunk[] {\n return chunks\n .map(chunk => {\n let priority = 0;\n \n // Recent weight\n if (chunk.metadata.timestamp) {\n const age = Date.now() - chunk.metadata.timestamp.getTime();\n const recentScore = Math.max(0, 1 - age / (24 * 60 * 60 * 1000)); // Decay over 24h\n priority += recentScore * weights.recent;\n }\n \n // Relevance weight\n priority += (chunk.metadata.score || 0.5) * weights.relevant;\n \n // Type-specific weights\n if (chunk.type === 'test') {\n priority += weights.test;\n }\n if (chunk.metadata.filePath?.includes('error')) {\n priority += weights.error;\n }\n \n return { ...chunk, priority };\n })\n .sort((a, b) => (b as any).priority - (a as any).priority);\n }\n \n /**\n * Fit chunks within token budget\n */\n private fitChunksToTokenBudget(\n chunks: ContextChunk[],\n maxTokens: number\n ): ContextChunk[] {\n const selected: ContextChunk[] = [];\n let totalTokens = 0;\n \n // Rough token estimation (1 token \u2248 4 chars)\n const estimateTokens = (text: string) => Math.ceil(text.length / 4);\n \n for (const chunk of chunks) {\n const chunkTokens = estimateTokens(chunk.content);\n \n if (totalTokens + chunkTokens <= maxTokens) {\n selected.push(chunk);\n totalTokens += chunkTokens;\n } else if (selected.length === 0) {\n // Always include at least one chunk, truncated if necessary\n const truncatedContent = chunk.content.slice(0, maxTokens * 4);\n selected.push({\n ...chunk,\n content: truncatedContent,\n metadata: {\n ...chunk.metadata,\n size: truncatedContent.length,\n },\n });\n break;\n } else {\n break;\n }\n }\n \n return selected;\n }\n \n /**\n * Helper methods\n */\n \n private async walkDirectory(dir: string): Promise<string[]> {\n const files: string[] = [];\n const entries = await fs.promises.readdir(dir, { withFileTypes: true });\n \n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n \n if (entry.isDirectory()) {\n // Skip node_modules, .git, etc\n if (!['node_modules', '.git', 'dist', 'build'].includes(entry.name)) {\n files.push(...await this.walkDirectory(fullPath));\n }\n } else if (entry.isFile()) {\n // Include code files\n if (/\\.(ts|tsx|js|jsx|py|java|go|rs|cpp|c|h)$/.test(entry.name)) {\n files.push(fullPath);\n }\n }\n }\n \n return files;\n }\n \n private detectLanguage(filePath: string): string {\n const ext = path.extname(filePath);\n const langMap: Record<string, string> = {\n '.ts': 'typescript',\n '.tsx': 'typescript',\n '.js': 'javascript',\n '.jsx': 'javascript',\n '.py': 'python',\n '.java': 'java',\n '.go': 'go',\n '.rs': 'rust',\n '.cpp': 'cpp',\n '.c': 'c',\n '.h': 'c',\n };\n return langMap[ext] || 'unknown';\n }\n \n private splitLargeFile(\n filePath: string,\n content: string,\n strategy: ChunkingStrategy\n ): ContextChunk[] {\n const chunks: ContextChunk[] = [];\n const lines = content.split('\\n');\n const linesPerChunk = Math.ceil(strategy.maxChunkSize / 50); // Estimate\n \n for (let i = 0; i < lines.length; i += linesPerChunk) {\n const chunkLines = lines.slice(i, i + linesPerChunk);\n const chunkContent = chunkLines.join('\\n');\n \n chunks.push({\n id: `file-${path.basename(filePath)}-part-${i}`,\n type: 'code',\n content: chunkContent,\n metadata: {\n filePath,\n language: this.detectLanguage(filePath),\n size: chunkContent.length,\n score: 0.5,\n },\n boundaries: {\n start: i,\n end: Math.min(i + linesPerChunk, lines.length),\n overlap: strategy.overlapSize,\n },\n });\n }\n \n return chunks;\n }\n \n private extractSemanticUnits(\n content: string,\n language: string\n ): Array<{\n name: string;\n content: string;\n start: number;\n end: number;\n importance: number;\n }> {\n const units: Array<{\n name: string;\n content: string;\n start: number;\n end: number;\n importance: number;\n }> = [];\n \n // Simple regex-based extraction (would need proper AST parsing for production)\n if (language === 'typescript' || language === 'javascript') {\n // Extract classes\n const classRegex = /class\\s+(\\w+)[^{]*\\{[^}]+\\}/g;\n let match;\n while ((match = classRegex.exec(content)) !== null) {\n units.push({\n name: match[1],\n content: match[0],\n start: match.index,\n end: match.index + match[0].length,\n importance: 0.8,\n });\n }\n \n // Extract functions\n const funcRegex = /(?:function|const|let)\\s+(\\w+)\\s*=?\\s*(?:\\([^)]*\\)|\\w+)\\s*(?:=>|{)[^}]+}/g;\n while ((match = funcRegex.exec(content)) !== null) {\n units.push({\n name: match[1],\n content: match[0],\n start: match.index,\n end: match.index + match[0].length,\n importance: 0.6,\n });\n }\n }\n \n return units;\n }\n \n private async getRecentFrameChunks(limit: number): Promise<ContextChunk[]> {\n const activeStack = this.dualStackManager.getActiveStack();\n const frames = await activeStack.getAllFrames();\n \n return frames.slice(-limit).map(frame => ({\n id: `frame-${frame.frameId}`,\n type: 'frame',\n content: JSON.stringify(frame, null, 2),\n metadata: {\n frameId: frame.frameId,\n size: JSON.stringify(frame).length,\n score: 0.7,\n timestamp: new Date(frame.timestamp),\n },\n boundaries: {},\n }));\n }\n \n private async getCodeChunks(files: string[]): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n \n for (const file of files) {\n if (fs.existsSync(file)) {\n const content = await fs.promises.readFile(file, 'utf-8');\n chunks.push({\n id: `code-${path.basename(file)}`,\n type: 'code',\n content,\n metadata: {\n filePath: file,\n language: this.detectLanguage(file),\n size: content.length,\n score: 0.8,\n },\n boundaries: {},\n });\n }\n }\n \n return chunks;\n }\n \n private async getTestChunks(testFiles: string[]): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n \n for (const file of testFiles) {\n if (fs.existsSync(file)) {\n const content = await fs.promises.readFile(file, 'utf-8');\n chunks.push({\n id: `test-${path.basename(file)}`,\n type: 'test',\n content,\n metadata: {\n filePath: file,\n language: this.detectLanguage(file),\n size: content.length,\n score: 0.7,\n },\n boundaries: {},\n });\n }\n }\n \n return chunks;\n }\n \n private getRelevantCachedChunks(agentType: SubagentType): ContextChunk[] {\n const relevantChunks: ContextChunk[] = [];\n \n // Get chunks from cache that might be relevant\n for (const [key, chunks] of this.sharedContextCache.entries()) {\n // Skip very old cache entries\n const timestamp = parseInt(key.split('-').pop() || '0');\n if (Date.now() - timestamp > 5 * 60 * 1000) { // 5 minutes\n continue;\n }\n \n // Add relevant chunks based on agent type\n if (agentType === 'review' || agentType === 'improve') {\n relevantChunks.push(...chunks.filter(c => c.type === 'code'));\n }\n }\n \n return relevantChunks;\n }\n \n /**\n * Clear context cache\n */\n clearCache(): void {\n this.sharedContextCache.clear();\n logger.debug('Context cache cleared');\n }\n \n /**\n * Get cache statistics\n */\n getCacheStats() {\n const stats = {\n cacheSize: this.sharedContextCache.size,\n totalChunks: 0,\n totalBytes: 0,\n };\n \n for (const chunks of this.sharedContextCache.values()) {\n stats.totalChunks += chunks.length;\n stats.total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,KAAK,MAAM,MAAM,EAAE,SAAS,MAAM,CAAC;AAAA,IACxE;AAEA,WAAO;AAAA,EACT;AACF;",
|
|
4
|
+
"sourcesContent": ["/**\n * Recursive Context Manager for RLM\n *\n * Handles context chunking, decomposition, and distribution\n * for recursive agent execution\n */\n\nimport { DualStackManager } from './dual-stack-manager.js';\nimport { ContextRetriever } from '../retrieval/context-retriever.js';\nimport { logger } from '../monitoring/logger.js';\nimport { ValidationError, ErrorCode } from '../errors/index.js';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { SubagentType } from '../../skills/recursive-agent-orchestrator.js';\n\nexport interface ContextChunk {\n id: string;\n type: 'code' | 'frame' | 'documentation' | 'test' | 'config';\n content: string;\n metadata: {\n filePath?: string;\n frameId?: string;\n language?: string;\n size: number;\n score: number;\n timestamp?: Date;\n };\n boundaries: {\n start?: number;\n end?: number;\n overlap?: number;\n };\n}\n\nexport interface ChunkingStrategy {\n type: 'file' | 'semantic' | 'size' | 'time';\n maxChunkSize: number;\n overlapSize: number;\n priorityThreshold: number;\n}\n\nexport interface AgentContextConfig {\n agent: SubagentType;\n _maxTokens: number;\n priorityWeights: {\n recent: number;\n relevant: number;\n dependency: number;\n error: number;\n test: number;\n };\n includeTypes: string[];\n excludeTypes: string[];\n}\n\n/**\n * Manages context for recursive agent execution\n */\nexport class RecursiveContextManager {\n private dualStackManager: DualStackManager;\n private contextRetriever: ContextRetriever;\n\n // Context cache for sharing between agents\n private sharedContextCache: Map<string, ContextChunk[]> = new Map();\n\n // Agent-specific configurations\n private agentConfigs: Map<SubagentType, AgentContextConfig>;\n\n constructor(\n dualStackManager: DualStackManager,\n contextRetriever: ContextRetriever\n ) {\n this.dualStackManager = dualStackManager;\n this.contextRetriever = contextRetriever;\n this.agentConfigs = this.initializeAgentConfigs();\n }\n\n /**\n * Initialize agent-specific context configurations\n */\n private initializeAgentConfigs(): Map<SubagentType, AgentContextConfig> {\n const configs = new Map<SubagentType, AgentContextConfig>();\n\n // Planning agent needs broad context\n configs.set('planning', {\n agent: 'planning',\n maxTokens: 20000,\n priorityWeights: {\n recent: 0.3,\n relevant: 0.4,\n dependency: 0.2,\n error: 0.05,\n test: 0.05,\n },\n includeTypes: ['frame', 'documentation', 'config'],\n excludeTypes: [],\n });\n\n // Code agent needs implementation context\n configs.set('code', {\n agent: 'code',\n maxTokens: 30000,\n priorityWeights: {\n recent: 0.2,\n relevant: 0.5,\n dependency: 0.2,\n error: 0.05,\n test: 0.05,\n },\n includeTypes: ['code', 'frame', 'test'],\n excludeTypes: ['documentation'],\n });\n\n // Testing agent needs code and existing tests\n configs.set('testing', {\n agent: 'testing',\n maxTokens: 25000,\n priorityWeights: {\n recent: 0.1,\n relevant: 0.3,\n dependency: 0.1,\n error: 0.1,\n test: 0.4,\n },\n includeTypes: ['code', 'test', 'frame'],\n excludeTypes: ['documentation', 'config'],\n });\n\n // Linting agent needs code and config\n configs.set('linting', {\n agent: 'linting',\n maxTokens: 15000,\n priorityWeights: {\n recent: 0.2,\n relevant: 0.4,\n dependency: 0.1,\n error: 0.2,\n test: 0.1,\n },\n includeTypes: ['code', 'config'],\n excludeTypes: ['documentation', 'test'],\n });\n\n // Review agent needs comprehensive context\n configs.set('review', {\n agent: 'review',\n maxTokens: 25000,\n priorityWeights: {\n recent: 0.3,\n relevant: 0.3,\n dependency: 0.1,\n error: 0.2,\n test: 0.1,\n },\n includeTypes: ['code', 'test', 'frame', 'documentation'],\n excludeTypes: [],\n });\n\n // Context agent for searching\n configs.set('context', {\n agent: 'context',\n maxTokens: 10000,\n priorityWeights: {\n recent: 0.1,\n relevant: 0.6,\n dependency: 0.2,\n error: 0.05,\n test: 0.05,\n },\n includeTypes: ['frame', 'documentation'],\n excludeTypes: [],\n });\n\n // Improvement agent needs review context\n configs.set('improve', {\n agent: 'improve',\n maxTokens: 30000,\n priorityWeights: {\n recent: 0.3,\n relevant: 0.4,\n dependency: 0.1,\n error: 0.15,\n test: 0.05,\n },\n includeTypes: ['code', 'test', 'frame'],\n excludeTypes: ['documentation'],\n });\n\n // Publish agent needs build/config context\n configs.set('publish', {\n agent: 'publish',\n maxTokens: 15000,\n priorityWeights: {\n recent: 0.4,\n relevant: 0.2,\n dependency: 0.1,\n error: 0.2,\n test: 0.1,\n },\n includeTypes: ['config', 'frame'],\n excludeTypes: ['code', 'test'],\n });\n\n return configs;\n }\n\n /**\n * Prepare context for a specific agent type\n */\n async prepareAgentContext(\n agentType: SubagentType,\n baseContext: Record<string, any>,\n _maxTokens: number\n ): Promise<Record<string, any>> {\n const config = this.agentConfigs.get(agentType);\n if (!config) {\n throw new ValidationError(\n `Unknown agent type: ${agentType}`,\n ErrorCode.VALIDATION_FAILED,\n { agentType }\n );\n }\n\n logger.debug(`Preparing context for ${agentType} agent`, { maxTokens });\n\n // Collect relevant chunks\n const chunks = await this.collectRelevantChunks(\n baseContext,\n config,\n maxTokens\n );\n\n // Sort by priority\n const sortedChunks = this.prioritizeChunks(chunks, config.priorityWeights);\n\n // Fit within token budget\n const selectedChunks = this.fitChunksToTokenBudget(sortedChunks, maxTokens);\n\n // Build agent context\n const agentContext: Record<string, any> = {\n ...baseContext,\n chunks: selectedChunks.map((c) => ({\n type: c.type,\n content: c.content,\n metadata: c.metadata,\n })),\n };\n\n // Cache for potential reuse\n this.sharedContextCache.set(`${agentType}-${Date.now()}`, selectedChunks);\n\n logger.debug(`Prepared context for ${agentType}`, {\n chunksSelected: selectedChunks.length,\n totalSize: selectedChunks.reduce((sum, c) => sum + c.metadata.size, 0),\n });\n\n return agentContext;\n }\n\n /**\n * Chunk large codebase for processing\n */\n async chunkCodebase(\n rootPath: string,\n strategy: ChunkingStrategy\n ): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n\n logger.info('Chunking codebase', { rootPath, strategy: strategy.type });\n\n switch (strategy.type) {\n case 'file':\n chunks.push(...(await this.chunkByFile(rootPath, strategy)));\n break;\n\n case 'semantic':\n chunks.push(...(await this.chunkBySemantic(rootPath, strategy)));\n break;\n\n case 'size':\n chunks.push(...(await this.chunkBySize(rootPath, strategy)));\n break;\n\n default:\n throw new ValidationError(\n `Unknown chunking strategy: ${strategy.type}`,\n ErrorCode.VALIDATION_FAILED,\n { strategyType: strategy.type }\n );\n }\n\n logger.info('Codebase chunked', {\n totalChunks: chunks.length,\n totalSize: chunks.reduce((sum, c) => sum + c.metadata.size, 0),\n });\n\n return chunks;\n }\n\n /**\n * Chunk by file boundaries\n */\n private async chunkByFile(\n rootPath: string,\n strategy: ChunkingStrategy\n ): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n const files = await this.walkDirectory(rootPath);\n\n for (const file of files) {\n const content = await fs.promises.readFile(file, 'utf-8');\n\n // Skip files larger than max chunk size\n if (content.length > strategy.maxChunkSize) {\n // Split large files\n const fileChunks = this.splitLargeFile(file, content, strategy);\n chunks.push(...fileChunks);\n } else {\n chunks.push({\n id: `file-${path.basename(file)}`,\n type: 'code',\n content,\n metadata: {\n filePath: file,\n language: this.detectLanguage(file),\n size: content.length,\n score: 0.5,\n },\n boundaries: {\n start: 0,\n end: content.length,\n },\n });\n }\n }\n\n return chunks;\n }\n\n /**\n * Chunk by semantic boundaries (classes, functions)\n */\n private async chunkBySemantic(\n rootPath: string,\n strategy: ChunkingStrategy\n ): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n const files = await this.walkDirectory(rootPath);\n\n for (const file of files) {\n const content = await fs.promises.readFile(file, 'utf-8');\n const language = this.detectLanguage(file);\n\n // Extract semantic units based on language\n const semanticUnits = this.extractSemanticUnits(content, language);\n\n for (const unit of semanticUnits) {\n if (unit.content.length <= strategy.maxChunkSize) {\n chunks.push({\n id: `semantic-${file}-${unit.name}`,\n type: 'code',\n content: unit.content,\n metadata: {\n filePath: file,\n language,\n size: unit.content.length,\n score: unit.importance,\n },\n boundaries: {\n start: unit.start,\n end: unit.end,\n },\n });\n }\n }\n }\n\n return chunks;\n }\n\n /**\n * Chunk by fixed size with overlap\n */\n private async chunkBySize(\n rootPath: string,\n strategy: ChunkingStrategy\n ): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n const files = await this.walkDirectory(rootPath);\n\n for (const file of files) {\n const content = await fs.promises.readFile(file, 'utf-8');\n const lines = content.split('\\n');\n\n let currentChunk = '';\n let startLine = 0;\n\n for (let i = 0; i < lines.length; i++) {\n currentChunk += lines[i] + '\\n';\n\n if (currentChunk.length >= strategy.maxChunkSize) {\n chunks.push({\n id: `size-${file}-${startLine}`,\n type: 'code',\n content: currentChunk,\n metadata: {\n filePath: file,\n language: this.detectLanguage(file),\n size: currentChunk.length,\n score: 0.5,\n },\n boundaries: {\n start: startLine,\n end: i,\n overlap: strategy.overlapSize,\n },\n });\n\n // Move window with overlap\n const overlapLines = Math.floor(strategy.overlapSize / 50); // Estimate lines\n startLine = Math.max(0, i - overlapLines);\n currentChunk = lines.slice(startLine, i + 1).join('\\n');\n }\n }\n\n // Add remaining chunk\n if (currentChunk.trim()) {\n chunks.push({\n id: `size-${file}-${startLine}`,\n type: 'code',\n content: currentChunk,\n metadata: {\n filePath: file,\n language: this.detectLanguage(file),\n size: currentChunk.length,\n score: 0.5,\n },\n boundaries: {\n start: startLine,\n end: lines.length - 1,\n },\n });\n }\n }\n\n return chunks;\n }\n\n /**\n * Collect relevant chunks for agent context\n */\n private async collectRelevantChunks(\n baseContext: Record<string, any>,\n config: AgentContextConfig,\n _maxTokens: number\n ): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n\n // Get recent frames\n if (config.includeTypes.includes('frame')) {\n const recentFrames = await this.getRecentFrameChunks(10);\n chunks.push(...recentFrames);\n }\n\n // Get relevant code files\n if (config.includeTypes.includes('code') && baseContext.files) {\n const codeChunks = await this.getCodeChunks(baseContext.files);\n chunks.push(...codeChunks);\n }\n\n // Get test files\n if (config.includeTypes.includes('test') && baseContext.testFiles) {\n const testChunks = await this.getTestChunks(baseContext.testFiles);\n chunks.push(...testChunks);\n }\n\n // Search for relevant context\n if (baseContext.query) {\n const searchResults = await this.contextRetriever.retrieve({\n query: baseContext.query,\n limit: 20,\n });\n\n for (const result of searchResults) {\n chunks.push({\n id: `search-${result.frameId}`,\n type: 'frame',\n content: result.content,\n metadata: {\n frameId: result.frameId,\n size: result.content.length,\n score: result.score,\n timestamp: new Date(result.timestamp),\n },\n boundaries: {},\n });\n }\n }\n\n // Check shared cache for relevant chunks\n const cachedChunks = this.getRelevantCachedChunks(config.agent);\n chunks.push(...cachedChunks);\n\n return chunks;\n }\n\n /**\n * Prioritize chunks based on agent weights\n */\n private prioritizeChunks(\n chunks: ContextChunk[],\n weights: AgentContextConfig['priorityWeights']\n ): ContextChunk[] {\n return chunks\n .map((chunk) => {\n let priority = 0;\n\n // Recent weight\n if (chunk.metadata.timestamp) {\n const age = Date.now() - chunk.metadata.timestamp.getTime();\n const recentScore = Math.max(0, 1 - age / (24 * 60 * 60 * 1000)); // Decay over 24h\n priority += recentScore * weights.recent;\n }\n\n // Relevance weight\n priority += (chunk.metadata.score || 0.5) * weights.relevant;\n\n // Type-specific weights\n if (chunk.type === 'test') {\n priority += weights.test;\n }\n if (chunk.metadata.filePath?.includes('error')) {\n priority += weights.error;\n }\n\n return { ...chunk, priority };\n })\n .sort((a, b) => (b as any).priority - (a as any).priority);\n }\n\n /**\n * Fit chunks within token budget\n */\n private fitChunksToTokenBudget(\n chunks: ContextChunk[],\n _maxTokens: number\n ): ContextChunk[] {\n const selected: ContextChunk[] = [];\n let totalTokens = 0;\n\n // Rough token estimation (1 token \u2248 4 chars)\n const estimateTokens = (text: string) => Math.ceil(text.length / 4);\n\n for (const chunk of chunks) {\n const chunkTokens = estimateTokens(chunk.content);\n\n if (totalTokens + chunkTokens <= maxTokens) {\n selected.push(chunk);\n totalTokens += chunkTokens;\n } else if (selected.length === 0) {\n // Always include at least one chunk, truncated if necessary\n const truncatedContent = chunk.content.slice(0, maxTokens * 4);\n selected.push({\n ...chunk,\n content: truncatedContent,\n metadata: {\n ...chunk.metadata,\n size: truncatedContent.length,\n },\n });\n break;\n } else {\n break;\n }\n }\n\n return selected;\n }\n\n /**\n * Helper methods\n */\n\n private async walkDirectory(dir: string): Promise<string[]> {\n const files: string[] = [];\n const entries = await fs.promises.readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n\n if (entry.isDirectory()) {\n // Skip node_modules, .git, etc\n if (!['node_modules', '.git', 'dist', 'build'].includes(entry.name)) {\n files.push(...(await this.walkDirectory(fullPath)));\n }\n } else if (entry.isFile()) {\n // Include code files\n if (/\\.(ts|tsx|js|jsx|py|java|go|rs|cpp|c|h)$/.test(entry.name)) {\n files.push(fullPath);\n }\n }\n }\n\n return files;\n }\n\n private detectLanguage(filePath: string): string {\n const ext = path.extname(filePath);\n const langMap: Record<string, string> = {\n '.ts': 'typescript',\n '.tsx': 'typescript',\n '.js': 'javascript',\n '.jsx': 'javascript',\n '.py': 'python',\n '.java': 'java',\n '.go': 'go',\n '.rs': 'rust',\n '.cpp': 'cpp',\n '.c': 'c',\n '.h': 'c',\n };\n return langMap[ext] || 'unknown';\n }\n\n private splitLargeFile(\n filePath: string,\n content: string,\n strategy: ChunkingStrategy\n ): ContextChunk[] {\n const chunks: ContextChunk[] = [];\n const lines = content.split('\\n');\n const linesPerChunk = Math.ceil(strategy.maxChunkSize / 50); // Estimate\n\n for (let i = 0; i < lines.length; i += linesPerChunk) {\n const chunkLines = lines.slice(i, i + linesPerChunk);\n const chunkContent = chunkLines.join('\\n');\n\n chunks.push({\n id: `file-${path.basename(filePath)}-part-${i}`,\n type: 'code',\n content: chunkContent,\n metadata: {\n filePath,\n language: this.detectLanguage(filePath),\n size: chunkContent.length,\n score: 0.5,\n },\n boundaries: {\n start: i,\n end: Math.min(i + linesPerChunk, lines.length),\n overlap: strategy.overlapSize,\n },\n });\n }\n\n return chunks;\n }\n\n private extractSemanticUnits(\n content: string,\n language: string\n ): Array<{\n name: string;\n content: string;\n start: number;\n end: number;\n importance: number;\n }> {\n const units: Array<{\n name: string;\n content: string;\n start: number;\n end: number;\n importance: number;\n }> = [];\n\n // Simple regex-based extraction (would need proper AST parsing for production)\n if (language === 'typescript' || language === 'javascript') {\n // Extract classes\n const classRegex = /class\\s+(\\w+)[^{]*\\{[^}]+\\}/g;\n let match;\n while ((match = classRegex.exec(content)) !== null) {\n units.push({\n name: match[1],\n content: match[0],\n start: match.index,\n end: match.index + match[0].length,\n importance: 0.8,\n });\n }\n\n // Extract functions\n const funcRegex =\n /(?:function|const|let)\\s+(\\w+)\\s*=?\\s*(?:\\([^)]*\\)|\\w+)\\s*(?:=>|{)[^}]+}/g;\n while ((match = funcRegex.exec(content)) !== null) {\n units.push({\n name: match[1],\n content: match[0],\n start: match.index,\n end: match.index + match[0].length,\n importance: 0.6,\n });\n }\n }\n\n return units;\n }\n\n private async getRecentFrameChunks(limit: number): Promise<ContextChunk[]> {\n const activeStack = this.dualStackManager.getActiveStack();\n const frames = await activeStack.getAllFrames();\n\n return frames.slice(-limit).map((frame) => ({\n id: `frame-${frame.frameId}`,\n type: 'frame',\n content: JSON.stringify(frame, null, 2),\n metadata: {\n frameId: frame.frameId,\n size: JSON.stringify(frame).length,\n score: 0.7,\n timestamp: new Date(frame.timestamp),\n },\n boundaries: {},\n }));\n }\n\n private async getCodeChunks(files: string[]): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n\n for (const file of files) {\n if (fs.existsSync(file)) {\n const content = await fs.promises.readFile(file, 'utf-8');\n chunks.push({\n id: `code-${path.basename(file)}`,\n type: 'code',\n content,\n metadata: {\n filePath: file,\n language: this.detectLanguage(file),\n size: content.length,\n score: 0.8,\n },\n boundaries: {},\n });\n }\n }\n\n return chunks;\n }\n\n private async getTestChunks(testFiles: string[]): Promise<ContextChunk[]> {\n const chunks: ContextChunk[] = [];\n\n for (const file of testFiles) {\n if (fs.existsSync(file)) {\n const content = await fs.promises.readFile(file, 'utf-8');\n chunks.push({\n id: `test-${path.basename(file)}`,\n type: 'test',\n content,\n metadata: {\n filePath: file,\n language: this.detectLanguage(file),\n size: content.length,\n score: 0.7,\n },\n boundaries: {},\n });\n }\n }\n\n return chunks;\n }\n\n private getRelevantCachedChunks(agentType: SubagentType): ContextChunk[] {\n const relevantChunks: ContextChunk[] = [];\n\n // Get chunks from cache that might be relevant\n for (const [key, chunks] of this.sharedContextCache.entries()) {\n // Skip very old cache entries\n const timestamp = parseInt(key.split('-').pop() || '0');\n if (Date.now() - timestamp > 5 * 60 * 1000) {\n // 5 minutes\n continue;\n }\n\n // Add relevant chunks based on agent type\n if (agentType === 'review' || agentType === 'improve') {\n relevantChunks.push(...chunks.filter((c) => c.type === 'code'));\n }\n }\n\n return relevantChunks;\n }\n\n /**\n * Clear context cache\n */\n clearCache(): void {\n this.sharedContextCache.clear();\n logger.debug('Context cache cleared');\n }\n\n /**\n * Get cache statistics\n */\n getCacheStats() {\n const stats = {\n cacheSize: this.sharedContextCache.size,\n totalChunks: 0,\n totalBytes: 0,\n };\n\n for (const chunks of this.sharedContextCache.values()) {\n stats.totalChunks += chunks.length;\n stats.totalBytes += chunks.reduce((sum, c) => sum + c.metadata.size, 0);\n }\n\n return stats;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;AASA,SAAS,cAAc;AACvB,SAAS,iBAAiB,iBAAiB;AAC3C,YAAY,QAAQ;AACpB,YAAY,UAAU;AA8Cf,MAAM,wBAAwB;AAAA,EAC3B;AAAA,EACA;AAAA;AAAA,EAGA,qBAAkD,oBAAI,IAAI;AAAA;AAAA,EAG1D;AAAA,EAER,YACE,kBACA,kBACA;AACA,SAAK,mBAAmB;AACxB,SAAK,mBAAmB;AACxB,SAAK,eAAe,KAAK,uBAAuB;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA,EAKQ,yBAAgE;AACtE,UAAM,UAAU,oBAAI,IAAsC;AAG1D,YAAQ,IAAI,YAAY;AAAA,MACtB,OAAO;AAAA,MACP,WAAW;AAAA,MACX,iBAAiB;AAAA,QACf,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,YA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MACH;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,wBAAwB,WAAyC;AACvE,UAAM,iBAAiC,CAAC;AAGxC,eAAW,CAAC,KAAK,MAAM,KAAK,KAAK,mBAAmB,QAAQ,GAAG;AAE7D,YAAM,YAAY,SAAS,IAAI,MAAM,GAAG,EAAE,IAAI,KAAK,GAAG;AACtD,UAAI,KAAK,IAAI,IAAI,YAAY,IAAI,KAAK,KAAM;AAE1C;AAAA,MACF;AAGA,UAAI,cAAc,YAAY,cAAc,WAAW;AACrD,uBAAe,KAAK,GAAG,OAAO,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,CAAC;AAAA,MAChE;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,aAAmB;AACjB,SAAK,mBAAmB,MAAM;AAC9B,WAAO,MAAM,uBAAuB;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAgB;AACd,UAAM,QAAQ;AAAA,MACZ,WAAW,KAAK,mBAAmB;AAAA,MACnC,aAAa;AAAA,MACb,YAAY;AAAA,IACd;AAEA,eAAW,UAAU,KAAK,mBAAmB,OAAO,GAAG;AACrD,YAAM,eAAe,OAAO;AAC5B,YAAM,cAAc,OAAO,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,SAAS,MAAM,CAAC;AAAA,IACxE;AAEA,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,17 +6,6 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
6
6
|
import * as fs from "fs/promises";
|
|
7
7
|
import * as path from "path";
|
|
8
8
|
import { sessionManager } from "../session/session-manager.js";
|
|
9
|
-
function getEnv(key, defaultValue) {
|
|
10
|
-
const value = process.env[key];
|
|
11
|
-
if (value === void 0) {
|
|
12
|
-
if (defaultValue !== void 0) return defaultValue;
|
|
13
|
-
throw new Error(`Environment variable ${key} is required`);
|
|
14
|
-
}
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
function getOptionalEnv(key) {
|
|
18
|
-
return process.env[key];
|
|
19
|
-
}
|
|
20
9
|
class SharedContextLayer {
|
|
21
10
|
static instance;
|
|
22
11
|
contextDir;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/core/context/shared-context-layer.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Shared Context Layer for Cross-Session Reference\n *\n * This layer maintains a lightweight shared context across sessions while\n * preserving run_id isolation for write operations. It enables:\n * - Read access to frames from other sessions\n * - Automatic context inheritance\n * - Efficient caching and indexing\n * - Safe concurrent access\n */\n\nimport { v4 as uuidv4 } from 'uuid';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\nimport { logger } from '../monitoring/logger.js';\nimport { sessionManager } from '../session/session-manager.js';\nimport type { Frame } from '../frame-manager/frame-manager.js';\n// Type-safe environment variable access\nfunction getEnv(key: string, defaultValue?: string): string {\n const value = process.env[key];\n if (value === undefined) {\n if (defaultValue !== undefined) return defaultValue;\n throw new Error(`Environment variable ${key} is required`);\n }\n return value;\n}\n\nfunction getOptionalEnv(key: string): string | undefined {\n return process.env[key];\n}\n\nexport interface SharedContext {\n projectId: string;\n branch?: string;\n lastUpdated: number;\n sessions: SharedSessionContext[];\n globalPatterns: ContextPattern[];\n decisionLog: Decision[];\n referenceIndex: ReferenceIndex;\n}\n\nexport interface SharedSessionContext {\n sessionId: string;\n runId: string;\n summary: string;\n keyFrames: FrameSummary[];\n createdAt: number;\n lastActiveAt: number;\n metadata: Record<string, any>;\n}\n\nexport interface FrameSummary {\n frameId: string;\n title: string;\n type: string;\n score: number;\n tags: string[];\n summary?: string;\n createdAt: number;\n}\n\nexport interface ContextPattern {\n pattern: string;\n type: 'error' | 'success' | 'decision' | 'learning';\n frequency: number;\n lastSeen: number;\n resolution?: string;\n}\n\nexport interface Decision {\n id: string;\n decision: string;\n reasoning: string;\n timestamp: number;\n sessionId: string;\n outcome?: 'success' | 'failure' | 'pending';\n}\n\nexport interface ReferenceIndex {\n byTag: Map<string, string[]>;\n byType: Map<string, string[]>;\n byScore: string[];\n recentlyAccessed: string[];\n}\n\nexport class SharedContextLayer {\n private static instance: SharedContextLayer;\n private contextDir: string;\n private cache: Map<string, SharedContext> = new Map();\n private readonly MAX_CACHE_SIZE = 100;\n private readonly CACHE_TTL = 5 * 60 * 1000; // 5 minutes\n private lastCacheClean = Date.now();\n\n private constructor() {\n const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';\n this.contextDir = path.join(homeDir, '.stackmemory', 'shared-context');\n }\n\n static getInstance(): SharedContextLayer {\n if (!SharedContextLayer.instance) {\n SharedContextLayer.instance = new SharedContextLayer();\n }\n return SharedContextLayer.instance;\n }\n\n async initialize(): Promise<void> {\n await fs.mkdir(this.contextDir, { recursive: true });\n await fs.mkdir(path.join(this.contextDir, 'projects'), { recursive: true });\n await fs.mkdir(path.join(this.contextDir, 'patterns'), { recursive: true });\n await fs.mkdir(path.join(this.contextDir, 'decisions'), {\n recursive: true,\n });\n }\n\n /**\n * Get or create shared context for current project/branch\n */\n async getSharedContext(options?: {\n projectId?: string;\n branch?: string;\n includeOtherBranches?: boolean;\n }): Promise<SharedContext> {\n const session = sessionManager.getCurrentSession();\n const projectId = options?.projectId || session?.projectId || 'global';\n const branch = options?.branch || session?.branch;\n\n const cacheKey = `${projectId}:${branch || 'main'}`;\n\n // Check cache first\n if (this.cache.has(cacheKey)) {\n const cached = this.cache.get(cacheKey)!;\n if (Date.now() - cached.lastUpdated < this.CACHE_TTL) {\n return cached;\n }\n }\n\n // Load from disk\n const context = await this.loadProjectContext(projectId, branch);\n\n // Include other branches if requested\n if (options?.includeOtherBranches) {\n const otherBranches = await this.loadOtherBranchContexts(\n projectId,\n branch\n );\n context.sessions.push(...otherBranches);\n }\n\n // Update cache\n this.cache.set(cacheKey, context);\n this.cleanCache();\n\n return context;\n }\n\n /**\n * Add current session's important frames to shared context\n */\n async addToSharedContext(\n frames: Frame[],\n options?: {\n minScore?: number;\n tags?: string[];\n }\n ): Promise<void> {\n const session = sessionManager.getCurrentSession();\n if (!session) return;\n\n const context = await this.getSharedContext();\n const minScore = options?.minScore || 0.7;\n\n // Filter important frames\n const importantFrames = frames.filter((f) => {\n const score = this.calculateFrameScore(f);\n return score >= minScore;\n });\n\n // Create session context\n const sessionContext: SharedSessionContext = {\n sessionId: session.sessionId,\n runId: session.runId,\n summary: this.generateSessionSummary(importantFrames),\n keyFrames: importantFrames.map((f) => this.summarizeFrame(f)),\n createdAt: session.startedAt,\n lastActiveAt: Date.now(),\n metadata: session.metadata,\n };\n\n // Update or add session context\n const existingIndex = context.sessions.findIndex(\n (s) => s.sessionId === session.sessionId\n );\n if (existingIndex >= 0) {\n context.sessions[existingIndex] = sessionContext;\n } else {\n context.sessions.push(sessionContext);\n }\n\n // Update patterns\n this.updatePatterns(context, importantFrames);\n\n // Update reference index\n this.updateReferenceIndex(context, importantFrames);\n\n // Save context\n await this.saveProjectContext(context);\n }\n\n /**\n * Query shared context for relevant frames\n */\n async querySharedContext(query: {\n tags?: string[];\n type?: string;\n minScore?: number;\n sessionId?: string;\n limit?: number;\n }): Promise<FrameSummary[]> {\n const context = await this.getSharedContext({ includeOtherBranches: true });\n let results: FrameSummary[] = [];\n\n // Collect all frames from all sessions\n for (const session of context.sessions) {\n if (query.sessionId && session.sessionId !== query.sessionId) continue;\n\n // Skip sessions without keyFrames\n if (!session.keyFrames || !Array.isArray(session.keyFrames)) continue;\n\n const filtered = session.keyFrames.filter((f) => {\n if (query.tags && !query.tags.some((tag) => f.tags.includes(tag)))\n return false;\n if (query.type && f.type !== query.type) return false;\n if (query.minScore && f.score < query.minScore) return false;\n return true;\n });\n\n results.push(...filtered);\n }\n\n // Sort by score and recency\n results.sort((a, b) => {\n const scoreWeight = 0.7;\n const recencyWeight = 0.3;\n\n const aScore =\n a.score * scoreWeight +\n (1 - (Date.now() - a.createdAt) / (30 * 24 * 60 * 60 * 1000)) *\n recencyWeight;\n const bScore =\n b.score * scoreWeight +\n (1 - (Date.now() - b.createdAt) / (30 * 24 * 60 * 60 * 1000)) *\n recencyWeight;\n\n return bScore - aScore;\n });\n\n // Apply limit\n if (query.limit) {\n results = results.slice(0, query.limit);\n }\n\n // Update recently accessed\n const index = context.referenceIndex;\n if (!index.recentlyAccessed) {\n index.recentlyAccessed = [];\n }\n\n // Add frameIds to recently accessed, removing duplicates\n if (results.length > 0) {\n const frameIds = results.map((r) => r.frameId);\n index.recentlyAccessed = [\n ...frameIds,\n ...index.recentlyAccessed.filter((id: any) => !frameIds.includes(id)),\n ].slice(0, 100);\n\n // Save the updated context with recently accessed frames\n await this.saveProjectContext(context);\n }\n\n return results;\n }\n\n /**\n * Get relevant patterns from shared context\n */\n async getPatterns(type?: ContextPattern['type']): Promise<ContextPattern[]> {\n const context = await this.getSharedContext();\n\n if (type) {\n return context.globalPatterns.filter((p) => p.type === type);\n }\n\n return context.globalPatterns;\n }\n\n /**\n * Add a decision to the shared context\n */\n async addDecision(\n decision: Omit<Decision, 'id' | 'timestamp' | 'sessionId'>\n ): Promise<void> {\n const session = sessionManager.getCurrentSession();\n if (!session) return;\n\n const context = await this.getSharedContext();\n\n const newDecision: Decision = {\n id: uuidv4(),\n timestamp: Date.now(),\n sessionId: session.sessionId,\n outcome: 'pending',\n ...decision,\n };\n\n context.decisionLog.push(newDecision);\n\n // Keep only last 100 decisions\n if (context.decisionLog.length > 100) {\n context.decisionLog = context.decisionLog.slice(-100);\n }\n\n await this.saveProjectContext(context);\n }\n\n /**\n * Get recent decisions from shared context\n */\n async getDecisions(limit: number = 10): Promise<Decision[]> {\n const context = await this.getSharedContext();\n return context.decisionLog.slice(-limit);\n }\n\n /**\n * Automatic context discovery on CLI startup\n */\n async autoDiscoverContext(): Promise<{\n hasSharedContext: boolean;\n sessionCount: number;\n recentPatterns: ContextPattern[];\n lastDecisions: Decision[];\n suggestedFrames: FrameSummary[];\n }> {\n const context = await this.getSharedContext({\n includeOtherBranches: false,\n });\n\n // Get recent patterns (last 7 days)\n const recentPatterns = context.globalPatterns\n .filter((p) => Date.now() - p.lastSeen < 7 * 24 * 60 * 60 * 1000)\n .sort((a, b) => b.frequency - a.frequency)\n .slice(0, 5);\n\n // Get last 5 decisions\n const lastDecisions = context.decisionLog.slice(-5);\n\n // Get suggested frames based on recent access and score\n const suggestedFrames = await this.querySharedContext({\n minScore: 0.8,\n limit: 5,\n });\n\n return {\n hasSharedContext: context.sessions.length > 0,\n sessionCount: context.sessions.length,\n recentPatterns,\n lastDecisions,\n suggestedFrames,\n };\n }\n\n private async loadProjectContext(\n projectId: string,\n branch?: string\n ): Promise<SharedContext> {\n const contextFile = path.join(\n this.contextDir,\n 'projects',\n `${projectId}_${branch || 'main'}.json`\n );\n\n try {\n const data = await fs.readFile(contextFile, 'utf-8');\n const context = JSON.parse(data);\n\n // Reconstruct Maps\n context.referenceIndex.byTag = new Map(\n Object.entries(context.referenceIndex.byTag || {})\n );\n context.referenceIndex.byType = new Map(\n Object.entries(context.referenceIndex.byType || {})\n );\n\n return context;\n } catch {\n // Return empty context if file doesn't exist\n return {\n projectId,\n branch,\n lastUpdated: Date.now(),\n sessions: [],\n globalPatterns: [],\n decisionLog: [],\n referenceIndex: {\n byTag: new Map(),\n byType: new Map(),\n byScore: [],\n recentlyAccessed: [],\n },\n };\n }\n }\n\n private async saveProjectContext(context: SharedContext): Promise<void> {\n const contextFile = path.join(\n this.contextDir,\n 'projects',\n `${context.projectId}_${context.branch || 'main'}.json`\n );\n\n // Convert Maps to objects for JSON serialization\n const serializable = {\n ...context,\n lastUpdated: Date.now(),\n referenceIndex: {\n ...context.referenceIndex,\n byTag: Object.fromEntries(context.referenceIndex.byTag),\n byType: Object.fromEntries(context.referenceIndex.byType),\n },\n };\n\n await fs.writeFile(contextFile, JSON.stringify(serializable, null, 2));\n }\n\n private async loadOtherBranchContexts(\n projectId: string,\n currentBranch?: string\n ): Promise<SharedSessionContext[]> {\n const projectsDir = path.join(this.contextDir, 'projects');\n const files = await fs.readdir(projectsDir);\n const sessions: SharedSessionContext[] = [];\n\n for (const file of files) {\n if (\n file.startsWith(`${projectId}_`) &&\n !file.includes(currentBranch || 'main')\n ) {\n try {\n const data = await fs.readFile(path.join(projectsDir, file), 'utf-8');\n const context = JSON.parse(data);\n sessions.push(...context.sessions);\n } catch {\n // Skip invalid files\n }\n }\n }\n\n return sessions;\n }\n\n private calculateFrameScore(frame: Frame): number {\n // Simple scoring algorithm\n let score = 0.5;\n\n // Boost for certain types\n if (frame.type === 'task' || frame.type === 'review') score += 0.2;\n if (frame.type === 'debug' || frame.type === 'write') score += 0.15;\n if (frame.type === 'error') score += 0.15; // Error frames are important for pattern extraction\n\n // Check for data property (used in tests)\n const frameWithData = frame as any;\n if (frameWithData.data) score += 0.2;\n\n // Boost for having outputs (indicates completion/results)\n if (frame.outputs && Object.keys(frame.outputs).length > 0) score += 0.2;\n if (\n frame.digest_text ||\n (frame.digest_json && Object.keys(frame.digest_json).length > 0)\n )\n score += 0.1;\n\n // Time decay (reduce score for older frames) - but handle missing created_at\n if (frame.created_at) {\n const age = Date.now() - frame.created_at;\n const daysSinceCreation = age / (24 * 60 * 60 * 1000);\n score *= Math.max(0.3, 1 - daysSinceCreation / 30);\n }\n\n return Math.min(1, score);\n }\n\n private summarizeFrame(frame: Frame): FrameSummary {\n return {\n frameId: frame.frame_id,\n title: frame.name,\n type: frame.type,\n score: this.calculateFrameScore(frame),\n tags: [],\n summary: this.generateFrameSummary(frame),\n createdAt: frame.created_at,\n };\n }\n\n private generateFrameSummary(frame: Frame): string {\n // Generate a brief summary of the frame\n const parts = [];\n const frameWithData = frame as any;\n\n if (frame.type) parts.push(`[${frame.type}]`);\n if (frame.name) parts.push(frame.name);\n if (frameWithData.title) parts.push(frameWithData.title);\n if (frameWithData.data?.error)\n parts.push(`Error: ${frameWithData.data.error}`);\n if (frameWithData.data?.resolution)\n parts.push(`Resolution: ${frameWithData.data.resolution}`);\n\n return parts.join(' - ').slice(0, 200);\n }\n\n private generateSessionSummary(frames: Frame[]): string {\n const types = [...new Set(frames.map((f) => f.type))];\n return `Session with ${frames.length} key frames: ${types.join(', ')}`;\n }\n\n private updatePatterns(context: SharedContext, frames: Frame[]): void {\n for (const frame of frames) {\n // Extract patterns from frame data\n // Handle frames with a data property (used in tests)\n const frameWithData = frame as any;\n if (frameWithData.data?.error) {\n this.addPattern(\n context,\n frameWithData.data.error,\n 'error',\n frameWithData.data?.resolution\n );\n } else if (frame.type === 'error' && frame.name) {\n // Only extract from name/outputs if no data.error property\n const errorText = frame.outputs?.error || frame.name;\n const resolution = frame.outputs?.resolution;\n if (errorText) {\n this.addPattern(context, errorText, 'error', resolution);\n }\n }\n\n if (frame.type === 'decision' && frameWithData.data?.decision) {\n this.addPattern(context, frameWithData.data.decision, 'decision');\n } else if (frame.digest_json?.decision) {\n // Only extract from digest_json if no data.decision\n this.addPattern(context, frame.digest_json.decision, 'decision');\n }\n }\n }\n\n private addPattern(\n context: SharedContext,\n pattern: string,\n type: ContextPattern['type'],\n resolution?: string\n ): void {\n const existing = context.globalPatterns.find(\n (p) => p.pattern === pattern && p.type === type\n );\n\n if (existing) {\n existing.frequency++;\n existing.lastSeen = Date.now();\n if (resolution) existing.resolution = resolution;\n } else {\n context.globalPatterns.push({\n pattern,\n type,\n frequency: 1,\n lastSeen: Date.now(),\n resolution,\n });\n }\n\n // Keep only top 100 patterns\n if (context.globalPatterns.length > 100) {\n context.globalPatterns.sort((a, b) => b.frequency - a.frequency);\n context.globalPatterns = context.globalPatterns.slice(0, 100);\n }\n }\n\n private updateReferenceIndex(context: SharedContext, frames: Frame[]): void {\n for (const frame of frames) {\n const summary = this.summarizeFrame(frame);\n\n // Index by tags\n for (const tag of summary.tags) {\n if (!context.referenceIndex.byTag.has(tag)) {\n context.referenceIndex.byTag.set(tag, []);\n }\n context.referenceIndex.byTag.get(tag)!.push(frame.frameId);\n }\n\n // Index by type\n if (!context.referenceIndex.byType.has(frame.type)) {\n context.referenceIndex.byType.set(frame.type, []);\n }\n context.referenceIndex.byType.get(frame.type)!.push(frame.frameId);\n\n // Update score index\n const scoreIndex = context.referenceIndex.byScore;\n const insertIndex = scoreIndex.findIndex((id) => {\n const otherFrame = context.sessions\n .flatMap((s) => s.keyFrames)\n .find((f) => f.frameId === id);\n return otherFrame && otherFrame.score < summary.score;\n });\n\n if (insertIndex >= 0) {\n scoreIndex.splice(insertIndex, 0, frame.frameId);\n } else {\n scoreIndex.push(frame.frameId);\n }\n\n // Keep only top 1000 by score\n context.referenceIndex.byScore = scoreIndex.slice(0, 1000);\n }\n }\n\n private cleanCache(): void {\n if (Date.now() - this.lastCacheClean < 60000) return; // Clean every minute\n\n if (this.cache.size > this.MAX_CACHE_SIZE) {\n const entries = Array.from(this.cache.entries()).sort(\n (a, b) => b[1].lastUpdated - a[1].lastUpdated\n );\n\n this.cache = new Map(entries.slice(0, this.MAX_CACHE_SIZE / 2));\n }\n\n this.lastCacheClean = Date.now();\n }\n}\n\nexport const sharedContextLayer = SharedContextLayer.getInstance();\n\n// Export for testing\nexport {\n SharedContext,\n SharedSessionContext,\n FrameSummary,\n ContextPattern,\n Decision,\n ReferenceIndex,\n};\n"],
|
|
5
|
-
"mappings": ";;;;AAWA,SAAS,MAAM,cAAc;AAC7B,YAAY,QAAQ;AACpB,YAAY,UAAU;
|
|
4
|
+
"sourcesContent": ["/**\n * Shared Context Layer for Cross-Session Reference\n *\n * This layer maintains a lightweight shared context across sessions while\n * preserving run_id isolation for write operations. It enables:\n * - Read access to frames from other sessions\n * - Automatic context inheritance\n * - Efficient caching and indexing\n * - Safe concurrent access\n */\n\nimport { v4 as uuidv4 } from 'uuid';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\nimport { sessionManager } from '../session/session-manager.js';\nimport type { Frame } from '../frame-manager/frame-manager.js';\n\n// Type-safe environment variable access\n\nexport interface SharedContext {\n projectId: string;\n branch?: string;\n lastUpdated: number;\n sessions: SharedSessionContext[];\n globalPatterns: ContextPattern[];\n decisionLog: Decision[];\n referenceIndex: ReferenceIndex;\n}\n\nexport interface SharedSessionContext {\n sessionId: string;\n runId: string;\n summary: string;\n keyFrames: FrameSummary[];\n createdAt: number;\n lastActiveAt: number;\n metadata: Record<string, any>;\n}\n\nexport interface FrameSummary {\n frameId: string;\n title: string;\n type: string;\n score: number;\n tags: string[];\n summary?: string;\n createdAt: number;\n}\n\nexport interface ContextPattern {\n pattern: string;\n type: 'error' | 'success' | 'decision' | 'learning';\n frequency: number;\n lastSeen: number;\n resolution?: string;\n}\n\nexport interface Decision {\n id: string;\n decision: string;\n reasoning: string;\n timestamp: number;\n sessionId: string;\n outcome?: 'success' | 'failure' | 'pending';\n}\n\nexport interface ReferenceIndex {\n byTag: Map<string, string[]>;\n byType: Map<string, string[]>;\n byScore: string[];\n recentlyAccessed: string[];\n}\n\nexport class SharedContextLayer {\n private static instance: SharedContextLayer;\n private contextDir: string;\n private cache: Map<string, SharedContext> = new Map();\n private readonly MAX_CACHE_SIZE = 100;\n private readonly CACHE_TTL = 5 * 60 * 1000; // 5 minutes\n private lastCacheClean = Date.now();\n\n private constructor() {\n const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';\n this.contextDir = path.join(homeDir, '.stackmemory', 'shared-context');\n }\n\n static getInstance(): SharedContextLayer {\n if (!SharedContextLayer.instance) {\n SharedContextLayer.instance = new SharedContextLayer();\n }\n return SharedContextLayer.instance;\n }\n\n async initialize(): Promise<void> {\n await fs.mkdir(this.contextDir, { recursive: true });\n await fs.mkdir(path.join(this.contextDir, 'projects'), { recursive: true });\n await fs.mkdir(path.join(this.contextDir, 'patterns'), { recursive: true });\n await fs.mkdir(path.join(this.contextDir, 'decisions'), {\n recursive: true,\n });\n }\n\n /**\n * Get or create shared context for current project/branch\n */\n async getSharedContext(options?: {\n projectId?: string;\n branch?: string;\n includeOtherBranches?: boolean;\n }): Promise<SharedContext> {\n const session = sessionManager.getCurrentSession();\n const projectId = options?.projectId || session?.projectId || 'global';\n const branch = options?.branch || session?.branch;\n\n const cacheKey = `${projectId}:${branch || 'main'}`;\n\n // Check cache first\n if (this.cache.has(cacheKey)) {\n const cached = this.cache.get(cacheKey)!;\n if (Date.now() - cached.lastUpdated < this.CACHE_TTL) {\n return cached;\n }\n }\n\n // Load from disk\n const context = await this.loadProjectContext(projectId, branch);\n\n // Include other branches if requested\n if (options?.includeOtherBranches) {\n const otherBranches = await this.loadOtherBranchContexts(\n projectId,\n branch\n );\n context.sessions.push(...otherBranches);\n }\n\n // Update cache\n this.cache.set(cacheKey, context);\n this.cleanCache();\n\n return context;\n }\n\n /**\n * Add current session's important frames to shared context\n */\n async addToSharedContext(\n frames: Frame[],\n options?: {\n minScore?: number;\n tags?: string[];\n }\n ): Promise<void> {\n const session = sessionManager.getCurrentSession();\n if (!session) return;\n\n const context = await this.getSharedContext();\n const minScore = options?.minScore || 0.7;\n\n // Filter important frames\n const importantFrames = frames.filter((f) => {\n const score = this.calculateFrameScore(f);\n return score >= minScore;\n });\n\n // Create session context\n const sessionContext: SharedSessionContext = {\n sessionId: session.sessionId,\n runId: session.runId,\n summary: this.generateSessionSummary(importantFrames),\n keyFrames: importantFrames.map((f) => this.summarizeFrame(f)),\n createdAt: session.startedAt,\n lastActiveAt: Date.now(),\n metadata: session.metadata,\n };\n\n // Update or add session context\n const existingIndex = context.sessions.findIndex(\n (s) => s.sessionId === session.sessionId\n );\n if (existingIndex >= 0) {\n context.sessions[existingIndex] = sessionContext;\n } else {\n context.sessions.push(sessionContext);\n }\n\n // Update patterns\n this.updatePatterns(context, importantFrames);\n\n // Update reference index\n this.updateReferenceIndex(context, importantFrames);\n\n // Save context\n await this.saveProjectContext(context);\n }\n\n /**\n * Query shared context for relevant frames\n */\n async querySharedContext(query: {\n tags?: string[];\n type?: string;\n minScore?: number;\n sessionId?: string;\n limit?: number;\n }): Promise<FrameSummary[]> {\n const context = await this.getSharedContext({ includeOtherBranches: true });\n let results: FrameSummary[] = [];\n\n // Collect all frames from all sessions\n for (const session of context.sessions) {\n if (query.sessionId && session.sessionId !== query.sessionId) continue;\n\n // Skip sessions without keyFrames\n if (!session.keyFrames || !Array.isArray(session.keyFrames)) continue;\n\n const filtered = session.keyFrames.filter((f) => {\n if (query.tags && !query.tags.some((tag) => f.tags.includes(tag)))\n return false;\n if (query.type && f.type !== query.type) return false;\n if (query.minScore && f.score < query.minScore) return false;\n return true;\n });\n\n results.push(...filtered);\n }\n\n // Sort by score and recency\n results.sort((a, b) => {\n const scoreWeight = 0.7;\n const recencyWeight = 0.3;\n\n const aScore =\n a.score * scoreWeight +\n (1 - (Date.now() - a.createdAt) / (30 * 24 * 60 * 60 * 1000)) *\n recencyWeight;\n const bScore =\n b.score * scoreWeight +\n (1 - (Date.now() - b.createdAt) / (30 * 24 * 60 * 60 * 1000)) *\n recencyWeight;\n\n return bScore - aScore;\n });\n\n // Apply limit\n if (query.limit) {\n results = results.slice(0, query.limit);\n }\n\n // Update recently accessed\n const index = context.referenceIndex;\n if (!index.recentlyAccessed) {\n index.recentlyAccessed = [];\n }\n\n // Add frameIds to recently accessed, removing duplicates\n if (results.length > 0) {\n const frameIds = results.map((r) => r.frameId);\n index.recentlyAccessed = [\n ...frameIds,\n ...index.recentlyAccessed.filter((id: any) => !frameIds.includes(id)),\n ].slice(0, 100);\n\n // Save the updated context with recently accessed frames\n await this.saveProjectContext(context);\n }\n\n return results;\n }\n\n /**\n * Get relevant patterns from shared context\n */\n async getPatterns(type?: ContextPattern['type']): Promise<ContextPattern[]> {\n const context = await this.getSharedContext();\n\n if (type) {\n return context.globalPatterns.filter((p) => p.type === type);\n }\n\n return context.globalPatterns;\n }\n\n /**\n * Add a decision to the shared context\n */\n async addDecision(\n decision: Omit<Decision, 'id' | 'timestamp' | 'sessionId'>\n ): Promise<void> {\n const session = sessionManager.getCurrentSession();\n if (!session) return;\n\n const context = await this.getSharedContext();\n\n const newDecision: Decision = {\n id: uuidv4(),\n timestamp: Date.now(),\n sessionId: session.sessionId,\n outcome: 'pending',\n ...decision,\n };\n\n context.decisionLog.push(newDecision);\n\n // Keep only last 100 decisions\n if (context.decisionLog.length > 100) {\n context.decisionLog = context.decisionLog.slice(-100);\n }\n\n await this.saveProjectContext(context);\n }\n\n /**\n * Get recent decisions from shared context\n */\n async getDecisions(limit: number = 10): Promise<Decision[]> {\n const context = await this.getSharedContext();\n return context.decisionLog.slice(-limit);\n }\n\n /**\n * Automatic context discovery on CLI startup\n */\n async autoDiscoverContext(): Promise<{\n hasSharedContext: boolean;\n sessionCount: number;\n recentPatterns: ContextPattern[];\n lastDecisions: Decision[];\n suggestedFrames: FrameSummary[];\n }> {\n const context = await this.getSharedContext({\n includeOtherBranches: false,\n });\n\n // Get recent patterns (last 7 days)\n const recentPatterns = context.globalPatterns\n .filter((p) => Date.now() - p.lastSeen < 7 * 24 * 60 * 60 * 1000)\n .sort((a, b) => b.frequency - a.frequency)\n .slice(0, 5);\n\n // Get last 5 decisions\n const lastDecisions = context.decisionLog.slice(-5);\n\n // Get suggested frames based on recent access and score\n const suggestedFrames = await this.querySharedContext({\n minScore: 0.8,\n limit: 5,\n });\n\n return {\n hasSharedContext: context.sessions.length > 0,\n sessionCount: context.sessions.length,\n recentPatterns,\n lastDecisions,\n suggestedFrames,\n };\n }\n\n private async loadProjectContext(\n projectId: string,\n branch?: string\n ): Promise<SharedContext> {\n const contextFile = path.join(\n this.contextDir,\n 'projects',\n `${projectId}_${branch || 'main'}.json`\n );\n\n try {\n const data = await fs.readFile(contextFile, 'utf-8');\n const context = JSON.parse(data);\n\n // Reconstruct Maps\n context.referenceIndex.byTag = new Map(\n Object.entries(context.referenceIndex.byTag || {})\n );\n context.referenceIndex.byType = new Map(\n Object.entries(context.referenceIndex.byType || {})\n );\n\n return context;\n } catch {\n // Return empty context if file doesn't exist\n return {\n projectId,\n branch,\n lastUpdated: Date.now(),\n sessions: [],\n globalPatterns: [],\n decisionLog: [],\n referenceIndex: {\n byTag: new Map(),\n byType: new Map(),\n byScore: [],\n recentlyAccessed: [],\n },\n };\n }\n }\n\n private async saveProjectContext(context: SharedContext): Promise<void> {\n const contextFile = path.join(\n this.contextDir,\n 'projects',\n `${context.projectId}_${context.branch || 'main'}.json`\n );\n\n // Convert Maps to objects for JSON serialization\n const serializable = {\n ...context,\n lastUpdated: Date.now(),\n referenceIndex: {\n ...context.referenceIndex,\n byTag: Object.fromEntries(context.referenceIndex.byTag),\n byType: Object.fromEntries(context.referenceIndex.byType),\n },\n };\n\n await fs.writeFile(contextFile, JSON.stringify(serializable, null, 2));\n }\n\n private async loadOtherBranchContexts(\n projectId: string,\n currentBranch?: string\n ): Promise<SharedSessionContext[]> {\n const projectsDir = path.join(this.contextDir, 'projects');\n const files = await fs.readdir(projectsDir);\n const sessions: SharedSessionContext[] = [];\n\n for (const file of files) {\n if (\n file.startsWith(`${projectId}_`) &&\n !file.includes(currentBranch || 'main')\n ) {\n try {\n const data = await fs.readFile(path.join(projectsDir, file), 'utf-8');\n const context = JSON.parse(data);\n sessions.push(...context.sessions);\n } catch {\n // Skip invalid files\n }\n }\n }\n\n return sessions;\n }\n\n private calculateFrameScore(frame: Frame): number {\n // Simple scoring algorithm\n let score = 0.5;\n\n // Boost for certain types\n if (frame.type === 'task' || frame.type === 'review') score += 0.2;\n if (frame.type === 'debug' || frame.type === 'write') score += 0.15;\n if (frame.type === 'error') score += 0.15; // Error frames are important for pattern extraction\n\n // Check for data property (used in tests)\n const frameWithData = frame as any;\n if (frameWithData.data) score += 0.2;\n\n // Boost for having outputs (indicates completion/results)\n if (frame.outputs && Object.keys(frame.outputs).length > 0) score += 0.2;\n if (\n frame.digest_text ||\n (frame.digest_json && Object.keys(frame.digest_json).length > 0)\n )\n score += 0.1;\n\n // Time decay (reduce score for older frames) - but handle missing created_at\n if (frame.created_at) {\n const age = Date.now() - frame.created_at;\n const daysSinceCreation = age / (24 * 60 * 60 * 1000);\n score *= Math.max(0.3, 1 - daysSinceCreation / 30);\n }\n\n return Math.min(1, score);\n }\n\n private summarizeFrame(frame: Frame): FrameSummary {\n return {\n frameId: frame.frame_id,\n title: frame.name,\n type: frame.type,\n score: this.calculateFrameScore(frame),\n tags: [],\n summary: this.generateFrameSummary(frame),\n createdAt: frame.created_at,\n };\n }\n\n private generateFrameSummary(frame: Frame): string {\n // Generate a brief summary of the frame\n const parts = [];\n const frameWithData = frame as any;\n\n if (frame.type) parts.push(`[${frame.type}]`);\n if (frame.name) parts.push(frame.name);\n if (frameWithData.title) parts.push(frameWithData.title);\n if (frameWithData.data?.error)\n parts.push(`Error: ${frameWithData.data.error}`);\n if (frameWithData.data?.resolution)\n parts.push(`Resolution: ${frameWithData.data.resolution}`);\n\n return parts.join(' - ').slice(0, 200);\n }\n\n private generateSessionSummary(frames: Frame[]): string {\n const types = [...new Set(frames.map((f) => f.type))];\n return `Session with ${frames.length} key frames: ${types.join(', ')}`;\n }\n\n private updatePatterns(context: SharedContext, frames: Frame[]): void {\n for (const frame of frames) {\n // Extract patterns from frame data\n // Handle frames with a data property (used in tests)\n const frameWithData = frame as any;\n if (frameWithData.data?.error) {\n this.addPattern(\n context,\n frameWithData.data.error,\n 'error',\n frameWithData.data?.resolution\n );\n } else if (frame.type === 'error' && frame.name) {\n // Only extract from name/outputs if no data.error property\n const errorText = frame.outputs?.error || frame.name;\n const resolution = frame.outputs?.resolution;\n if (errorText) {\n this.addPattern(context, errorText, 'error', resolution);\n }\n }\n\n if (frame.type === 'decision' && frameWithData.data?.decision) {\n this.addPattern(context, frameWithData.data.decision, 'decision');\n } else if (frame.digest_json?.decision) {\n // Only extract from digest_json if no data.decision\n this.addPattern(context, frame.digest_json.decision, 'decision');\n }\n }\n }\n\n private addPattern(\n context: SharedContext,\n pattern: string,\n type: ContextPattern['type'],\n resolution?: string\n ): void {\n const existing = context.globalPatterns.find(\n (p) => p.pattern === pattern && p.type === type\n );\n\n if (existing) {\n existing.frequency++;\n existing.lastSeen = Date.now();\n if (resolution) existing.resolution = resolution;\n } else {\n context.globalPatterns.push({\n pattern,\n type,\n frequency: 1,\n lastSeen: Date.now(),\n resolution,\n });\n }\n\n // Keep only top 100 patterns\n if (context.globalPatterns.length > 100) {\n context.globalPatterns.sort((a, b) => b.frequency - a.frequency);\n context.globalPatterns = context.globalPatterns.slice(0, 100);\n }\n }\n\n private updateReferenceIndex(context: SharedContext, frames: Frame[]): void {\n for (const frame of frames) {\n const summary = this.summarizeFrame(frame);\n\n // Index by tags\n for (const tag of summary.tags) {\n if (!context.referenceIndex.byTag.has(tag)) {\n context.referenceIndex.byTag.set(tag, []);\n }\n context.referenceIndex.byTag.get(tag)!.push(frame.frameId);\n }\n\n // Index by type\n if (!context.referenceIndex.byType.has(frame.type)) {\n context.referenceIndex.byType.set(frame.type, []);\n }\n context.referenceIndex.byType.get(frame.type)!.push(frame.frameId);\n\n // Update score index\n const scoreIndex = context.referenceIndex.byScore;\n const insertIndex = scoreIndex.findIndex((id) => {\n const otherFrame = context.sessions\n .flatMap((s) => s.keyFrames)\n .find((f) => f.frameId === id);\n return otherFrame && otherFrame.score < summary.score;\n });\n\n if (insertIndex >= 0) {\n scoreIndex.splice(insertIndex, 0, frame.frameId);\n } else {\n scoreIndex.push(frame.frameId);\n }\n\n // Keep only top 1000 by score\n context.referenceIndex.byScore = scoreIndex.slice(0, 1000);\n }\n }\n\n private cleanCache(): void {\n if (Date.now() - this.lastCacheClean < 60000) return; // Clean every minute\n\n if (this.cache.size > this.MAX_CACHE_SIZE) {\n const entries = Array.from(this.cache.entries()).sort(\n (a, b) => b[1].lastUpdated - a[1].lastUpdated\n );\n\n this.cache = new Map(entries.slice(0, this.MAX_CACHE_SIZE / 2));\n }\n\n this.lastCacheClean = Date.now();\n }\n}\n\nexport const sharedContextLayer = SharedContextLayer.getInstance();\n\n// Export for testing\nexport {\n SharedContext,\n SharedSessionContext,\n FrameSummary,\n ContextPattern,\n Decision,\n ReferenceIndex,\n};\n"],
|
|
5
|
+
"mappings": ";;;;AAWA,SAAS,MAAM,cAAc;AAC7B,YAAY,QAAQ;AAC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;AACF;AAEO,MAAM,qBAAqB,mBAAmB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,6 +3,7 @@ import { dirname as __pathDirname } from 'path';
|
|
|
3
3
|
const __filename = __fileURLToPath(import.meta.url);
|
|
4
4
|
const __dirname = __pathDirname(__filename);
|
|
5
5
|
import { z } from "zod";
|
|
6
|
+
import { ValidationError, ErrorCode } from "../errors/index.js";
|
|
6
7
|
const StackPermissionsSchema = z.object({
|
|
7
8
|
canRead: z.boolean(),
|
|
8
9
|
canWrite: z.boolean(),
|
|
@@ -89,7 +90,11 @@ function validateInput(schema, input) {
|
|
|
89
90
|
} catch (error) {
|
|
90
91
|
if (error instanceof z.ZodError) {
|
|
91
92
|
const details = error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ");
|
|
92
|
-
throw new
|
|
93
|
+
throw new ValidationError(
|
|
94
|
+
`Validation failed: ${details}`,
|
|
95
|
+
ErrorCode.VALIDATION_FAILED,
|
|
96
|
+
{ errors: error.errors }
|
|
97
|
+
);
|
|
93
98
|
}
|
|
94
99
|
throw error;
|
|
95
100
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/core/context/validation.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Input validation schemas for collaboration layer\n */\n\nimport { z } from 'zod';\n\n// Permission validation\nexport const StackPermissionsSchema = z.object({\n canRead: z.boolean(),\n canWrite: z.boolean(),\n canHandoff: z.boolean(),\n canMerge: z.boolean(),\n canAdminister: z.boolean(),\n});\n\n// Common string validations\nconst stackIdSchema = z.string().min(1).max(200);\nconst userIdSchema = z.string().min(1).max(100);\nconst frameIdSchema = z.string().min(1).max(100);\nconst teamIdSchema = z.string().min(1).max(100);\n\n// Dual Stack Manager validation\nexport const CreateSharedStackSchema = z.object({\n teamId: teamIdSchema,\n name: z.string().min(1).max(200),\n ownerId: userIdSchema,\n permissions: StackPermissionsSchema.optional(),\n});\n\nexport const SwitchStackSchema = z.object({\n stackId: stackIdSchema,\n});\n\n// Frame Handoff validation\nexport const FrameContextSchema = z.object({\n totalFrames: z.number().min(1).max(10000),\n frameTypes: z.array(z.string()).min(1).max(50),\n estimatedSize: z.number().min(0).max(1000000), // Max 1MB\n dependencies: z.array(z.string()).max(100),\n});\n\nexport const BusinessContextSchema = z.object({\n milestone: z.string().max(100).optional(),\n priority: z.enum(['low', 'medium', 'high', 'critical']).optional(),\n deadline: z.date().optional(),\n stakeholders: z.array(userIdSchema).max(20).optional(),\n});\n\nexport const HandoffRequestSchema = z.object({\n initiatedAt: z.date(),\n initiatorId: userIdSchema,\n frameContext: FrameContextSchema,\n businessContext: BusinessContextSchema.optional(),\n});\n\nexport const InitiateHandoffSchema = z.object({\n targetStackId: stackIdSchema,\n frameIds: z.array(frameIdSchema).min(1).max(1000),\n handoffRequest: HandoffRequestSchema,\n reviewerId: userIdSchema.optional(),\n description: z.string().max(1000).optional(),\n});\n\nexport const HandoffApprovalSchema = z.object({\n reviewerId: userIdSchema,\n decision: z.enum(['approved', 'rejected', 'needs_changes']),\n feedback: z.string().max(2000).optional(),\n suggestedChanges: z\n .array(\n z.object({\n frameId: frameIdSchema,\n suggestion: z.string().max(500),\n reason: z.string().max(300).optional(),\n })\n )\n .max(50)\n .optional(),\n});\n\n// Merge Resolution validation\nexport const ConflictResolutionSchema = z.object({\n strategy: z.enum(['source_wins', 'target_wins', 'merge_both', 'manual']),\n resolvedBy: userIdSchema,\n notes: z.string().max(1000).optional(),\n});\n\nexport const MergePolicyRuleSchema = z.object({\n condition: z.string().min(1).max(500),\n action: z.enum(['source_wins', 'target_wins', 'merge_both', 'manual_review']),\n priority: z.number().min(1).max(10),\n});\n\nexport const CreateMergePolicySchema = z.object({\n name: z.string().min(1).max(100),\n description: z.string().max(500).optional(),\n rules: z.array(MergePolicyRuleSchema).min(1).max(20),\n autoApplyThreshold: z.enum(['low', 'medium', 'high']),\n});\n\nexport const StartMergeSessionSchema = z.object({\n sourceStackId: stackIdSchema,\n targetStackId: stackIdSchema,\n frameIds: z.array(frameIdSchema).max(1000).optional(),\n policyName: z.string().max(100).optional(),\n});\n\n// Type exports for use in implementation\nexport type StackPermissions = z.infer<typeof StackPermissionsSchema>;\nexport type CreateSharedStackInput = z.infer<typeof CreateSharedStackSchema>;\nexport type SwitchStackInput = z.infer<typeof SwitchStackSchema>;\nexport type FrameContext = z.infer<typeof FrameContextSchema>;\nexport type BusinessContext = z.infer<typeof BusinessContextSchema>;\nexport type HandoffRequest = z.infer<typeof HandoffRequestSchema>;\nexport type InitiateHandoffInput = z.infer<typeof InitiateHandoffSchema>;\nexport type HandoffApprovalInput = z.infer<typeof HandoffApprovalSchema>;\nexport type ConflictResolutionInput = z.infer<typeof ConflictResolutionSchema>;\nexport type MergePolicyRule = z.infer<typeof MergePolicyRuleSchema>;\nexport type CreateMergePolicyInput = z.infer<typeof CreateMergePolicySchema>;\nexport type StartMergeSessionInput = z.infer<typeof StartMergeSessionSchema>;\n\n// Validation helper functions\nexport function validateInput<T>(schema: z.ZodSchema<T>, input: unknown): T {\n try {\n return schema.parse(input);\n } catch (error: unknown) {\n if (error instanceof z.ZodError) {\n const details = error.errors\n .map((e) => `${e.path.join('.')}: ${e.message}`)\n .join(', ');\n throw new
|
|
5
|
-
"mappings": ";;;;AAIA,SAAS,SAAS;
|
|
4
|
+
"sourcesContent": ["/**\n * Input validation schemas for collaboration layer\n */\n\nimport { z } from 'zod';\nimport { ValidationError, ErrorCode } from '../errors/index.js';\n\n// Permission validation\nexport const StackPermissionsSchema = z.object({\n canRead: z.boolean(),\n canWrite: z.boolean(),\n canHandoff: z.boolean(),\n canMerge: z.boolean(),\n canAdminister: z.boolean(),\n});\n\n// Common string validations\nconst stackIdSchema = z.string().min(1).max(200);\nconst userIdSchema = z.string().min(1).max(100);\nconst frameIdSchema = z.string().min(1).max(100);\nconst teamIdSchema = z.string().min(1).max(100);\n\n// Dual Stack Manager validation\nexport const CreateSharedStackSchema = z.object({\n teamId: teamIdSchema,\n name: z.string().min(1).max(200),\n ownerId: userIdSchema,\n permissions: StackPermissionsSchema.optional(),\n});\n\nexport const SwitchStackSchema = z.object({\n stackId: stackIdSchema,\n});\n\n// Frame Handoff validation\nexport const FrameContextSchema = z.object({\n totalFrames: z.number().min(1).max(10000),\n frameTypes: z.array(z.string()).min(1).max(50),\n estimatedSize: z.number().min(0).max(1000000), // Max 1MB\n dependencies: z.array(z.string()).max(100),\n});\n\nexport const BusinessContextSchema = z.object({\n milestone: z.string().max(100).optional(),\n priority: z.enum(['low', 'medium', 'high', 'critical']).optional(),\n deadline: z.date().optional(),\n stakeholders: z.array(userIdSchema).max(20).optional(),\n});\n\nexport const HandoffRequestSchema = z.object({\n initiatedAt: z.date(),\n initiatorId: userIdSchema,\n frameContext: FrameContextSchema,\n businessContext: BusinessContextSchema.optional(),\n});\n\nexport const InitiateHandoffSchema = z.object({\n targetStackId: stackIdSchema,\n frameIds: z.array(frameIdSchema).min(1).max(1000),\n handoffRequest: HandoffRequestSchema,\n reviewerId: userIdSchema.optional(),\n description: z.string().max(1000).optional(),\n});\n\nexport const HandoffApprovalSchema = z.object({\n reviewerId: userIdSchema,\n decision: z.enum(['approved', 'rejected', 'needs_changes']),\n feedback: z.string().max(2000).optional(),\n suggestedChanges: z\n .array(\n z.object({\n frameId: frameIdSchema,\n suggestion: z.string().max(500),\n reason: z.string().max(300).optional(),\n })\n )\n .max(50)\n .optional(),\n});\n\n// Merge Resolution validation\nexport const ConflictResolutionSchema = z.object({\n strategy: z.enum(['source_wins', 'target_wins', 'merge_both', 'manual']),\n resolvedBy: userIdSchema,\n notes: z.string().max(1000).optional(),\n});\n\nexport const MergePolicyRuleSchema = z.object({\n condition: z.string().min(1).max(500),\n action: z.enum(['source_wins', 'target_wins', 'merge_both', 'manual_review']),\n priority: z.number().min(1).max(10),\n});\n\nexport const CreateMergePolicySchema = z.object({\n name: z.string().min(1).max(100),\n description: z.string().max(500).optional(),\n rules: z.array(MergePolicyRuleSchema).min(1).max(20),\n autoApplyThreshold: z.enum(['low', 'medium', 'high']),\n});\n\nexport const StartMergeSessionSchema = z.object({\n sourceStackId: stackIdSchema,\n targetStackId: stackIdSchema,\n frameIds: z.array(frameIdSchema).max(1000).optional(),\n policyName: z.string().max(100).optional(),\n});\n\n// Type exports for use in implementation\nexport type StackPermissions = z.infer<typeof StackPermissionsSchema>;\nexport type CreateSharedStackInput = z.infer<typeof CreateSharedStackSchema>;\nexport type SwitchStackInput = z.infer<typeof SwitchStackSchema>;\nexport type FrameContext = z.infer<typeof FrameContextSchema>;\nexport type BusinessContext = z.infer<typeof BusinessContextSchema>;\nexport type HandoffRequest = z.infer<typeof HandoffRequestSchema>;\nexport type InitiateHandoffInput = z.infer<typeof InitiateHandoffSchema>;\nexport type HandoffApprovalInput = z.infer<typeof HandoffApprovalSchema>;\nexport type ConflictResolutionInput = z.infer<typeof ConflictResolutionSchema>;\nexport type MergePolicyRule = z.infer<typeof MergePolicyRuleSchema>;\nexport type CreateMergePolicyInput = z.infer<typeof CreateMergePolicySchema>;\nexport type StartMergeSessionInput = z.infer<typeof StartMergeSessionSchema>;\n\n// Validation helper functions\nexport function validateInput<T>(schema: z.ZodSchema<T>, input: unknown): T {\n try {\n return schema.parse(input);\n } catch (error: unknown) {\n if (error instanceof z.ZodError) {\n const details = error.errors\n .map((e) => `${e.path.join('.')}: ${e.message}`)\n .join(', ');\n throw new ValidationError(\n `Validation failed: ${details}`,\n ErrorCode.VALIDATION_FAILED,\n { errors: error.errors }\n );\n }\n throw error;\n }\n}\n\nexport function validateInputSafe<T>(\n schema: z.ZodSchema<T>,\n input: unknown\n): { success: true; data: T } | { success: false; error: string } {\n try {\n const data = schema.parse(input);\n return { success: true, data };\n } catch (error: unknown) {\n if (error instanceof z.ZodError) {\n const details = error.errors\n .map((e) => `${e.path.join('.')}: ${e.message}`)\n .join(', ');\n return { success: false, error: `Validation failed: ${details}` };\n }\n return { success: false, error: 'Unknown validation error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