cogmem 3.6.2
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/BENCHMARKS.md +62 -0
- package/CHANGELOG.md +215 -0
- package/CONCURRENT_ACCESS.md +27 -0
- package/CONTRIBUTING.md +32 -0
- package/LICENSE +21 -0
- package/MEMORY_ATLAS.md +101 -0
- package/MEMORY_MODEL.md +179 -0
- package/README.md +751 -0
- package/RECALL_EXPLAINABILITY.md +152 -0
- package/RELEASE_CHECKLIST.md +92 -0
- package/SECURITY.md +21 -0
- package/dist/adapters/MarkdownSourceLoader.d.ts +5 -0
- package/dist/adapters/MarkdownSourceLoader.js +19 -0
- package/dist/adapters/conversation/ConversationMarkdownAdapter.d.ts +9 -0
- package/dist/adapters/conversation/ConversationMarkdownAdapter.js +233 -0
- package/dist/adapters/hermes/HermesStateDbAdapter.d.ts +10 -0
- package/dist/adapters/hermes/HermesStateDbAdapter.js +268 -0
- package/dist/adapters/hermes/HermesWorkspaceProfile.d.ts +15 -0
- package/dist/adapters/hermes/HermesWorkspaceProfile.js +82 -0
- package/dist/adapters/index.d.ts +15 -0
- package/dist/adapters/index.js +12 -0
- package/dist/adapters/openclaw/OpenClawAdapterSupport.d.ts +14 -0
- package/dist/adapters/openclaw/OpenClawAdapterSupport.js +29 -0
- package/dist/adapters/openclaw/OpenClawDailyMemoryAdapter.d.ts +8 -0
- package/dist/adapters/openclaw/OpenClawDailyMemoryAdapter.js +35 -0
- package/dist/adapters/openclaw/OpenClawMemoryIndexAdapter.d.ts +8 -0
- package/dist/adapters/openclaw/OpenClawMemoryIndexAdapter.js +23 -0
- package/dist/adapters/openclaw/OpenClawPersonaAdapter.d.ts +8 -0
- package/dist/adapters/openclaw/OpenClawPersonaAdapter.js +24 -0
- package/dist/adapters/openclaw/OpenClawSessionAdapter.d.ts +8 -0
- package/dist/adapters/openclaw/OpenClawSessionAdapter.js +15 -0
- package/dist/adapters/openclaw/OpenClawUserProfileAdapter.d.ts +8 -0
- package/dist/adapters/openclaw/OpenClawUserProfileAdapter.js +24 -0
- package/dist/adapters/openclaw/OpenClawWorkspaceProfile.d.ts +38 -0
- package/dist/adapters/openclaw/OpenClawWorkspaceProfile.js +199 -0
- package/dist/adapters/soul/SoulMarkdownAdapter.d.ts +14 -0
- package/dist/adapters/soul/SoulMarkdownAdapter.js +255 -0
- package/dist/adapters/types.d.ts +97 -0
- package/dist/adapters/types.js +185 -0
- package/dist/agent/AgentMemoryBackend.d.ts +291 -0
- package/dist/agent/AgentMemoryBackend.js +1272 -0
- package/dist/agent/AgentRecallQueryCompiler.d.ts +20 -0
- package/dist/agent/AgentRecallQueryCompiler.js +289 -0
- package/dist/agent/ContextHygiene.d.ts +9 -0
- package/dist/agent/ContextHygiene.js +20 -0
- package/dist/agent/MemoryUsageReceipt.d.ts +35 -0
- package/dist/agent/MemoryUsageReceipt.js +136 -0
- package/dist/agent/SessionWorkingState.d.ts +20 -0
- package/dist/agent/SessionWorkingState.js +94 -0
- package/dist/agent/index.d.ts +6 -0
- package/dist/agent/index.js +5 -0
- package/dist/algorithm/AlgorithmReviewBackend.d.ts +84 -0
- package/dist/algorithm/AlgorithmReviewBackend.js +261 -0
- package/dist/algorithm/AlgorithmReviewMetrics.d.ts +23 -0
- package/dist/algorithm/AlgorithmReviewMetrics.js +25 -0
- package/dist/algorithm/Phase2ModelAlgorithmReviewBackend.d.ts +38 -0
- package/dist/algorithm/Phase2ModelAlgorithmReviewBackend.js +372 -0
- package/dist/assets/FileAssetIngestionService.d.ts +32 -0
- package/dist/assets/FileAssetIngestionService.js +133 -0
- package/dist/assets/FileAssetStore.d.ts +36 -0
- package/dist/assets/FileAssetStore.js +152 -0
- package/dist/assets/FileBlockStore.d.ts +12 -0
- package/dist/assets/FileBlockStore.js +110 -0
- package/dist/assets/FileChunkStore.d.ts +23 -0
- package/dist/assets/FileChunkStore.js +179 -0
- package/dist/assets/FileChunker.d.ts +10 -0
- package/dist/assets/FileChunker.js +69 -0
- package/dist/assets/FileLoaderRegistry.d.ts +8 -0
- package/dist/assets/FileLoaderRegistry.js +21 -0
- package/dist/assets/FileLoaders.d.ts +37 -0
- package/dist/assets/FileLoaders.js +268 -0
- package/dist/assets/index.d.ts +10 -0
- package/dist/assets/index.js +7 -0
- package/dist/assets/providers/types.d.ts +47 -0
- package/dist/assets/providers/types.js +1 -0
- package/dist/assets/types.d.ts +159 -0
- package/dist/assets/types.js +1 -0
- package/dist/atlas/ActionFrameExtractor.d.ts +15 -0
- package/dist/atlas/ActionFrameExtractor.js +135 -0
- package/dist/atlas/MemoryAtlasIndexer.d.ts +32 -0
- package/dist/atlas/MemoryAtlasIndexer.js +74 -0
- package/dist/atlas/MemoryAtlasQueryCompiler.d.ts +23 -0
- package/dist/atlas/MemoryAtlasQueryCompiler.js +55 -0
- package/dist/atlas/MemoryAtlasService.d.ts +25 -0
- package/dist/atlas/MemoryAtlasService.js +216 -0
- package/dist/atlas/MemoryAtlasTypes.d.ts +107 -0
- package/dist/atlas/MemoryAtlasTypes.js +1 -0
- package/dist/atlas/index.d.ts +6 -0
- package/dist/atlas/index.js +5 -0
- package/dist/backend/SemanticBackend.d.ts +40 -0
- package/dist/backend/SemanticBackend.js +107 -0
- package/dist/batch/IngestionCursorStore.d.ts +52 -0
- package/dist/batch/IngestionCursorStore.js +153 -0
- package/dist/batch/InstalledBatchProcessor.d.ts +88 -0
- package/dist/batch/InstalledBatchProcessor.js +179 -0
- package/dist/batch/SourceOnboarding.d.ts +56 -0
- package/dist/batch/SourceOnboarding.js +366 -0
- package/dist/belief/BeliefGovernanceService.d.ts +59 -0
- package/dist/belief/BeliefGovernanceService.js +183 -0
- package/dist/belief/BeliefStore.d.ts +78 -0
- package/dist/belief/BeliefStore.js +898 -0
- package/dist/benchmark/BenchmarkRegistry.d.ts +16 -0
- package/dist/benchmark/BenchmarkRegistry.js +97 -0
- package/dist/benchmark/BenchmarkReport.d.ts +23 -0
- package/dist/benchmark/BenchmarkReport.js +62 -0
- package/dist/benchmark/BenchmarkRunner.d.ts +27 -0
- package/dist/benchmark/BenchmarkRunner.js +64 -0
- package/dist/benchmark/BrainEval.d.ts +134 -0
- package/dist/benchmark/BrainEval.js +252 -0
- package/dist/benchmark/ExternalBenchmarkRunner.d.ts +8 -0
- package/dist/benchmark/ExternalBenchmarkRunner.js +12 -0
- package/dist/benchmark/LongMemEvalAdapter.d.ts +46 -0
- package/dist/benchmark/LongMemEvalAdapter.js +88 -0
- package/dist/benchmark/LongMemEvalCli.d.ts +6 -0
- package/dist/benchmark/LongMemEvalCli.js +26 -0
- package/dist/bin/CliJson.d.ts +17 -0
- package/dist/bin/CliJson.js +20 -0
- package/dist/bin/brain-eval.d.ts +3 -0
- package/dist/bin/brain-eval.js +46 -0
- package/dist/bin/cogmem.d.ts +3 -0
- package/dist/bin/cogmem.js +95 -0
- package/dist/bin/compact.d.ts +3 -0
- package/dist/bin/compact.js +96 -0
- package/dist/bin/connect.d.ts +3 -0
- package/dist/bin/connect.js +398 -0
- package/dist/bin/doctor.d.ts +3 -0
- package/dist/bin/doctor.js +171 -0
- package/dist/bin/dream.d.ts +3 -0
- package/dist/bin/dream.js +65 -0
- package/dist/bin/episode.d.ts +3 -0
- package/dist/bin/episode.js +268 -0
- package/dist/bin/explain-recall.d.ts +3 -0
- package/dist/bin/explain-recall.js +139 -0
- package/dist/bin/import-hermes.d.ts +3 -0
- package/dist/bin/import-hermes.js +6 -0
- package/dist/bin/import-openclaw.d.ts +3 -0
- package/dist/bin/import-openclaw.js +6 -0
- package/dist/bin/import-support.d.ts +43 -0
- package/dist/bin/import-support.js +528 -0
- package/dist/bin/init.d.ts +30 -0
- package/dist/bin/init.js +761 -0
- package/dist/bin/mcp.d.ts +3 -0
- package/dist/bin/mcp.js +52 -0
- package/dist/bin/memory.d.ts +3 -0
- package/dist/bin/memory.js +803 -0
- package/dist/bin/migrate-vectors.d.ts +3 -0
- package/dist/bin/migrate-vectors.js +74 -0
- package/dist/bin/migrate.d.ts +3 -0
- package/dist/bin/migrate.js +95 -0
- package/dist/bin/normalize-transcript.d.ts +16 -0
- package/dist/bin/normalize-transcript.js +153 -0
- package/dist/bin/openclaw.d.ts +3 -0
- package/dist/bin/openclaw.js +78 -0
- package/dist/bin/prospective.d.ts +3 -0
- package/dist/bin/prospective.js +115 -0
- package/dist/bin/re-embed.d.ts +3 -0
- package/dist/bin/re-embed.js +46 -0
- package/dist/bin/repair.d.ts +3 -0
- package/dist/bin/repair.js +118 -0
- package/dist/bin/snapshot.d.ts +3 -0
- package/dist/bin/snapshot.js +100 -0
- package/dist/bin/strategy.d.ts +3 -0
- package/dist/bin/strategy.js +66 -0
- package/dist/bin/update-release.d.ts +15 -0
- package/dist/bin/update-release.js +62 -0
- package/dist/bin/update.d.ts +3 -0
- package/dist/bin/update.js +215 -0
- package/dist/binding/BindingClassifier.d.ts +19 -0
- package/dist/binding/BindingClassifier.js +270 -0
- package/dist/binding/BindingDecisionEngine.d.ts +11 -0
- package/dist/binding/BindingDecisionEngine.js +13 -0
- package/dist/binding/ClaimKeyGenerator.d.ts +4 -0
- package/dist/binding/ClaimKeyGenerator.js +21 -0
- package/dist/binding/MemoryBindingService.d.ts +28 -0
- package/dist/binding/MemoryBindingService.js +283 -0
- package/dist/binding/MemoryBindingTypes.d.ts +140 -0
- package/dist/binding/MemoryBindingTypes.js +1 -0
- package/dist/binding/TopicPathRegistry.d.ts +5 -0
- package/dist/binding/TopicPathRegistry.js +33 -0
- package/dist/binding/index.d.ts +12 -0
- package/dist/binding/index.js +6 -0
- package/dist/boards/ApprovalBoard.d.ts +14 -0
- package/dist/boards/ApprovalBoard.js +32 -0
- package/dist/boards/Board.d.ts +23 -0
- package/dist/boards/Board.js +1 -0
- package/dist/boards/BoardEventBuffer.d.ts +10 -0
- package/dist/boards/BoardEventBuffer.js +22 -0
- package/dist/boards/BoardEventBus.d.ts +15 -0
- package/dist/boards/BoardEventBus.js +38 -0
- package/dist/boards/BoardEventFilter.d.ts +5 -0
- package/dist/boards/BoardEventFilter.js +1 -0
- package/dist/boards/BoardRegistry.d.ts +11 -0
- package/dist/boards/BoardRegistry.js +15 -0
- package/dist/boards/ContextBoard.d.ts +15 -0
- package/dist/boards/ContextBoard.js +33 -0
- package/dist/boards/MemoryBoard.d.ts +13 -0
- package/dist/boards/MemoryBoard.js +30 -0
- package/dist/boards/ProcessBoard.d.ts +16 -0
- package/dist/boards/ProcessBoard.js +56 -0
- package/dist/boards/ProposalBoard.d.ts +13 -0
- package/dist/boards/ProposalBoard.js +37 -0
- package/dist/boards/ReasoningTraceBoard.d.ts +11 -0
- package/dist/boards/ReasoningTraceBoard.js +34 -0
- package/dist/boards/TaskBoard.d.ts +14 -0
- package/dist/boards/TaskBoard.js +37 -0
- package/dist/boards/index.d.ts +13 -0
- package/dist/boards/index.js +12 -0
- package/dist/config/CogmemConfig.d.ts +43 -0
- package/dist/config/CogmemConfig.js +247 -0
- package/dist/config/VectorDimension.d.ts +13 -0
- package/dist/config/VectorDimension.js +53 -0
- package/dist/context/ContextCortex.d.ts +71 -0
- package/dist/context/ContextCortex.js +156 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.js +1 -0
- package/dist/core/ImportanceLevels.d.ts +4 -0
- package/dist/core/ImportanceLevels.js +6 -0
- package/dist/core/IntentParser.d.ts +12 -0
- package/dist/core/IntentParser.js +211 -0
- package/dist/core/MemoryGraph.d.ts +100 -0
- package/dist/core/MemoryGraph.js +860 -0
- package/dist/core/Metabolism.d.ts +43 -0
- package/dist/core/Metabolism.js +196 -0
- package/dist/core/Neuron.d.ts +20 -0
- package/dist/core/Neuron.js +51 -0
- package/dist/core/QueryClassifier.d.ts +36 -0
- package/dist/core/QueryClassifier.js +161 -0
- package/dist/core/Reflection.d.ts +42 -0
- package/dist/core/Reflection.js +183 -0
- package/dist/core/ResonanceCore.d.ts +26 -0
- package/dist/core/ResonanceCore.js +115 -0
- package/dist/core/Synapse.d.ts +10 -0
- package/dist/core/Synapse.js +27 -0
- package/dist/core/TwoStagePulseRanker.d.ts +16 -0
- package/dist/core/TwoStagePulseRanker.js +120 -0
- package/dist/dream/DreamScheduler.d.ts +47 -0
- package/dist/dream/DreamScheduler.js +156 -0
- package/dist/dream/index.d.ts +2 -0
- package/dist/dream/index.js +1 -0
- package/dist/embedding/EmbeddingProvider.d.ts +16 -0
- package/dist/embedding/EmbeddingProvider.js +12 -0
- package/dist/embedding/NeuronEmbeddingStore.d.ts +38 -0
- package/dist/embedding/NeuronEmbeddingStore.js +193 -0
- package/dist/embedding/OllamaEmbeddingProvider.d.ts +21 -0
- package/dist/embedding/OllamaEmbeddingProvider.js +65 -0
- package/dist/embedding/QwenAPIEmbeddingProvider.d.ts +26 -0
- package/dist/embedding/QwenAPIEmbeddingProvider.js +53 -0
- package/dist/embedding/ReEmbeddingPipeline.d.ts +30 -0
- package/dist/embedding/ReEmbeddingPipeline.js +119 -0
- package/dist/embedding/ReEmbeddingStatus.d.ts +10 -0
- package/dist/embedding/ReEmbeddingStatus.js +1 -0
- package/dist/embedding/index.d.ts +11 -0
- package/dist/embedding/index.js +5 -0
- package/dist/encryption/AesGcmEncryptionProvider.d.ts +9 -0
- package/dist/encryption/AesGcmEncryptionProvider.js +42 -0
- package/dist/encryption/EncryptionProvider.d.ts +6 -0
- package/dist/encryption/EncryptionProvider.js +3 -0
- package/dist/encryption/index.d.ts +4 -0
- package/dist/encryption/index.js +2 -0
- package/dist/engine/BeliefExtractor.d.ts +48 -0
- package/dist/engine/BeliefExtractor.js +1189 -0
- package/dist/engine/CognitiveGraphCompiler.d.ts +24 -0
- package/dist/engine/CognitiveGraphCompiler.js +243 -0
- package/dist/engine/ConsolidationPipeline.d.ts +66 -0
- package/dist/engine/ConsolidationPipeline.js +376 -0
- package/dist/engine/ConsolidationTrigger.d.ts +18 -0
- package/dist/engine/ConsolidationTrigger.js +41 -0
- package/dist/engine/CrossTopicSynthesizer.d.ts +28 -0
- package/dist/engine/CrossTopicSynthesizer.js +70 -0
- package/dist/engine/CrossTopicTrigger.d.ts +17 -0
- package/dist/engine/CrossTopicTrigger.js +29 -0
- package/dist/engine/DeepWriteConfig.d.ts +14 -0
- package/dist/engine/DeepWriteConfig.js +37 -0
- package/dist/engine/DeepWriteMemoryCompiler.d.ts +43 -0
- package/dist/engine/DeepWriteMemoryCompiler.js +42 -0
- package/dist/engine/DeepWriteMemoryOrchestrator.d.ts +60 -0
- package/dist/engine/DeepWriteMemoryOrchestrator.js +175 -0
- package/dist/engine/DeepWritePromotionPolicy.d.ts +48 -0
- package/dist/engine/DeepWritePromotionPolicy.js +514 -0
- package/dist/engine/DeepWriteRedactor.d.ts +14 -0
- package/dist/engine/DeepWriteRedactor.js +53 -0
- package/dist/engine/DreamCuratorSchedule.d.ts +18 -0
- package/dist/engine/DreamCuratorSchedule.js +95 -0
- package/dist/engine/DreamCuratorWorker.d.ts +67 -0
- package/dist/engine/DreamCuratorWorker.js +908 -0
- package/dist/engine/EntityResolutionEngine.d.ts +45 -0
- package/dist/engine/EntityResolutionEngine.js +105 -0
- package/dist/engine/EpisodicSemanticDistiller.d.ts +25 -0
- package/dist/engine/EpisodicSemanticDistiller.js +68 -0
- package/dist/engine/EvolutionVerifier.d.ts +39 -0
- package/dist/engine/EvolutionVerifier.js +104 -0
- package/dist/engine/FactCompiler.d.ts +41 -0
- package/dist/engine/FactCompiler.js +820 -0
- package/dist/engine/GraphCommunityEngine.d.ts +20 -0
- package/dist/engine/GraphCommunityEngine.js +91 -0
- package/dist/engine/ImportanceSignalDetector.d.ts +11 -0
- package/dist/engine/ImportanceSignalDetector.js +51 -0
- package/dist/engine/IngestionEngine.d.ts +44 -0
- package/dist/engine/IngestionEngine.js +182 -0
- package/dist/engine/InteractionBinder.d.ts +16 -0
- package/dist/engine/InteractionBinder.js +87 -0
- package/dist/engine/LocalSemanticCompiler.d.ts +40 -0
- package/dist/engine/LocalSemanticCompiler.js +111 -0
- package/dist/engine/MemoryConsolidationEngine.d.ts +11 -0
- package/dist/engine/MemoryConsolidationEngine.js +21 -0
- package/dist/engine/MemoryGate.d.ts +10 -0
- package/dist/engine/MemoryGate.js +34 -0
- package/dist/engine/OfflineConsolidationPipeline.d.ts +148 -0
- package/dist/engine/OfflineConsolidationPipeline.js +670 -0
- package/dist/engine/OrphanCleaner.d.ts +15 -0
- package/dist/engine/OrphanCleaner.js +27 -0
- package/dist/engine/PipelineMetrics.d.ts +32 -0
- package/dist/engine/PipelineMetrics.js +126 -0
- package/dist/engine/PrincipleDecayPolicy.d.ts +17 -0
- package/dist/engine/PrincipleDecayPolicy.js +64 -0
- package/dist/engine/TopologyCompiler.d.ts +25 -0
- package/dist/engine/TopologyCompiler.js +276 -0
- package/dist/engine/WorkingMemoryDelta.d.ts +23 -0
- package/dist/engine/WorkingMemoryDelta.js +63 -0
- package/dist/entity/EntityGovernanceService.d.ts +47 -0
- package/dist/entity/EntityGovernanceService.js +215 -0
- package/dist/entity/index.d.ts +3 -0
- package/dist/entity/index.js +1 -0
- package/dist/episode/CogmemBlockStripper.d.ts +11 -0
- package/dist/episode/CogmemBlockStripper.js +58 -0
- package/dist/episode/CorrectionResolver.d.ts +30 -0
- package/dist/episode/CorrectionResolver.js +17 -0
- package/dist/episode/EpisodeAssembler.d.ts +54 -0
- package/dist/episode/EpisodeAssembler.js +203 -0
- package/dist/episode/EpisodeImportIdentity.d.ts +7 -0
- package/dist/episode/EpisodeImportIdentity.js +17 -0
- package/dist/episode/EpisodeSemanticSummarizer.d.ts +4 -0
- package/dist/episode/EpisodeSemanticSummarizer.js +31 -0
- package/dist/episode/EpisodeStore.d.ts +189 -0
- package/dist/episode/EpisodeStore.js +680 -0
- package/dist/episode/EpisodeTypes.d.ts +96 -0
- package/dist/episode/EpisodeTypes.js +1 -0
- package/dist/episode/TurnRelationClassifier.d.ts +40 -0
- package/dist/episode/TurnRelationClassifier.js +205 -0
- package/dist/episode/index.d.ts +9 -0
- package/dist/episode/index.js +8 -0
- package/dist/eval/datasets/contradiction_injection.d.ts +3 -0
- package/dist/eval/datasets/contradiction_injection.js +56 -0
- package/dist/eval/datasets/noisy_tool_output_corpus.d.ts +16 -0
- package/dist/eval/datasets/noisy_tool_output_corpus.js +59 -0
- package/dist/eval/datasets/synthetic_long_conversation.d.ts +40 -0
- package/dist/eval/datasets/synthetic_long_conversation.js +136 -0
- package/dist/eval/runners/EvalRunner.d.ts +12 -0
- package/dist/eval/runners/EvalRunner.js +66 -0
- package/dist/eval/runners/ReportFormatter.d.ts +13 -0
- package/dist/eval/runners/ReportFormatter.js +59 -0
- package/dist/eval/strategy/ContextOutcomeStore.d.ts +12 -0
- package/dist/eval/strategy/ContextOutcomeStore.js +44 -0
- package/dist/eval/strategy/ContextPolicyScorer.d.ts +25 -0
- package/dist/eval/strategy/ContextPolicyScorer.js +58 -0
- package/dist/eval/strategy/MemoryUseJudge.d.ts +49 -0
- package/dist/eval/strategy/MemoryUseJudge.js +75 -0
- package/dist/eval/strategy/StrategyDiversitySelector.d.ts +8 -0
- package/dist/eval/strategy/StrategyDiversitySelector.js +44 -0
- package/dist/eval/strategy/StrategyRolloutEvaluator.d.ts +15 -0
- package/dist/eval/strategy/StrategyRolloutEvaluator.js +30 -0
- package/dist/eval/strategy/index.d.ts +6 -0
- package/dist/eval/strategy/index.js +5 -0
- package/dist/factory.d.ts +726 -0
- package/dist/factory.js +2118 -0
- package/dist/governance/CandidateReviewService.d.ts +33 -0
- package/dist/governance/CandidateReviewService.js +126 -0
- package/dist/governance/ContradictionResolver.d.ts +22 -0
- package/dist/governance/ContradictionResolver.js +54 -0
- package/dist/governance/CredibilityScorer.d.ts +10 -0
- package/dist/governance/CredibilityScorer.js +29 -0
- package/dist/governance/DecayPolicy.d.ts +18 -0
- package/dist/governance/DecayPolicy.js +28 -0
- package/dist/governance/MemoryExplain.d.ts +46 -0
- package/dist/governance/MemoryExplain.js +62 -0
- package/dist/governance/MemoryGovernanceExecutor.d.ts +18 -0
- package/dist/governance/MemoryGovernanceExecutor.js +37 -0
- package/dist/governance/MemoryGovernancePlan.d.ts +36 -0
- package/dist/governance/MemoryGovernancePlan.js +1 -0
- package/dist/governance/MemoryGovernanceValidator.d.ts +13 -0
- package/dist/governance/MemoryGovernanceValidator.js +53 -0
- package/dist/governance/ObservationHygieneRules.d.ts +17 -0
- package/dist/governance/ObservationHygieneRules.js +28 -0
- package/dist/governance/PiiRedactor.d.ts +20 -0
- package/dist/governance/PiiRedactor.js +37 -0
- package/dist/governance/SupersedeChain.d.ts +21 -0
- package/dist/governance/SupersedeChain.js +107 -0
- package/dist/governance/index.d.ts +14 -0
- package/dist/governance/index.js +6 -0
- package/dist/graph/BrainGraphView.d.ts +20 -0
- package/dist/graph/BrainGraphView.js +45 -0
- package/dist/host/openclaw/AutoMemoryPluginInstaller.d.ts +45 -0
- package/dist/host/openclaw/AutoMemoryPluginInstaller.js +1904 -0
- package/dist/internal.d.ts +148 -0
- package/dist/internal.js +144 -0
- package/dist/lexicon/coreMemoryLexicon.d.ts +96 -0
- package/dist/lexicon/coreMemoryLexicon.js +525 -0
- package/dist/lexicon/language-packs/en.d.ts +42 -0
- package/dist/lexicon/language-packs/en.js +41 -0
- package/dist/lexicon/language-packs/zh.d.ts +42 -0
- package/dist/lexicon/language-packs/zh.js +41 -0
- package/dist/lexicon/zh/entities.d.ts +2 -0
- package/dist/lexicon/zh/entities.js +17 -0
- package/dist/lexicon/zh/index.d.ts +5 -0
- package/dist/lexicon/zh/index.js +3 -0
- package/dist/lexicon/zh/stopwords.d.ts +2 -0
- package/dist/lexicon/zh/stopwords.js +22 -0
- package/dist/lexicon/zh/topics.d.ts +6 -0
- package/dist/lexicon/zh/topics.js +52 -0
- package/dist/mcp/CoreMcpTools.d.ts +33 -0
- package/dist/mcp/CoreMcpTools.js +832 -0
- package/dist/mcp/server.d.ts +5 -0
- package/dist/mcp/server.js +29 -0
- package/dist/meta/MetaObservationCollector.d.ts +37 -0
- package/dist/meta/MetaObservationCollector.js +348 -0
- package/dist/meta/PolicyProposalGenerator.d.ts +11 -0
- package/dist/meta/PolicyProposalGenerator.js +159 -0
- package/dist/meta/ProposalApplier.d.ts +18 -0
- package/dist/meta/ProposalApplier.js +91 -0
- package/dist/meta/ProposalConfigOverlay.d.ts +13 -0
- package/dist/meta/ProposalConfigOverlay.js +27 -0
- package/dist/meta/ProposalEvalRunner.d.ts +31 -0
- package/dist/meta/ProposalEvalRunner.js +62 -0
- package/dist/meta/ProposalLedger.d.ts +34 -0
- package/dist/meta/ProposalLedger.js +242 -0
- package/dist/meta/types.d.ts +63 -0
- package/dist/meta/types.js +1 -0
- package/dist/migrations/0001_init.d.ts +4 -0
- package/dist/migrations/0001_init.js +67 -0
- package/dist/migrations/0002_v06_platform.d.ts +10 -0
- package/dist/migrations/0002_v06_platform.js +103 -0
- package/dist/migrations/0003_v07_dialogues.d.ts +9 -0
- package/dist/migrations/0003_v07_dialogues.js +53 -0
- package/dist/migrations/0004_v09_self_improvement.d.ts +9 -0
- package/dist/migrations/0004_v09_self_improvement.js +100 -0
- package/dist/migrations/0005_dialogue_buffer.d.ts +8 -0
- package/dist/migrations/0005_dialogue_buffer.js +44 -0
- package/dist/migrations/0006_deep_write_memory.d.ts +3 -0
- package/dist/migrations/0006_deep_write_memory.js +54 -0
- package/dist/migrations/0007_deep_write_summaries.d.ts +3 -0
- package/dist/migrations/0007_deep_write_summaries.js +24 -0
- package/dist/migrations/0009_memory_importance.d.ts +3 -0
- package/dist/migrations/0009_memory_importance.js +18 -0
- package/dist/migrations/0010_skill_neurons.d.ts +3 -0
- package/dist/migrations/0010_skill_neurons.js +19 -0
- package/dist/migrations/0011_topic_path.d.ts +3 -0
- package/dist/migrations/0011_topic_path.js +19 -0
- package/dist/migrations/0012_governance_security.d.ts +3 -0
- package/dist/migrations/0012_governance_security.js +23 -0
- package/dist/migrations/0015_memory_governance.d.ts +3 -0
- package/dist/migrations/0015_memory_governance.js +74 -0
- package/dist/migrations/0016_entity_governance.d.ts +3 -0
- package/dist/migrations/0016_entity_governance.js +40 -0
- package/dist/migrations/0017_belief_graph.d.ts +3 -0
- package/dist/migrations/0017_belief_graph.js +41 -0
- package/dist/migrations/0018_temporal_memory.d.ts +3 -0
- package/dist/migrations/0018_temporal_memory.js +25 -0
- package/dist/migrations/0019_context_cortex.d.ts +3 -0
- package/dist/migrations/0019_context_cortex.js +19 -0
- package/dist/migrations/0020_prospective_memory.d.ts +3 -0
- package/dist/migrations/0020_prospective_memory.js +42 -0
- package/dist/migrations/0021_strategy_cortex.d.ts +3 -0
- package/dist/migrations/0021_strategy_cortex.js +23 -0
- package/dist/migrations/0022_episode_dream_engine.d.ts +3 -0
- package/dist/migrations/0022_episode_dream_engine.js +74 -0
- package/dist/migrations/0023_episode_dream_hardening.d.ts +3 -0
- package/dist/migrations/0023_episode_dream_hardening.js +65 -0
- package/dist/migrations/0024_episode_ontology_reliability.d.ts +3 -0
- package/dist/migrations/0024_episode_ontology_reliability.js +70 -0
- package/dist/migrations/0025_memory_atlas.d.ts +6 -0
- package/dist/migrations/0025_memory_atlas.js +268 -0
- package/dist/migrations/0026_runtime_governance_atlas_reliability.d.ts +3 -0
- package/dist/migrations/0026_runtime_governance_atlas_reliability.js +72 -0
- package/dist/migrations/0027_openclaw_upgrade_hotfix.d.ts +3 -0
- package/dist/migrations/0027_openclaw_upgrade_hotfix.js +21 -0
- package/dist/migrations/SchemaMigrationRunner.d.ts +21 -0
- package/dist/migrations/SchemaMigrationRunner.js +67 -0
- package/dist/migrations/index.d.ts +36 -0
- package/dist/migrations/index.js +57 -0
- package/dist/models/ModelCapabilityRouter.d.ts +17 -0
- package/dist/models/ModelCapabilityRouter.js +75 -0
- package/dist/models/ModelRegistry.d.ts +15 -0
- package/dist/models/ModelRegistry.js +132 -0
- package/dist/models/ModelRole.d.ts +19 -0
- package/dist/models/ModelRole.js +1 -0
- package/dist/models/UserInsight.d.ts +16 -0
- package/dist/models/UserInsight.js +9 -0
- package/dist/models/UserInsightExtractor.d.ts +19 -0
- package/dist/models/UserInsightExtractor.js +99 -0
- package/dist/models/UserModelManager.d.ts +21 -0
- package/dist/models/UserModelManager.js +41 -0
- package/dist/models/UserModelStore.d.ts +20 -0
- package/dist/models/UserModelStore.js +136 -0
- package/dist/models/WorkingMemoryReporter.d.ts +16 -0
- package/dist/models/WorkingMemoryReporter.js +38 -0
- package/dist/models/adapters/MemoryReviewAdapter.d.ts +12 -0
- package/dist/models/adapters/MemoryReviewAdapter.js +77 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.js +5 -0
- package/dist/models/providers/AnthropicClient.d.ts +17 -0
- package/dist/models/providers/AnthropicClient.js +40 -0
- package/dist/models/providers/OpenAICompatibleClient.d.ts +24 -0
- package/dist/models/providers/OpenAICompatibleClient.js +76 -0
- package/dist/observability/DecisionExplainer.d.ts +5 -0
- package/dist/observability/DecisionExplainer.js +62 -0
- package/dist/observability/TraceEvent.d.ts +11 -0
- package/dist/observability/TraceEvent.js +1 -0
- package/dist/observability/TraceQuery.d.ts +15 -0
- package/dist/observability/TraceQuery.js +28 -0
- package/dist/observability/TraceStore.d.ts +15 -0
- package/dist/observability/TraceStore.js +110 -0
- package/dist/observability/TraceWriter.d.ts +8 -0
- package/dist/observability/TraceWriter.js +14 -0
- package/dist/ontology/MemoryOntology.d.ts +4 -0
- package/dist/ontology/MemoryOntology.js +7 -0
- package/dist/prospective/ProspectiveMemoryService.d.ts +79 -0
- package/dist/prospective/ProspectiveMemoryService.js +258 -0
- package/dist/prospective/index.d.ts +2 -0
- package/dist/prospective/index.js +1 -0
- package/dist/public.d.ts +160 -0
- package/dist/public.js +115 -0
- package/dist/recall/BrainRecall.d.ts +96 -0
- package/dist/recall/BrainRecall.js +574 -0
- package/dist/recall/HierarchicalRecallRouter.d.ts +24 -0
- package/dist/recall/HierarchicalRecallRouter.js +62 -0
- package/dist/recall/RecallExplanation.d.ts +59 -0
- package/dist/recall/RecallExplanation.js +244 -0
- package/dist/recall/RecallGovernance.d.ts +10 -0
- package/dist/recall/RecallGovernance.js +83 -0
- package/dist/recall/RecallSufficiencyGate.d.ts +40 -0
- package/dist/recall/RecallSufficiencyGate.js +208 -0
- package/dist/recall/SourceContextMetadata.d.ts +49 -0
- package/dist/recall/SourceContextMetadata.js +134 -0
- package/dist/recall/TopicClassifier.d.ts +33 -0
- package/dist/recall/TopicClassifier.js +138 -0
- package/dist/recall/TopicDecayPolicy.d.ts +15 -0
- package/dist/recall/TopicDecayPolicy.js +46 -0
- package/dist/recall/TopicRegistry.d.ts +12 -0
- package/dist/recall/TopicRegistry.js +26 -0
- package/dist/recall/TopicSummaryBoard.d.ts +27 -0
- package/dist/recall/TopicSummaryBoard.js +139 -0
- package/dist/recall/VectorCandidateFilter.d.ts +50 -0
- package/dist/recall/VectorCandidateFilter.js +78 -0
- package/dist/retrieval/ConditionDslEvaluator.d.ts +33 -0
- package/dist/retrieval/ConditionDslEvaluator.js +160 -0
- package/dist/retrieval/EntityActivationIndex.d.ts +14 -0
- package/dist/retrieval/EntityActivationIndex.js +19 -0
- package/dist/retrieval/EvidenceFusionPolicy.d.ts +30 -0
- package/dist/retrieval/EvidenceFusionPolicy.js +112 -0
- package/dist/retrieval/EvidenceFusionRanker.d.ts +13 -0
- package/dist/retrieval/EvidenceFusionRanker.js +17 -0
- package/dist/retrieval/NarrativeRecallAssembler.d.ts +32 -0
- package/dist/retrieval/NarrativeRecallAssembler.js +27 -0
- package/dist/retrieval/NativeQueryParser.d.ts +23 -0
- package/dist/retrieval/NativeQueryParser.js +135 -0
- package/dist/retrieval/PlanDslExecutor.d.ts +67 -0
- package/dist/retrieval/PlanDslExecutor.js +194 -0
- package/dist/retrieval/PolicyRuntimeEvaluator.d.ts +48 -0
- package/dist/retrieval/PolicyRuntimeEvaluator.js +96 -0
- package/dist/retrieval/PolicySideEffectExecutor.d.ts +50 -0
- package/dist/retrieval/PolicySideEffectExecutor.js +202 -0
- package/dist/retrieval/PulseRetrievalEngine.d.ts +37 -0
- package/dist/retrieval/PulseRetrievalEngine.js +51 -0
- package/dist/retrieval/QueryCompiler.d.ts +18 -0
- package/dist/retrieval/QueryCompiler.js +97 -0
- package/dist/retrieval/QueryTimePendingEntityResolver.d.ts +67 -0
- package/dist/retrieval/QueryTimePendingEntityResolver.js +260 -0
- package/dist/retrieval/RetrievalPlanner.d.ts +42 -0
- package/dist/retrieval/RetrievalPlanner.js +209 -0
- package/dist/retrieval/TemporalBranchSearch.d.ts +38 -0
- package/dist/retrieval/TemporalBranchSearch.js +109 -0
- package/dist/retrieval/UniverseNavigator.d.ts +43 -0
- package/dist/retrieval/UniverseNavigator.js +75 -0
- package/dist/retrieval/UniverseTraversalExecutor.d.ts +21 -0
- package/dist/retrieval/UniverseTraversalExecutor.js +77 -0
- package/dist/routing/AnswerEvidenceTrace.d.ts +18 -0
- package/dist/routing/AnswerEvidenceTrace.js +1 -0
- package/dist/routing/BrainToolDispatcher.d.ts +37 -0
- package/dist/routing/BrainToolDispatcher.js +163 -0
- package/dist/routing/ConfidenceGate.d.ts +26 -0
- package/dist/routing/ConfidenceGate.js +40 -0
- package/dist/routing/ConfirmationPhraseMatcher.d.ts +9 -0
- package/dist/routing/ConfirmationPhraseMatcher.js +43 -0
- package/dist/routing/DirectReplyFormatter.d.ts +5 -0
- package/dist/routing/DirectReplyFormatter.js +55 -0
- package/dist/routing/EvidenceBudgetManager.d.ts +30 -0
- package/dist/routing/EvidenceBudgetManager.js +55 -0
- package/dist/routing/ExecutionLoop.d.ts +79 -0
- package/dist/routing/ExecutionLoop.js +234 -0
- package/dist/routing/IntentClassifier.d.ts +15 -0
- package/dist/routing/IntentClassifier.js +97 -0
- package/dist/routing/IntentPatternMatcher.d.ts +12 -0
- package/dist/routing/IntentPatternMatcher.js +206 -0
- package/dist/routing/IterativeLLMClarifier.d.ts +80 -0
- package/dist/routing/IterativeLLMClarifier.js +408 -0
- package/dist/routing/LLMToolSchema.d.ts +60 -0
- package/dist/routing/LLMToolSchema.js +143 -0
- package/dist/routing/MessageRouter.d.ts +20 -0
- package/dist/routing/MessageRouter.js +58 -0
- package/dist/routing/SessionContextSelector.d.ts +12 -0
- package/dist/routing/SessionContextSelector.js +86 -0
- package/dist/routing/SystemIntentClassifier.d.ts +15 -0
- package/dist/routing/SystemIntentClassifier.js +50 -0
- package/dist/routing/TaskPlan.d.ts +31 -0
- package/dist/routing/TaskPlan.js +1 -0
- package/dist/routing/TaskRouter.d.ts +13 -0
- package/dist/routing/TaskRouter.js +111 -0
- package/dist/routing/ToolCallParser.d.ts +16 -0
- package/dist/routing/ToolCallParser.js +123 -0
- package/dist/routing/ToolEvidenceNormalizer.d.ts +13 -0
- package/dist/routing/ToolEvidenceNormalizer.js +96 -0
- package/dist/routing/ToolEvidencePack.d.ts +36 -0
- package/dist/routing/ToolEvidencePack.js +84 -0
- package/dist/routing/ToolResultSanitizer.d.ts +19 -0
- package/dist/routing/ToolResultSanitizer.js +58 -0
- package/dist/routing/ToolUsePolicy.d.ts +78 -0
- package/dist/routing/ToolUsePolicy.js +163 -0
- package/dist/routing/index.d.ts +32 -0
- package/dist/routing/index.js +19 -0
- package/dist/routing/templates/ability_template.d.ts +2 -0
- package/dist/routing/templates/ability_template.js +34 -0
- package/dist/routing/templates/approvals_template.d.ts +2 -0
- package/dist/routing/templates/approvals_template.js +43 -0
- package/dist/routing/templates/context_template.d.ts +2 -0
- package/dist/routing/templates/context_template.js +25 -0
- package/dist/routing/templates/contradictions_template.d.ts +2 -0
- package/dist/routing/templates/contradictions_template.js +36 -0
- package/dist/routing/templates/importance_template.d.ts +2 -0
- package/dist/routing/templates/importance_template.js +23 -0
- package/dist/routing/templates/memory_template.d.ts +2 -0
- package/dist/routing/templates/memory_template.js +37 -0
- package/dist/routing/templates/self_manifest_template.d.ts +5 -0
- package/dist/routing/templates/self_manifest_template.js +64 -0
- package/dist/routing/templates/tasks_template.d.ts +2 -0
- package/dist/routing/templates/tasks_template.js +41 -0
- package/dist/routing/templates/trace_template.d.ts +2 -0
- package/dist/routing/templates/trace_template.js +37 -0
- package/dist/routing/tools/EntityExpandTool.d.ts +25 -0
- package/dist/routing/tools/EntityExpandTool.js +59 -0
- package/dist/routing/tools/NeuronContextTool.d.ts +32 -0
- package/dist/routing/tools/NeuronContextTool.js +66 -0
- package/dist/routing/tools/SecondaryRecallTool.d.ts +27 -0
- package/dist/routing/tools/SecondaryRecallTool.js +30 -0
- package/dist/routing/tools/SkillDiscoveryTool.d.ts +13 -0
- package/dist/routing/tools/SkillDiscoveryTool.js +11 -0
- package/dist/snapshot/SnapshotExporter.d.ts +13 -0
- package/dist/snapshot/SnapshotExporter.js +70 -0
- package/dist/snapshot/SnapshotHeader.d.ts +15 -0
- package/dist/snapshot/SnapshotHeader.js +1 -0
- package/dist/snapshot/SnapshotImporter.d.ts +20 -0
- package/dist/snapshot/SnapshotImporter.js +40 -0
- package/dist/snapshot/errors.d.ts +18 -0
- package/dist/snapshot/errors.js +34 -0
- package/dist/snapshot/index.d.ts +5 -0
- package/dist/snapshot/index.js +3 -0
- package/dist/storage/StorageCompactor.d.ts +30 -0
- package/dist/storage/StorageCompactor.js +95 -0
- package/dist/store/ActivationStore.d.ts +45 -0
- package/dist/store/ActivationStore.js +135 -0
- package/dist/store/BackgroundJobStore.d.ts +49 -0
- package/dist/store/BackgroundJobStore.js +156 -0
- package/dist/store/CandidateReviewStore.d.ts +33 -0
- package/dist/store/CandidateReviewStore.js +67 -0
- package/dist/store/CognitiveGraphStore.d.ts +42 -0
- package/dist/store/CognitiveGraphStore.js +193 -0
- package/dist/store/CompilerConfidenceStore.d.ts +20 -0
- package/dist/store/CompilerConfidenceStore.js +76 -0
- package/dist/store/DeepWriteCandidateStore.d.ts +94 -0
- package/dist/store/DeepWriteCandidateStore.js +290 -0
- package/dist/store/DeterministicEmbedder.d.ts +10 -0
- package/dist/store/DeterministicEmbedder.js +24 -0
- package/dist/store/DreamLedgerStore.d.ts +22 -0
- package/dist/store/DreamLedgerStore.js +84 -0
- package/dist/store/Embedder.d.ts +14 -0
- package/dist/store/Embedder.js +52 -0
- package/dist/store/EmbedderFactory.d.ts +12 -0
- package/dist/store/EmbedderFactory.js +51 -0
- package/dist/store/EntityStore.d.ts +195 -0
- package/dist/store/EntityStore.js +941 -0
- package/dist/store/EventStore.d.ts +118 -0
- package/dist/store/EventStore.js +699 -0
- package/dist/store/FactStore.d.ts +76 -0
- package/dist/store/FactStore.js +356 -0
- package/dist/store/HnswlibVectorStore.d.ts +2 -0
- package/dist/store/HnswlibVectorStore.js +1 -0
- package/dist/store/IVectorStore.d.ts +32 -0
- package/dist/store/IVectorStore.js +1 -0
- package/dist/store/InteractionUnitStore.d.ts +52 -0
- package/dist/store/InteractionUnitStore.js +167 -0
- package/dist/store/MemoryAtlasStore.d.ts +60 -0
- package/dist/store/MemoryAtlasStore.js +500 -0
- package/dist/store/MemoryBindingStore.d.ts +77 -0
- package/dist/store/MemoryBindingStore.js +608 -0
- package/dist/store/MemoryGovernanceStore.d.ts +23 -0
- package/dist/store/MemoryGovernanceStore.js +103 -0
- package/dist/store/MemoryInspectionStore.d.ts +61 -0
- package/dist/store/MemoryInspectionStore.js +215 -0
- package/dist/store/PlanRuntimeStore.d.ts +83 -0
- package/dist/store/PlanRuntimeStore.js +257 -0
- package/dist/store/PolicyExecutionProjector.d.ts +17 -0
- package/dist/store/PolicyExecutionProjector.js +115 -0
- package/dist/store/PolicyExecutionStore.d.ts +62 -0
- package/dist/store/PolicyExecutionStore.js +290 -0
- package/dist/store/PolicyProjectionStore.d.ts +18 -0
- package/dist/store/PolicyProjectionStore.js +61 -0
- package/dist/store/ProjectionObservabilityStore.d.ts +38 -0
- package/dist/store/ProjectionObservabilityStore.js +310 -0
- package/dist/store/ReasoningChainStore.d.ts +13 -0
- package/dist/store/ReasoningChainStore.js +74 -0
- package/dist/store/RuntimeProjectionStore.d.ts +18 -0
- package/dist/store/RuntimeProjectionStore.js +61 -0
- package/dist/store/RuntimeProjector.d.ts +17 -0
- package/dist/store/RuntimeProjector.js +119 -0
- package/dist/store/SqliteVecStore.d.ts +25 -0
- package/dist/store/SqliteVecStore.js +126 -0
- package/dist/store/SummaryStore.d.ts +56 -0
- package/dist/store/SummaryStore.js +225 -0
- package/dist/store/TemporalAdjacencyStore.d.ts +49 -0
- package/dist/store/TemporalAdjacencyStore.js +300 -0
- package/dist/store/TopologyStore.d.ts +89 -0
- package/dist/store/TopologyStore.js +657 -0
- package/dist/store/VectorProjector.d.ts +22 -0
- package/dist/store/VectorProjector.js +125 -0
- package/dist/store/VectorStore.d.ts +35 -0
- package/dist/store/VectorStore.js +201 -0
- package/dist/strategy/StrategyCapsule.d.ts +44 -0
- package/dist/strategy/StrategyCapsule.js +1 -0
- package/dist/strategy/StrategyConditionedCandidateBuilder.d.ts +9 -0
- package/dist/strategy/StrategyConditionedCandidateBuilder.js +11 -0
- package/dist/strategy/StrategyContextFormatter.d.ts +3 -0
- package/dist/strategy/StrategyContextFormatter.js +25 -0
- package/dist/strategy/StrategyCortex.d.ts +28 -0
- package/dist/strategy/StrategyCortex.js +78 -0
- package/dist/strategy/StrategyTemplateRegistry.d.ts +9 -0
- package/dist/strategy/StrategyTemplateRegistry.js +78 -0
- package/dist/strategy/index.d.ts +6 -0
- package/dist/strategy/index.js +5 -0
- package/dist/temporal/TemporalMemoryService.d.ts +62 -0
- package/dist/temporal/TemporalMemoryService.js +128 -0
- package/dist/temporal/index.d.ts +2 -0
- package/dist/temporal/index.js +1 -0
- package/dist/topic/TopicAliasRegistry.d.ts +21 -0
- package/dist/topic/TopicAliasRegistry.js +67 -0
- package/dist/topic/TopicGovernance.d.ts +21 -0
- package/dist/topic/TopicGovernance.js +173 -0
- package/dist/topic/TopicPathRegistry.d.ts +36 -0
- package/dist/topic/TopicPathRegistry.js +105 -0
- package/dist/topic/TopicRelationGraph.d.ts +23 -0
- package/dist/topic/TopicRelationGraph.js +55 -0
- package/dist/topic/TopicTypes.d.ts +73 -0
- package/dist/topic/TopicTypes.js +1 -0
- package/dist/topic/index.d.ts +6 -0
- package/dist/topic/index.js +5 -0
- package/dist/types/AsyncEnrichment.d.ts +62 -0
- package/dist/types/AsyncEnrichment.js +7 -0
- package/dist/types/BrainRecallResult.d.ts +66 -0
- package/dist/types/BrainRecallResult.js +1 -0
- package/dist/types/ExtensionPoints.d.ts +116 -0
- package/dist/types/ExtensionPoints.js +1 -0
- package/dist/types/Migration.d.ts +22 -0
- package/dist/types/Migration.js +1 -0
- package/dist/types/QueryTimePendingEntityResolution.d.ts +11 -0
- package/dist/types/QueryTimePendingEntityResolution.js +23 -0
- package/dist/types/index.d.ts +855 -0
- package/dist/types/index.js +24 -0
- package/dist/types/query-ir.d.ts +71 -0
- package/dist/types/query-ir.js +4 -0
- package/dist/types/reasoning.d.ts +16 -0
- package/dist/types/reasoning.js +4 -0
- package/dist/utils/AAAKGenerator.d.ts +57 -0
- package/dist/utils/AAAKGenerator.js +212 -0
- package/dist/utils/Config.d.ts +78 -0
- package/dist/utils/Config.js +91 -0
- package/dist/utils/ConversationMarkdownNormalization.d.ts +88 -0
- package/dist/utils/ConversationMarkdownNormalization.js +567 -0
- package/dist/utils/Logger.d.ts +22 -0
- package/dist/utils/Logger.js +77 -0
- package/dist/utils/hash.d.ts +33 -0
- package/dist/utils/hash.js +53 -0
- package/dist/utils/text.d.ts +2 -0
- package/dist/utils/text.js +19 -0
- package/dist/utils/vector.d.ts +26 -0
- package/dist/utils/vector.js +38 -0
- package/examples/hermes-backend/AGENTS.md +218 -0
- package/examples/hermes-backend/README.md +153 -0
- package/examples/hermes-backend/SKILL.md +365 -0
- package/examples/hermes-backend/references/operations.md +202 -0
- package/examples/openclaw-backend/AGENTS.md +195 -0
- package/examples/openclaw-backend/README.md +228 -0
- package/examples/openclaw-backend/SKILL.md +464 -0
- package/examples/openclaw-backend/references/operations.md +269 -0
- package/install.sh +84 -0
- package/package.json +90 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { backfillAtlasDocuments, installAtlasProjectionDirtyTriggers } from '../migrations/0025_memory_atlas.js';
|
|
2
|
+
import { ActionFrameExtractor } from './ActionFrameExtractor.js';
|
|
3
|
+
export class MemoryAtlasIndexer {
|
|
4
|
+
db;
|
|
5
|
+
store;
|
|
6
|
+
actions;
|
|
7
|
+
constructor(db, eventStore, store) {
|
|
8
|
+
this.db = db;
|
|
9
|
+
this.store = store;
|
|
10
|
+
installAtlasProjectionDirtyTriggers(db);
|
|
11
|
+
this.actions = new ActionFrameExtractor(db, eventStore, store);
|
|
12
|
+
}
|
|
13
|
+
rebuild(options = {}) {
|
|
14
|
+
const projectId = options.projectId;
|
|
15
|
+
let actions = 0;
|
|
16
|
+
try {
|
|
17
|
+
this.db.transaction(() => {
|
|
18
|
+
if (projectId) {
|
|
19
|
+
this.db.prepare(`DELETE FROM memory_atlas_documents WHERE project_id=? AND node_type IN ('project','entity','topic','cluster','episode','belief')`).run(projectId);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.db.exec(`DELETE FROM memory_atlas_documents WHERE node_type IN ('project','entity','topic','cluster','episode','belief');`);
|
|
23
|
+
}
|
|
24
|
+
backfillAtlasDocuments(this.db, projectId);
|
|
25
|
+
const projects = projectId
|
|
26
|
+
? [projectId]
|
|
27
|
+
: this.db.prepare(`SELECT DISTINCT project_id FROM memory_atlas_documents WHERE project_id<>''`).all().map((row) => row.project_id);
|
|
28
|
+
for (const id of projects)
|
|
29
|
+
this.store.upsertDocument({
|
|
30
|
+
id: `project:${id}`, projectId: id, nodeType: 'project', sourceId: id, label: id,
|
|
31
|
+
confidence: 1, supportCount: this.store.countDocuments(id), status: 'active', evidenceEventIds: [],
|
|
32
|
+
metadata: { projection: 'memory_atlas.v1' },
|
|
33
|
+
});
|
|
34
|
+
actions = this.actions.rebuild(projectId);
|
|
35
|
+
if (projectId) {
|
|
36
|
+
this.store.markProjectionClean(projectId, { actions });
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
for (const id of projects)
|
|
40
|
+
this.store.markProjectionClean(id, { actions });
|
|
41
|
+
}
|
|
42
|
+
})();
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
this.store.markProjectionFailed(projectId || '__global__', error instanceof Error ? error.message : String(error));
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
return { documents: this.store.countDocuments(projectId), actions };
|
|
49
|
+
}
|
|
50
|
+
ensureFresh(options) {
|
|
51
|
+
if (!this.store.projectionNeedsRefresh(options.projectId)) {
|
|
52
|
+
return { documents: this.store.countDocuments(options.projectId), actions: 0, refreshed: false };
|
|
53
|
+
}
|
|
54
|
+
return { ...this.rebuild(options), refreshed: true };
|
|
55
|
+
}
|
|
56
|
+
ensureAllFresh() {
|
|
57
|
+
let documents = 0;
|
|
58
|
+
let actions = 0;
|
|
59
|
+
let refreshed = false;
|
|
60
|
+
const errors = [];
|
|
61
|
+
for (const projectId of this.store.listKnownProjectIds()) {
|
|
62
|
+
try {
|
|
63
|
+
const result = this.ensureFresh({ projectId });
|
|
64
|
+
documents += result.documents;
|
|
65
|
+
actions += result.actions;
|
|
66
|
+
refreshed ||= result.refreshed;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
errors.push({ projectId, error: error instanceof Error ? error.message : String(error) });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { documents, actions, refreshed, errors };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface CompiledAtlasQuery {
|
|
2
|
+
text: string;
|
|
3
|
+
tokens: string[];
|
|
4
|
+
keywords: string[];
|
|
5
|
+
target?: string;
|
|
6
|
+
actionIntent: boolean;
|
|
7
|
+
range?: {
|
|
8
|
+
from: number;
|
|
9
|
+
to: number;
|
|
10
|
+
label: string;
|
|
11
|
+
};
|
|
12
|
+
memoryKinds: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare function compileAtlasQuery(query: string, now?: number): CompiledAtlasQuery;
|
|
15
|
+
export declare function actionMarker(value: string): {
|
|
16
|
+
frameType: string;
|
|
17
|
+
action: string;
|
|
18
|
+
} | undefined;
|
|
19
|
+
export declare function actionMarkers(value: string): Array<{
|
|
20
|
+
frameType: string;
|
|
21
|
+
action: string;
|
|
22
|
+
}>;
|
|
23
|
+
//# sourceMappingURL=MemoryAtlasQueryCompiler.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const STOP_WORDS = new Set(['我', '你', '让', '对', '的', '年', '做过', '什么', '去年', '今年', 'the', 'a', 'an', 'what', 'did', 'do', 'to', 'last', 'year']);
|
|
2
|
+
const ACTION_MARKERS = /配置|连接|安装|修复|更新|升级|比较|操作|设置|调试|configure|connect|install|repair|fix|update|upgrade|compare|setup|debug/iu;
|
|
3
|
+
const MEMORY_KIND_MARKERS = [
|
|
4
|
+
[/决策|决定|decision/iu, 'decision'], [/修正|纠正|correction/iu, 'correction'],
|
|
5
|
+
[/目标|goal/iu, 'goal'], [/偏好|preference/iu, 'preference'], [/计划|plan/iu, 'plan'],
|
|
6
|
+
[/事件|经历|event/iu, 'event'], [/证据|原文|evidence/iu, 'evidence'],
|
|
7
|
+
[/人物|person/iu, 'person'], [/地点|place/iu, 'place'], [/项目|project/iu, 'project'],
|
|
8
|
+
[ACTION_MARKERS, 'action'],
|
|
9
|
+
];
|
|
10
|
+
export function compileAtlasQuery(query, now = Date.now()) {
|
|
11
|
+
const text = String(query || '').trim().slice(0, 1000);
|
|
12
|
+
const tokens = Array.from(new Set((text.match(/[\p{L}\p{N}_-]+/gu) || [])
|
|
13
|
+
.map((item) => item.trim())
|
|
14
|
+
.filter((item) => item.length > 1 && !STOP_WORDS.has(item.toLowerCase())))).slice(0, 24);
|
|
15
|
+
const explicitYear = text.match(/(?:^|\D)((?:19|20)\d{2})(?:\D|$)/u)?.[1];
|
|
16
|
+
let range;
|
|
17
|
+
if (explicitYear) {
|
|
18
|
+
const year = Number(explicitYear);
|
|
19
|
+
range = { from: Date.UTC(year, 0, 1), to: Date.UTC(year + 1, 0, 1), label: explicitYear };
|
|
20
|
+
}
|
|
21
|
+
else if (/去年|last year/iu.test(text)) {
|
|
22
|
+
const year = new Date(now).getUTCFullYear() - 1;
|
|
23
|
+
range = { from: Date.UTC(year, 0, 1), to: Date.UTC(year + 1, 0, 1), label: String(year) };
|
|
24
|
+
}
|
|
25
|
+
const target = tokens.find((token) => /^[A-Z][\p{L}\p{N}_.-]*$/u.test(token))
|
|
26
|
+
?? tokens.find((token) => !/^\d{4}$/u.test(token)
|
|
27
|
+
&& !ACTION_MARKERS.test(token)
|
|
28
|
+
&& !MEMORY_KIND_MARKERS.some(([pattern]) => pattern.test(token)));
|
|
29
|
+
const memoryKinds = MEMORY_KIND_MARKERS.filter(([pattern]) => pattern.test(text)).map(([, kind]) => kind);
|
|
30
|
+
const keywords = tokens.filter((token) => token !== target
|
|
31
|
+
&& token !== explicitYear
|
|
32
|
+
&& !ACTION_MARKERS.test(token)
|
|
33
|
+
&& !MEMORY_KIND_MARKERS.some(([pattern]) => pattern.test(token)));
|
|
34
|
+
return { text, tokens, keywords, target, actionIntent: ACTION_MARKERS.test(text), range, memoryKinds };
|
|
35
|
+
}
|
|
36
|
+
export function actionMarker(value) {
|
|
37
|
+
return actionMarkers(value)[0];
|
|
38
|
+
}
|
|
39
|
+
export function actionMarkers(value) {
|
|
40
|
+
const matches = value.match(new RegExp(ACTION_MARKERS.source, 'giu')) || [];
|
|
41
|
+
return Array.from(new Set(matches.map((match) => match.toLocaleLowerCase()))).map((action) => ({
|
|
42
|
+
frameType: frameTypeForAction(action),
|
|
43
|
+
action,
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
function frameTypeForAction(lower) {
|
|
47
|
+
const frameType = /修复|fix|repair|调试|debug/u.test(lower) ? 'repair'
|
|
48
|
+
: /安装|install/u.test(lower) ? 'install'
|
|
49
|
+
: /连接|connect/u.test(lower) ? 'connect'
|
|
50
|
+
: /更新|升级|update|upgrade/u.test(lower) ? 'update'
|
|
51
|
+
: /比较|compare/u.test(lower) ? 'compare'
|
|
52
|
+
: /配置|设置|configure|setup/u.test(lower) ? 'configuration'
|
|
53
|
+
: 'operation';
|
|
54
|
+
return frameType;
|
|
55
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { EventStore } from '../store/EventStore.js';
|
|
2
|
+
import type { MemoryAtlasStore } from '../store/MemoryAtlasStore.js';
|
|
3
|
+
import type { MemoryAtlasNodeDetail, MemoryAtlasPathResult, MemoryAtlasQueryOptions, MemoryAtlasSlice, MemoryAtlasTimelineResult } from './MemoryAtlasTypes.js';
|
|
4
|
+
export declare class MemoryAtlasService {
|
|
5
|
+
private store;
|
|
6
|
+
private eventStore;
|
|
7
|
+
constructor(store: MemoryAtlasStore, eventStore: EventStore);
|
|
8
|
+
overview(options: MemoryAtlasQueryOptions): MemoryAtlasSlice;
|
|
9
|
+
search(query: string, options: MemoryAtlasQueryOptions): MemoryAtlasSlice;
|
|
10
|
+
explore(query: string, options: MemoryAtlasQueryOptions): MemoryAtlasSlice;
|
|
11
|
+
node(nodeId: string, options: MemoryAtlasQueryOptions): MemoryAtlasNodeDetail | null;
|
|
12
|
+
neighbors(nodeId: string, options: MemoryAtlasQueryOptions & {
|
|
13
|
+
hops?: number;
|
|
14
|
+
}): MemoryAtlasSlice;
|
|
15
|
+
path(from: string, to: string, options: MemoryAtlasQueryOptions & {
|
|
16
|
+
maxHops?: number;
|
|
17
|
+
}): MemoryAtlasPathResult;
|
|
18
|
+
timeline(query: string, options: MemoryAtlasQueryOptions): MemoryAtlasTimelineResult;
|
|
19
|
+
private evidence;
|
|
20
|
+
private edgesFor;
|
|
21
|
+
private safeEdges;
|
|
22
|
+
private adjacentEdges;
|
|
23
|
+
private directEdgesToTarget;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=MemoryAtlasService.d.ts.map
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { eventTextForMemory } from '../episode/CogmemBlockStripper.js';
|
|
2
|
+
import { compileAtlasQuery } from './MemoryAtlasQueryCompiler.js';
|
|
3
|
+
export class MemoryAtlasService {
|
|
4
|
+
store;
|
|
5
|
+
eventStore;
|
|
6
|
+
constructor(store, eventStore) {
|
|
7
|
+
this.store = store;
|
|
8
|
+
this.eventStore = eventStore;
|
|
9
|
+
}
|
|
10
|
+
overview(options) {
|
|
11
|
+
const limit = boundedLimit(options.limit);
|
|
12
|
+
const nodes = this.store.listNodes(requiredProject(options.projectId), limit);
|
|
13
|
+
return slice(options.projectId, nodes, this.edgesFor(nodes, options.projectId));
|
|
14
|
+
}
|
|
15
|
+
search(query, options) {
|
|
16
|
+
const projectId = requiredProject(options.projectId);
|
|
17
|
+
const nodes = this.store.search(boundedQuery(query), projectId, boundedLimit(options.limit));
|
|
18
|
+
return slice(projectId, nodes, this.edgesFor(nodes, projectId), query);
|
|
19
|
+
}
|
|
20
|
+
explore(query, options) {
|
|
21
|
+
const projectId = requiredProject(options.projectId);
|
|
22
|
+
const limit = boundedLimit(options.limit);
|
|
23
|
+
const compiled = compileAtlasQuery(boundedQuery(query), options.now);
|
|
24
|
+
const target = this.store.resolveTargetNodeIds(projectId, compiled.text);
|
|
25
|
+
let nodes = this.store.searchFaceted(query, projectId, limit, {
|
|
26
|
+
from: compiled.range?.from, to: compiled.range?.to, memoryKinds: compiled.memoryKinds,
|
|
27
|
+
keywords: target.nodeIds.length ? compiled.keywords : compiled.tokens,
|
|
28
|
+
targetNodeIds: target.nodeIds.length ? target.nodeIds : undefined,
|
|
29
|
+
});
|
|
30
|
+
if (compiled.actionIntent) {
|
|
31
|
+
const actions = this.store.listActions(projectId, { target: compiled.target, targetEntityIds: target.entitySourceIds,
|
|
32
|
+
from: compiled.range?.from, to: compiled.range?.to, limit });
|
|
33
|
+
nodes = uniqueNodes([...actions.map((action) => this.store.getNode(action.id, projectId)).filter((node) => Boolean(node)), ...nodes]).slice(0, limit);
|
|
34
|
+
}
|
|
35
|
+
const edges = this.edgesFor(nodes, projectId);
|
|
36
|
+
const result = slice(projectId, nodes, edges, query);
|
|
37
|
+
result.facets = { time: compiled.range, target: target.labels.join(', ') || compiled.target, memoryKinds: compiled.memoryKinds, keywords: compiled.keywords };
|
|
38
|
+
const hasFacet = Boolean(compiled.range || compiled.target || compiled.memoryKinds.length || compiled.tokens.length);
|
|
39
|
+
result.coldMemoryResurrected = hasFacet && nodes.some((node) => node.activation <= 0.1);
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
node(nodeId, options) {
|
|
43
|
+
const projectId = requiredProject(options.projectId);
|
|
44
|
+
const node = this.store.getNode(boundedId(nodeId), projectId);
|
|
45
|
+
if (!node)
|
|
46
|
+
return null;
|
|
47
|
+
const evidence = this.evidence(node.id, projectId, options.evidenceLimit, options.includeEvidence);
|
|
48
|
+
const neighbors = this.safeEdges(this.store.listEdgesForNodes(projectId, [node.id], 30), projectId);
|
|
49
|
+
const evidenceTotal = this.store.evidenceTotal(node.id, projectId);
|
|
50
|
+
return { ...node, evidenceCount: evidenceTotal, evidenceTotal, evidenceReturned: evidence.length, evidence, neighbors };
|
|
51
|
+
}
|
|
52
|
+
neighbors(nodeId, options) {
|
|
53
|
+
const projectId = requiredProject(options.projectId);
|
|
54
|
+
const hops = options.hops ?? 1;
|
|
55
|
+
if (!Number.isInteger(hops) || hops < 1 || hops > 2)
|
|
56
|
+
throw new Error('hops must be between 1 and 2');
|
|
57
|
+
const limit = boundedLimit(options.limit);
|
|
58
|
+
const seen = new Set([boundedId(nodeId)]);
|
|
59
|
+
let frontier = [...seen];
|
|
60
|
+
const selectedEdges = [];
|
|
61
|
+
for (let depth = 0; depth < hops; depth += 1) {
|
|
62
|
+
const next = [];
|
|
63
|
+
const adjacentEdges = this.store.listEdgesForNodes(projectId, frontier, Math.max(60, limit * 20));
|
|
64
|
+
for (const edge of adjacentEdges)
|
|
65
|
+
if (frontier.includes(edge.source) || frontier.includes(edge.target)) {
|
|
66
|
+
selectedEdges.push(edge);
|
|
67
|
+
const other = frontier.includes(edge.source) ? edge.target : edge.source;
|
|
68
|
+
if (!seen.has(other) && seen.size < limit) {
|
|
69
|
+
seen.add(other);
|
|
70
|
+
next.push(other);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
frontier = next;
|
|
74
|
+
}
|
|
75
|
+
const nodes = Array.from(seen).map((id) => this.store.getNode(id, projectId)).filter((node) => Boolean(node)).slice(0, limit);
|
|
76
|
+
return slice(projectId, nodes, this.safeEdges(selectedEdges.filter((edge) => seen.has(edge.source) && seen.has(edge.target)).slice(0, 60), projectId));
|
|
77
|
+
}
|
|
78
|
+
path(from, to, options) {
|
|
79
|
+
const projectId = requiredProject(options.projectId);
|
|
80
|
+
const maxHops = Math.max(1, Math.min(options.maxHops ?? 6, 6));
|
|
81
|
+
const start = boundedId(from);
|
|
82
|
+
const target = boundedId(to);
|
|
83
|
+
const parents = new Map();
|
|
84
|
+
const best = new Map([[start, 0]]);
|
|
85
|
+
const queue = [{ id: start, cost: 0, hops: 0 }];
|
|
86
|
+
const expanded = new Set();
|
|
87
|
+
let found = start === target;
|
|
88
|
+
while (queue.length && expanded.size < 2000) {
|
|
89
|
+
queue.sort((left, right) => left.cost - right.cost || left.hops - right.hops);
|
|
90
|
+
const current = queue.shift();
|
|
91
|
+
if (current.cost !== best.get(current.id))
|
|
92
|
+
continue;
|
|
93
|
+
if (current.id === target) {
|
|
94
|
+
found = true;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
if (current.hops >= maxHops)
|
|
98
|
+
continue;
|
|
99
|
+
expanded.add(current.id);
|
|
100
|
+
const adjacent = uniqueEdges([
|
|
101
|
+
...this.adjacentEdges(projectId, [current.id], 4000),
|
|
102
|
+
...this.directEdgesToTarget(projectId, [current.id], target),
|
|
103
|
+
]);
|
|
104
|
+
for (const edge of adjacent) {
|
|
105
|
+
const next = edge.source === current.id ? edge.target : edge.target === current.id ? edge.source : undefined;
|
|
106
|
+
if (!next)
|
|
107
|
+
continue;
|
|
108
|
+
if (next !== target && !this.store.getNode(next, projectId))
|
|
109
|
+
continue;
|
|
110
|
+
const nextCost = current.cost + edgeTraversalCost(edge);
|
|
111
|
+
if (nextCost >= (best.get(next) ?? Number.POSITIVE_INFINITY))
|
|
112
|
+
continue;
|
|
113
|
+
best.set(next, nextCost);
|
|
114
|
+
parents.set(next, { previous: current.id, edge });
|
|
115
|
+
queue.push({ id: next, cost: nextCost, hops: current.hops + 1 });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const pathIds = [];
|
|
119
|
+
const pathEdges = [];
|
|
120
|
+
if (found) {
|
|
121
|
+
let current = target;
|
|
122
|
+
pathIds.push(current);
|
|
123
|
+
while (current !== start) {
|
|
124
|
+
const parent = parents.get(current);
|
|
125
|
+
if (!parent)
|
|
126
|
+
break;
|
|
127
|
+
pathEdges.push(parent.edge);
|
|
128
|
+
current = parent.previous;
|
|
129
|
+
pathIds.push(current);
|
|
130
|
+
}
|
|
131
|
+
pathIds.reverse();
|
|
132
|
+
pathEdges.reverse();
|
|
133
|
+
}
|
|
134
|
+
const path = found ? pathIds.map((id) => this.store.getNode(id, projectId)).filter((node) => Boolean(node)) : [];
|
|
135
|
+
return { version: 'memory_atlas.v1', projectId, from: start, to: target, path,
|
|
136
|
+
edges: found ? this.safeEdges(pathEdges, projectId) : [], truncated: expanded.size >= 2000 };
|
|
137
|
+
}
|
|
138
|
+
timeline(query, options) {
|
|
139
|
+
const projectId = requiredProject(options.projectId);
|
|
140
|
+
const compiled = compileAtlasQuery(boundedQuery(query), options.now);
|
|
141
|
+
const limit = boundedLimit(options.limit);
|
|
142
|
+
const target = this.store.resolveTargetNodeIds(projectId, compiled.text);
|
|
143
|
+
const nodes = this.store.searchFaceted(query, projectId, limit, {
|
|
144
|
+
from: compiled.range?.from, to: compiled.range?.to, memoryKinds: compiled.memoryKinds,
|
|
145
|
+
keywords: target.nodeIds.length ? compiled.keywords : compiled.tokens,
|
|
146
|
+
targetNodeIds: target.nodeIds.length ? target.nodeIds : undefined,
|
|
147
|
+
}).sort((left, right) => Number(right.occurredAt || 0) - Number(left.occurredAt || 0)).map((node) => {
|
|
148
|
+
const evidence = this.evidence(node.id, projectId, options.evidenceLimit, options.includeEvidence);
|
|
149
|
+
const evidenceTotal = this.store.evidenceTotal(node.id, projectId);
|
|
150
|
+
return { ...node, evidenceCount: evidenceTotal, evidenceTotal, evidenceReturned: evidence.length, evidence, neighbors: [] };
|
|
151
|
+
});
|
|
152
|
+
const actions = this.store.listActions(projectId, { target: compiled.target, targetEntityIds: target.entitySourceIds,
|
|
153
|
+
from: compiled.range?.from, to: compiled.range?.to, limit: boundedLimit(options.limit) })
|
|
154
|
+
.map((action) => ({ ...action, evidence: this.evidence(action.id, projectId, options.evidenceLimit, options.includeEvidence) }));
|
|
155
|
+
return { version: 'memory_atlas.v1', projectId, query, range: compiled.range,
|
|
156
|
+
temporalResurrection: Boolean(compiled.range && [...nodes, ...actions].length), nodes, actions, warnings: [] };
|
|
157
|
+
}
|
|
158
|
+
evidence(nodeId, projectId, requested, includeExcerpt) {
|
|
159
|
+
const limit = Math.max(1, Math.min(requested ?? 2, 10));
|
|
160
|
+
return this.store.evidenceIds(nodeId, projectId, limit).flatMap((eventId) => {
|
|
161
|
+
const event = this.eventStore.getEvent(eventId);
|
|
162
|
+
if (!event || event.projectId !== projectId)
|
|
163
|
+
return [];
|
|
164
|
+
return [{ eventId, drilldown: `cogmem memory show --event ${eventId} --project ${projectId} --json`,
|
|
165
|
+
excerpt: includeExcerpt ? eventTextForMemory(event).slice(0, 500) : undefined }];
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
edgesFor(nodes, projectId) {
|
|
169
|
+
const ids = new Set(nodes.map((node) => node.id));
|
|
170
|
+
return this.safeEdges(this.store.listEdgesForNodes(projectId, [...ids], 60)
|
|
171
|
+
.filter((edge) => ids.has(edge.source) && ids.has(edge.target)).slice(0, 60), projectId);
|
|
172
|
+
}
|
|
173
|
+
safeEdges(edges, projectId) {
|
|
174
|
+
return edges.map((edge) => ({ ...edge, evidenceEventIds: edge.evidenceEventIds.filter((eventId) => {
|
|
175
|
+
const event = this.eventStore.getEvent(eventId);
|
|
176
|
+
return Boolean(event && event.projectId === projectId);
|
|
177
|
+
}) }));
|
|
178
|
+
}
|
|
179
|
+
adjacentEdges(projectId, nodeIds, limit) {
|
|
180
|
+
const chunks = chunked(nodeIds, 30);
|
|
181
|
+
const perChunk = Math.max(60, Math.ceil(limit / Math.max(1, chunks.length)));
|
|
182
|
+
const edges = chunks.flatMap((chunk) => this.store.listEdgesForNodes(projectId, chunk, perChunk));
|
|
183
|
+
return uniqueEdges(edges).slice(0, limit);
|
|
184
|
+
}
|
|
185
|
+
directEdgesToTarget(projectId, nodeIds, target) {
|
|
186
|
+
return uniqueEdges(chunked(nodeIds, 30)
|
|
187
|
+
.flatMap((chunk) => this.store.findEdgesFromNodesToTarget(projectId, chunk, target)));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function requiredProject(value) { if (!value?.trim())
|
|
191
|
+
throw new Error('projectId is required for Memory Atlas queries'); return value.trim(); }
|
|
192
|
+
function boundedLimit(value) { if (value !== undefined && (!Number.isFinite(value) || value < 1))
|
|
193
|
+
throw new Error('limit must be a positive number'); return Math.min(Math.floor(value ?? 8), 30); }
|
|
194
|
+
function boundedQuery(value) { const query = String(value || '').trim(); if (!query)
|
|
195
|
+
throw new Error('query is required'); if (query.length > 1000)
|
|
196
|
+
throw new Error('query exceeds 1000 characters'); return query; }
|
|
197
|
+
function boundedId(value) { const id = String(value || '').trim(); if (!id || id.length > 500)
|
|
198
|
+
throw new Error('invalid node id'); return id; }
|
|
199
|
+
function uniqueNodes(nodes) { return Array.from(new Map(nodes.map((node) => [node.id, node])).values()); }
|
|
200
|
+
function uniqueIds(ids) { return Array.from(new Set(ids)); }
|
|
201
|
+
function uniqueEdges(edges) {
|
|
202
|
+
return Array.from(new Map(edges.map((edge) => [`${edge.source}\0${edge.relation}\0${edge.target}`, edge])).values());
|
|
203
|
+
}
|
|
204
|
+
function edgeTraversalCost(edge) {
|
|
205
|
+
const confidence = Math.max(0.01, Math.min(1, edge.confidence));
|
|
206
|
+
const relationPenalty = /^(EVIDENCED_BY|DERIVED_FROM|TARGETS|OCCURRED_IN|SUPPORTS|ABOUT|MENTIONS)$/u.test(edge.relation)
|
|
207
|
+
? 0 : /^(CONTRADICTS|CORRECTS)$/u.test(edge.relation) ? 0.2 : 0.1;
|
|
208
|
+
return -Math.log(confidence) + 0.12 + relationPenalty;
|
|
209
|
+
}
|
|
210
|
+
function chunked(values, size) {
|
|
211
|
+
const chunks = [];
|
|
212
|
+
for (let index = 0; index < values.length; index += size)
|
|
213
|
+
chunks.push(values.slice(index, index + size));
|
|
214
|
+
return chunks;
|
|
215
|
+
}
|
|
216
|
+
function slice(projectId, nodes, edges, query) { return { version: 'memory_atlas.v1', projectId, query, nodes, edges, nextActions: nodes.slice(0, 5).map((node) => ({ label: `Inspect ${node.label}`, tool: 'cogmem_graph_node', args: { id: node.id, projectId } })), warnings: [] }; }
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export type MemoryAtlasNodeType = 'project' | 'topic' | 'entity' | 'cluster' | 'episode' | 'belief' | 'action' | 'time' | 'event';
|
|
2
|
+
export interface MemoryAtlasEvidence {
|
|
3
|
+
eventId: string;
|
|
4
|
+
drilldown: string;
|
|
5
|
+
excerpt?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface MemoryAtlasNode {
|
|
8
|
+
id: string;
|
|
9
|
+
projectId: string;
|
|
10
|
+
nodeType: MemoryAtlasNodeType;
|
|
11
|
+
memoryKind?: string;
|
|
12
|
+
sourceId: string;
|
|
13
|
+
label: string;
|
|
14
|
+
summary?: string;
|
|
15
|
+
topicPath?: string;
|
|
16
|
+
confidence: number;
|
|
17
|
+
supportCount: number;
|
|
18
|
+
status: string;
|
|
19
|
+
occurredAt?: number;
|
|
20
|
+
activation: number;
|
|
21
|
+
score: number;
|
|
22
|
+
evidenceCount: number;
|
|
23
|
+
/** Total source evidence known for this node. */
|
|
24
|
+
evidenceTotal: number;
|
|
25
|
+
/** Number of evidence records returned in this response. */
|
|
26
|
+
evidenceReturned?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface MemoryAtlasEdge {
|
|
29
|
+
source: string;
|
|
30
|
+
relation: string;
|
|
31
|
+
target: string;
|
|
32
|
+
confidence: number;
|
|
33
|
+
evidenceEventIds: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface MemoryAtlasNextAction {
|
|
36
|
+
label: string;
|
|
37
|
+
tool: string;
|
|
38
|
+
args: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
export interface MemoryAtlasSlice {
|
|
41
|
+
version: 'memory_atlas.v1';
|
|
42
|
+
projectId: string;
|
|
43
|
+
query?: string;
|
|
44
|
+
nodes: MemoryAtlasNode[];
|
|
45
|
+
edges: MemoryAtlasEdge[];
|
|
46
|
+
nextActions: MemoryAtlasNextAction[];
|
|
47
|
+
warnings: string[];
|
|
48
|
+
facets?: {
|
|
49
|
+
time?: {
|
|
50
|
+
from: number;
|
|
51
|
+
to: number;
|
|
52
|
+
label: string;
|
|
53
|
+
};
|
|
54
|
+
target?: string;
|
|
55
|
+
memoryKinds: string[];
|
|
56
|
+
keywords: string[];
|
|
57
|
+
};
|
|
58
|
+
coldMemoryResurrected?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface MemoryAtlasNodeDetail extends MemoryAtlasNode {
|
|
61
|
+
evidence: MemoryAtlasEvidence[];
|
|
62
|
+
neighbors: MemoryAtlasEdge[];
|
|
63
|
+
}
|
|
64
|
+
export interface MemoryAtlasAction {
|
|
65
|
+
id: string;
|
|
66
|
+
frameType: string;
|
|
67
|
+
action: string;
|
|
68
|
+
targetLabel?: string;
|
|
69
|
+
topicPath?: string;
|
|
70
|
+
episodeId?: string;
|
|
71
|
+
occurredAt: number;
|
|
72
|
+
confidence: number;
|
|
73
|
+
evidence: MemoryAtlasEvidence[];
|
|
74
|
+
}
|
|
75
|
+
export interface MemoryAtlasTimelineResult {
|
|
76
|
+
version: 'memory_atlas.v1';
|
|
77
|
+
projectId: string;
|
|
78
|
+
query: string;
|
|
79
|
+
range?: {
|
|
80
|
+
from: number;
|
|
81
|
+
to: number;
|
|
82
|
+
label: string;
|
|
83
|
+
};
|
|
84
|
+
temporalResurrection: boolean;
|
|
85
|
+
nodes: MemoryAtlasNodeDetail[];
|
|
86
|
+
actions: MemoryAtlasAction[];
|
|
87
|
+
warnings: string[];
|
|
88
|
+
}
|
|
89
|
+
export interface MemoryAtlasPathResult {
|
|
90
|
+
version: 'memory_atlas.v1';
|
|
91
|
+
projectId: string;
|
|
92
|
+
from: string;
|
|
93
|
+
to: string;
|
|
94
|
+
path: MemoryAtlasNode[];
|
|
95
|
+
edges: MemoryAtlasEdge[];
|
|
96
|
+
truncated: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface MemoryAtlasQueryOptions {
|
|
99
|
+
projectId: string;
|
|
100
|
+
limit?: number;
|
|
101
|
+
includeEvidence?: boolean;
|
|
102
|
+
evidenceLimit?: number;
|
|
103
|
+
now?: number;
|
|
104
|
+
refresh?: boolean;
|
|
105
|
+
staleOk?: boolean;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=MemoryAtlasTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type SemanticBackendMode = 'deterministic_local' | 'rule_only' | 'model_backed' | 'hybrid';
|
|
2
|
+
export type SemanticBackendProviderId = 'deterministic-local' | 'rule-only' | 'gemma4-e4b-local' | 'hybrid-rule-plus-gemma4-e4b';
|
|
3
|
+
export type SemanticBackendTask = 'offline_deep_consolidation' | 'async_low_confidence_enrichment' | 'optional_semantic_task';
|
|
4
|
+
export interface SemanticBackendConfig {
|
|
5
|
+
mode: SemanticBackendMode;
|
|
6
|
+
providerId: SemanticBackendProviderId;
|
|
7
|
+
modelPath?: string;
|
|
8
|
+
readinessFile: string;
|
|
9
|
+
requireReady: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface SemanticBackendStatus {
|
|
12
|
+
mode: SemanticBackendMode;
|
|
13
|
+
providerId: SemanticBackendProviderId;
|
|
14
|
+
ready: boolean;
|
|
15
|
+
requiresExplicitSetup: boolean;
|
|
16
|
+
modelPath?: string;
|
|
17
|
+
readinessFile: string;
|
|
18
|
+
eligibleTasks: SemanticBackendTask[];
|
|
19
|
+
failureBehavior: 'no_effect' | 'rule_only_fallback' | 'explicit_failure';
|
|
20
|
+
fallbackBackend: 'rule_only' | null;
|
|
21
|
+
reason: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SemanticBackendInvocation {
|
|
24
|
+
task: SemanticBackendTask;
|
|
25
|
+
selectedBackend: SemanticBackendProviderId | 'rule-only-fallback';
|
|
26
|
+
fallbackUsed: boolean;
|
|
27
|
+
ready: boolean;
|
|
28
|
+
reason: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function resolveSemanticBackendConfig(): SemanticBackendConfig;
|
|
31
|
+
export declare class SemanticBackendRuntime {
|
|
32
|
+
private readonly config;
|
|
33
|
+
constructor(config?: SemanticBackendConfig);
|
|
34
|
+
getStatus(): SemanticBackendStatus;
|
|
35
|
+
warmup(): SemanticBackendStatus;
|
|
36
|
+
prepare(task: SemanticBackendTask): SemanticBackendInvocation;
|
|
37
|
+
private isReady;
|
|
38
|
+
private explainNotReady;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=SemanticBackend.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { existsSync, mkdirSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
const DEFAULT_CACHE_ROOT = resolve(`${process.env.HOME || '/tmp'}/.cache/cogmem`);
|
|
5
|
+
const DEFAULT_READY_FILE = join(DEFAULT_CACHE_ROOT, 'semantic-backends', 'gemma4-e4b-ready.json');
|
|
6
|
+
export function resolveSemanticBackendConfig() {
|
|
7
|
+
return {
|
|
8
|
+
mode: 'rule_only',
|
|
9
|
+
providerId: 'rule-only',
|
|
10
|
+
readinessFile: DEFAULT_READY_FILE,
|
|
11
|
+
requireReady: false
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export class SemanticBackendRuntime {
|
|
15
|
+
config;
|
|
16
|
+
constructor(config = resolveSemanticBackendConfig()) {
|
|
17
|
+
this.config = config;
|
|
18
|
+
}
|
|
19
|
+
getStatus() {
|
|
20
|
+
const ready = this.isReady();
|
|
21
|
+
const eligibleTasks = this.config.mode === 'rule_only' || this.config.mode === 'deterministic_local'
|
|
22
|
+
? []
|
|
23
|
+
: ['offline_deep_consolidation', 'async_low_confidence_enrichment', 'optional_semantic_task'];
|
|
24
|
+
const failureBehavior = this.config.mode === 'model_backed'
|
|
25
|
+
? (this.config.requireReady ? 'explicit_failure' : 'rule_only_fallback')
|
|
26
|
+
: this.config.mode === 'hybrid'
|
|
27
|
+
? 'rule_only_fallback'
|
|
28
|
+
: 'no_effect';
|
|
29
|
+
return {
|
|
30
|
+
mode: this.config.mode,
|
|
31
|
+
providerId: this.config.providerId,
|
|
32
|
+
ready,
|
|
33
|
+
requiresExplicitSetup: this.config.mode === 'model_backed' || this.config.mode === 'hybrid',
|
|
34
|
+
modelPath: this.config.modelPath,
|
|
35
|
+
readinessFile: this.config.readinessFile,
|
|
36
|
+
eligibleTasks,
|
|
37
|
+
failureBehavior,
|
|
38
|
+
fallbackBackend: failureBehavior === 'rule_only_fallback' ? 'rule_only' : null,
|
|
39
|
+
reason: ready ? 'ready' : this.explainNotReady()
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
warmup() {
|
|
43
|
+
const status = this.getStatus();
|
|
44
|
+
if (!status.requiresExplicitSetup)
|
|
45
|
+
return status;
|
|
46
|
+
if (!this.config.modelPath || !existsSync(this.config.modelPath))
|
|
47
|
+
return status;
|
|
48
|
+
if (!statSync(this.config.modelPath).isDirectory())
|
|
49
|
+
return status;
|
|
50
|
+
mkdirSync(dirname(this.config.readinessFile), { recursive: true });
|
|
51
|
+
writeFileSync(this.config.readinessFile, JSON.stringify({
|
|
52
|
+
providerId: this.config.providerId,
|
|
53
|
+
modelPath: this.config.modelPath,
|
|
54
|
+
warmedAt: new Date().toISOString()
|
|
55
|
+
}, null, 2));
|
|
56
|
+
return this.getStatus();
|
|
57
|
+
}
|
|
58
|
+
prepare(task) {
|
|
59
|
+
const status = this.getStatus();
|
|
60
|
+
if (status.mode === 'rule_only' || status.mode === 'deterministic_local') {
|
|
61
|
+
return {
|
|
62
|
+
task,
|
|
63
|
+
selectedBackend: status.providerId,
|
|
64
|
+
fallbackUsed: false,
|
|
65
|
+
ready: true,
|
|
66
|
+
reason: 'default_no_download_backend'
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (status.ready) {
|
|
70
|
+
return {
|
|
71
|
+
task,
|
|
72
|
+
selectedBackend: status.providerId,
|
|
73
|
+
fallbackUsed: false,
|
|
74
|
+
ready: true,
|
|
75
|
+
reason: 'explicit_model_backend_ready'
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (status.failureBehavior === 'explicit_failure') {
|
|
79
|
+
throw new Error(`Semantic backend ${status.providerId} is not ready: ${status.reason}`);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
task,
|
|
83
|
+
selectedBackend: 'rule-only-fallback',
|
|
84
|
+
fallbackUsed: true,
|
|
85
|
+
ready: false,
|
|
86
|
+
reason: status.reason
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
isReady() {
|
|
90
|
+
if (this.config.mode === 'rule_only' || this.config.mode === 'deterministic_local')
|
|
91
|
+
return true;
|
|
92
|
+
if (!this.config.modelPath || !existsSync(this.config.modelPath))
|
|
93
|
+
return false;
|
|
94
|
+
return existsSync(this.config.readinessFile);
|
|
95
|
+
}
|
|
96
|
+
explainNotReady() {
|
|
97
|
+
if (this.config.mode === 'rule_only' || this.config.mode === 'deterministic_local')
|
|
98
|
+
return 'no_model_required';
|
|
99
|
+
if (!this.config.modelPath)
|
|
100
|
+
return 'missing_model_path';
|
|
101
|
+
if (!existsSync(this.config.modelPath))
|
|
102
|
+
return 'missing_local_model';
|
|
103
|
+
if (!existsSync(this.config.readinessFile))
|
|
104
|
+
return 'setup_not_run';
|
|
105
|
+
return 'not_ready';
|
|
106
|
+
}
|
|
107
|
+
}
|