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,376 @@
|
|
|
1
|
+
import { aaakGenerator } from '../utils/AAAKGenerator.js';
|
|
2
|
+
import { BeliefExtractor } from './BeliefExtractor.js';
|
|
3
|
+
import { MemoryGate } from './MemoryGate.js';
|
|
4
|
+
import { OfflineConsolidationPipeline } from './OfflineConsolidationPipeline.js';
|
|
5
|
+
import { createAsyncEnrichmentRunId, NoopAsyncEnrichmentHook } from '../types/AsyncEnrichment.js';
|
|
6
|
+
/**
|
|
7
|
+
* Online lightweight compilation pipeline.
|
|
8
|
+
* Responsibilities stay intentionally narrow:
|
|
9
|
+
* - raw episodes are already durably written before this stage runs
|
|
10
|
+
* - apply the minimal gate and binder needed for the current session
|
|
11
|
+
* - emit provisional facts / events / entity hints for near-term recall
|
|
12
|
+
* - leave deep semantic reconciliation to the offline consolidation layer
|
|
13
|
+
*/
|
|
14
|
+
export class ConsolidationPipeline {
|
|
15
|
+
beliefStore;
|
|
16
|
+
interactionBinder;
|
|
17
|
+
factCompiler;
|
|
18
|
+
semanticCompiler;
|
|
19
|
+
factStore;
|
|
20
|
+
entityStore;
|
|
21
|
+
compilerConfidenceStore;
|
|
22
|
+
beliefExtractor;
|
|
23
|
+
memoryGate;
|
|
24
|
+
asyncEnrichmentHook;
|
|
25
|
+
asyncEnrichmentEnabled;
|
|
26
|
+
lowConfidenceThreshold;
|
|
27
|
+
offlineConsolidationPipeline;
|
|
28
|
+
constructor(beliefStore, interactionBinder, factCompiler, semanticCompiler, factStore, entityStore, compilerConfidenceStore, beliefExtractor, offlineConsolidationPipeline = new OfflineConsolidationPipeline(), asyncEnrichmentHook = new NoopAsyncEnrichmentHook(), options = {}) {
|
|
29
|
+
this.beliefStore = beliefStore;
|
|
30
|
+
this.interactionBinder = interactionBinder;
|
|
31
|
+
this.factCompiler = factCompiler;
|
|
32
|
+
this.semanticCompiler = semanticCompiler;
|
|
33
|
+
this.factStore = factStore;
|
|
34
|
+
this.entityStore = entityStore;
|
|
35
|
+
this.compilerConfidenceStore = compilerConfidenceStore;
|
|
36
|
+
this.beliefExtractor = beliefExtractor || new BeliefExtractor();
|
|
37
|
+
this.memoryGate = new MemoryGate();
|
|
38
|
+
this.offlineConsolidationPipeline = offlineConsolidationPipeline;
|
|
39
|
+
this.asyncEnrichmentHook = asyncEnrichmentHook;
|
|
40
|
+
this.asyncEnrichmentEnabled = options.enabled === true;
|
|
41
|
+
this.lowConfidenceThreshold = options.lowConfidenceThreshold ?? 0.72;
|
|
42
|
+
}
|
|
43
|
+
consolidate(neuron, sourceEventId) {
|
|
44
|
+
const aaakSummary = this.ensureAAAKSummary(neuron);
|
|
45
|
+
const gate = this.memoryGate.classify(neuron.content);
|
|
46
|
+
const binding = this.interactionBinder.process(neuron);
|
|
47
|
+
const interactionUnit = binding.unit;
|
|
48
|
+
const tags = neuron.metadata.tags || [];
|
|
49
|
+
const isProfileOnlyImport = tags.includes('ingest:profile_only');
|
|
50
|
+
if (isProfileOnlyImport) {
|
|
51
|
+
return {
|
|
52
|
+
gate,
|
|
53
|
+
binding,
|
|
54
|
+
interactionUnit,
|
|
55
|
+
aaakSummary,
|
|
56
|
+
semanticCompilation: undefined,
|
|
57
|
+
candidates: [],
|
|
58
|
+
beliefs: [],
|
|
59
|
+
compiledFacts: [],
|
|
60
|
+
compiledEvents: [],
|
|
61
|
+
compiledEntityIds: [],
|
|
62
|
+
rejectedCount: 0
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const semanticCompilation = this.semanticCompiler.compileMemory({
|
|
66
|
+
text: interactionUnit?.semanticText || neuron.content,
|
|
67
|
+
projectId: neuron.metadata.projectId,
|
|
68
|
+
type: neuron.metadata.type,
|
|
69
|
+
createdAt: neuron.metadata.createdAt
|
|
70
|
+
});
|
|
71
|
+
this.compilerConfidenceStore?.insert({
|
|
72
|
+
runId: semanticCompilation.runId,
|
|
73
|
+
targetType: 'memory',
|
|
74
|
+
targetId: neuron.id,
|
|
75
|
+
projectId: neuron.metadata.projectId,
|
|
76
|
+
compilerName: 'LocalSemanticCompiler',
|
|
77
|
+
confidence: semanticCompilation.confidence,
|
|
78
|
+
metadata: {
|
|
79
|
+
tags: semanticCompilation.tags,
|
|
80
|
+
entities: semanticCompilation.entities.map((entity) => entity.text),
|
|
81
|
+
topics: semanticCompilation.topics.map((topic) => topic.topic),
|
|
82
|
+
issueHints: semanticCompilation.issueHints,
|
|
83
|
+
ownershipSignals: semanticCompilation.ownershipSignals,
|
|
84
|
+
relativeReferences: semanticCompilation.relativeReferences,
|
|
85
|
+
projectLinks: semanticCompilation.projectLinks
|
|
86
|
+
},
|
|
87
|
+
createdAt: neuron.metadata.createdAt
|
|
88
|
+
});
|
|
89
|
+
if (gate.memoryClass === 'drop') {
|
|
90
|
+
return {
|
|
91
|
+
gate,
|
|
92
|
+
binding,
|
|
93
|
+
interactionUnit,
|
|
94
|
+
aaakSummary,
|
|
95
|
+
semanticCompilation,
|
|
96
|
+
candidates: [],
|
|
97
|
+
beliefs: [],
|
|
98
|
+
compiledFacts: [],
|
|
99
|
+
compiledEvents: [],
|
|
100
|
+
compiledEntityIds: [],
|
|
101
|
+
rejectedCount: 0
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const compiled = this.factCompiler.compile({
|
|
105
|
+
neuron,
|
|
106
|
+
unit: interactionUnit,
|
|
107
|
+
semanticCompilation
|
|
108
|
+
});
|
|
109
|
+
if (gate.memoryClass === 'bind_first' && !binding.bound) {
|
|
110
|
+
return {
|
|
111
|
+
gate,
|
|
112
|
+
binding,
|
|
113
|
+
interactionUnit,
|
|
114
|
+
aaakSummary,
|
|
115
|
+
semanticCompilation,
|
|
116
|
+
candidates: [],
|
|
117
|
+
beliefs: [],
|
|
118
|
+
compiledFacts: compiled.facts,
|
|
119
|
+
compiledEvents: compiled.events,
|
|
120
|
+
compiledEntityIds: compiled.entityIds,
|
|
121
|
+
rejectedCount: 0
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const candidates = gate.memoryClass === 'short_term'
|
|
125
|
+
? []
|
|
126
|
+
: this.extractBeliefCandidates(neuron, sourceEventId);
|
|
127
|
+
const beliefs = [];
|
|
128
|
+
let rejectedCount = 0;
|
|
129
|
+
for (const candidate of candidates) {
|
|
130
|
+
const result = this.beliefStore.upsert(candidate, neuron.metadata.createdAt);
|
|
131
|
+
if (result.belief)
|
|
132
|
+
beliefs.push(result.belief);
|
|
133
|
+
else
|
|
134
|
+
rejectedCount += 1;
|
|
135
|
+
}
|
|
136
|
+
const result = {
|
|
137
|
+
gate,
|
|
138
|
+
binding,
|
|
139
|
+
interactionUnit,
|
|
140
|
+
aaakSummary,
|
|
141
|
+
semanticCompilation,
|
|
142
|
+
candidates,
|
|
143
|
+
beliefs,
|
|
144
|
+
compiledFacts: compiled.facts,
|
|
145
|
+
compiledEvents: compiled.events,
|
|
146
|
+
compiledEntityIds: compiled.entityIds,
|
|
147
|
+
rejectedCount
|
|
148
|
+
};
|
|
149
|
+
this.dispatchAsyncEnrichment(neuron, sourceEventId, result);
|
|
150
|
+
this.scheduleOfflineConsolidation(neuron, result);
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
ensureAAAKSummary(neuron) {
|
|
154
|
+
if (neuron.metadata.aaak_summary)
|
|
155
|
+
return neuron.metadata.aaak_summary;
|
|
156
|
+
const importance = this.calculateImportance(neuron.content);
|
|
157
|
+
const summary = aaakGenerator.generateSummarySync(neuron.content, neuron.metadata.type, importance);
|
|
158
|
+
neuron.metadata.aaak_summary = summary;
|
|
159
|
+
return summary;
|
|
160
|
+
}
|
|
161
|
+
extractBeliefCandidates(neuron, sourceEventId) {
|
|
162
|
+
return this.beliefExtractor.extract({ neuron, sourceEventId });
|
|
163
|
+
}
|
|
164
|
+
calculateImportance(content) {
|
|
165
|
+
const len = content.length;
|
|
166
|
+
if (len < 50)
|
|
167
|
+
return 1;
|
|
168
|
+
if (len < 100)
|
|
169
|
+
return 2;
|
|
170
|
+
if (len < 200)
|
|
171
|
+
return 3;
|
|
172
|
+
if (len < 500)
|
|
173
|
+
return 4;
|
|
174
|
+
return 5;
|
|
175
|
+
}
|
|
176
|
+
dispatchAsyncEnrichment(neuron, sourceEventId, consolidation) {
|
|
177
|
+
if (!this.asyncEnrichmentEnabled)
|
|
178
|
+
return;
|
|
179
|
+
const triggers = this.collectAsyncEnrichmentTriggers(consolidation);
|
|
180
|
+
if (triggers.length === 0)
|
|
181
|
+
return;
|
|
182
|
+
const runId = createAsyncEnrichmentRunId();
|
|
183
|
+
queueMicrotask(() => {
|
|
184
|
+
Promise.resolve(this.asyncEnrichmentHook.enrich({
|
|
185
|
+
runId,
|
|
186
|
+
neuron,
|
|
187
|
+
sourceEventId,
|
|
188
|
+
triggers,
|
|
189
|
+
consolidation,
|
|
190
|
+
compilerOutput: {
|
|
191
|
+
facts: consolidation.compiledFacts,
|
|
192
|
+
events: consolidation.compiledEvents,
|
|
193
|
+
entityIds: consolidation.compiledEntityIds
|
|
194
|
+
},
|
|
195
|
+
entityBinding: this.buildAsyncEnrichmentEntityBinding(neuron, consolidation),
|
|
196
|
+
recentContext: this.buildAsyncEnrichmentContext(neuron, consolidation)
|
|
197
|
+
}, {
|
|
198
|
+
persist: (result) => this.persistAsyncEnrichmentResult(runId, neuron, sourceEventId, result)
|
|
199
|
+
}))
|
|
200
|
+
.then((result) => {
|
|
201
|
+
if (result)
|
|
202
|
+
this.persistAsyncEnrichmentResult(runId, neuron, sourceEventId, result);
|
|
203
|
+
})
|
|
204
|
+
.catch(() => undefined);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
scheduleOfflineConsolidation(neuron, consolidation) {
|
|
208
|
+
const pendingReferenceIds = consolidation.compiledFacts
|
|
209
|
+
.filter((fact) => fact.status === 'provisional' && !fact.entityId)
|
|
210
|
+
.map((fact) => fact.factId);
|
|
211
|
+
const reasons = [
|
|
212
|
+
...(pendingReferenceIds.length > 0 ? ['pending_reference_or_entity_binding'] : []),
|
|
213
|
+
...(this.collectAsyncEnrichmentTriggers(consolidation).map((trigger) => trigger.kind)),
|
|
214
|
+
...((consolidation.semanticCompilation?.issueHints.length || 0) > 1 ? ['multi_issue_candidate_sentence'] : []),
|
|
215
|
+
...((consolidation.binding.bound || consolidation.binding.pendingRegistered) ? ['interaction_binding_present'] : [])
|
|
216
|
+
];
|
|
217
|
+
queueMicrotask(() => {
|
|
218
|
+
this.offlineConsolidationPipeline.schedule({
|
|
219
|
+
neuron,
|
|
220
|
+
interactionUnit: consolidation.interactionUnit,
|
|
221
|
+
provisionalFacts: consolidation.compiledFacts,
|
|
222
|
+
provisionalEvents: consolidation.compiledEvents,
|
|
223
|
+
provisionalEntityIds: consolidation.compiledEntityIds,
|
|
224
|
+
beliefIds: consolidation.beliefs.map((belief) => belief.id),
|
|
225
|
+
pendingReferenceIds,
|
|
226
|
+
reasons: Array.from(new Set(reasons))
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
collectAsyncEnrichmentTriggers(consolidation) {
|
|
231
|
+
const triggers = [];
|
|
232
|
+
if (consolidation.compiledFacts.length === 0) {
|
|
233
|
+
triggers.push({
|
|
234
|
+
kind: 'ingest_compiled_fact_count_zero',
|
|
235
|
+
detail: 'ingest_compiled_fact_count=0'
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
if (this.hasSelfCorrectionPattern(consolidation)) {
|
|
239
|
+
triggers.push({
|
|
240
|
+
kind: 'self_correction_pattern',
|
|
241
|
+
detail: consolidation.interactionUnit?.semanticText || consolidation.aaakSummary || 'self_correction_pattern'
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
if ((consolidation.semanticCompilation?.issueHints.length || 0) > 1 && consolidation.compiledFacts.length <= 1) {
|
|
245
|
+
triggers.push({
|
|
246
|
+
kind: 'multi_candidate_single_fact',
|
|
247
|
+
detail: `${consolidation.semanticCompilation?.issueHints.length || 0}_issue_candidates_vs_${consolidation.compiledFacts.length}_compiled_facts`
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
if (this.hasSuspiciousUnseenEntityBinding(consolidation)) {
|
|
251
|
+
triggers.push({
|
|
252
|
+
kind: 'unseen_entity_binding_suspect',
|
|
253
|
+
detail: 'explicit_unseen_name_bound_to_existing_entity'
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
if ((consolidation.semanticCompilation?.confidence || 1) < this.lowConfidenceThreshold) {
|
|
257
|
+
triggers.push({
|
|
258
|
+
kind: 'low_compiler_confidence',
|
|
259
|
+
detail: `compiler_confidence=${(consolidation.semanticCompilation?.confidence || 0).toFixed(3)}`
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return triggers;
|
|
263
|
+
}
|
|
264
|
+
buildAsyncEnrichmentEntityBinding(neuron, consolidation) {
|
|
265
|
+
const compiledEntities = consolidation.compiledEntityIds
|
|
266
|
+
.map((entityId) => this.entityStore.findByEntityId(entityId))
|
|
267
|
+
.filter((entity) => Boolean(entity));
|
|
268
|
+
const suspiciousReasons = [];
|
|
269
|
+
if (compiledEntities.length > 0) {
|
|
270
|
+
const explicitEntityHints = consolidation.semanticCompilation?.entities.map((entity) => entity.text) || [];
|
|
271
|
+
if (explicitEntityHints.some((hint) => !compiledEntities.some((entity) => entity.canonicalName.includes(hint) || hint.includes(entity.canonicalName)))) {
|
|
272
|
+
suspiciousReasons.push('semantic_entity_hint_mismatch');
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const explicitNamedDevice = neuron.content.match(/([A-Za-z][A-Za-z0-9._-]*(?:\s+[A-Za-z0-9._-]+){1,3})/);
|
|
276
|
+
const candidate = explicitNamedDevice?.[1];
|
|
277
|
+
if (candidate && compiledEntities.length > 0 && compiledEntities.every((entity) => !entity.canonicalName.toLowerCase().includes(candidate.toLowerCase()))) {
|
|
278
|
+
suspiciousReasons.push('explicit_unseen_name_mismatch');
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
compiledEntityIds: consolidation.compiledEntityIds,
|
|
282
|
+
compiledEntities,
|
|
283
|
+
suspicious: suspiciousReasons.length > 0,
|
|
284
|
+
reasons: suspiciousReasons
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
buildAsyncEnrichmentContext(neuron, consolidation) {
|
|
288
|
+
const recentEntities = Array.from(new Map([
|
|
289
|
+
...consolidation.compiledEntityIds.map((entityId) => this.entityStore.findByEntityId(entityId)),
|
|
290
|
+
...this.entityStore.getEntityTimeline({
|
|
291
|
+
projectId: neuron.metadata.projectId,
|
|
292
|
+
limit: 8
|
|
293
|
+
}).map((item) => this.entityStore.findByEntityId(item.entityId))
|
|
294
|
+
]
|
|
295
|
+
.filter((entity) => Boolean(entity))
|
|
296
|
+
.map((entity) => [entity.entityId, entity])).values()).slice(0, 6);
|
|
297
|
+
const recentFacts = this.factStore.listFactsByEntityIds(recentEntities.map((entity) => entity.entityId), { limit: 12 });
|
|
298
|
+
const recentPreferenceFacts = recentFacts.filter((fact) => fact.predicateFamily === 'likes' || fact.predicateFamily === 'dislikes');
|
|
299
|
+
return {
|
|
300
|
+
recentEntities,
|
|
301
|
+
recentFacts,
|
|
302
|
+
recentPreferenceFacts
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
hasSelfCorrectionPattern(consolidation) {
|
|
306
|
+
const text = consolidation.interactionUnit?.semanticText || '';
|
|
307
|
+
return /(不对|不是|更正|改口)/.test(text) && /(左耳|右耳)/.test(text);
|
|
308
|
+
}
|
|
309
|
+
hasSuspiciousUnseenEntityBinding(consolidation) {
|
|
310
|
+
const semanticEntityHints = consolidation.semanticCompilation?.entities.map((entity) => entity.text) || [];
|
|
311
|
+
const compiledEntityNames = consolidation.compiledEntityIds
|
|
312
|
+
.map((entityId) => this.entityStore.findByEntityId(entityId)?.canonicalName || '')
|
|
313
|
+
.filter(Boolean);
|
|
314
|
+
const sourceText = consolidation.interactionUnit?.semanticText || '';
|
|
315
|
+
const explicitNamedDevice = sourceText.match(/([A-Za-z][A-Za-z0-9._-]*(?:\s+[A-Za-z0-9._-]+){1,3})/);
|
|
316
|
+
const candidate = explicitNamedDevice?.[1];
|
|
317
|
+
if (!candidate)
|
|
318
|
+
return false;
|
|
319
|
+
return semanticEntityHints.some((hint) => hint === candidate)
|
|
320
|
+
|| (compiledEntityNames.length > 0 && compiledEntityNames.every((name) => !name.toLowerCase().includes(candidate.toLowerCase())));
|
|
321
|
+
}
|
|
322
|
+
persistAsyncEnrichmentResult(runId, neuron, sourceEventId, result) {
|
|
323
|
+
const entities = (result.entities || []).map((entity) => {
|
|
324
|
+
const record = this.entityStore.upsertEntity({
|
|
325
|
+
canonicalName: entity.canonicalName,
|
|
326
|
+
type: entity.type,
|
|
327
|
+
aliases: entity.aliases,
|
|
328
|
+
createdFrom: neuron.id,
|
|
329
|
+
metadata: {
|
|
330
|
+
...(entity.metadata || {}),
|
|
331
|
+
source: 'enrichment',
|
|
332
|
+
enrichment_run_id: runId,
|
|
333
|
+
parent_neuron_id: neuron.id
|
|
334
|
+
},
|
|
335
|
+
instanceMode: entity.instanceMode,
|
|
336
|
+
createdAt: Date.now()
|
|
337
|
+
});
|
|
338
|
+
this.entityStore.recordMention({
|
|
339
|
+
entityId: record.entityId,
|
|
340
|
+
neuronId: neuron.id,
|
|
341
|
+
projectId: neuron.metadata.projectId,
|
|
342
|
+
mentionType: 'related',
|
|
343
|
+
createdAt: Date.now()
|
|
344
|
+
});
|
|
345
|
+
return record;
|
|
346
|
+
});
|
|
347
|
+
const facts = this.factStore.insertFacts((result.facts || []).map((fact) => ({
|
|
348
|
+
...fact,
|
|
349
|
+
metadata: {
|
|
350
|
+
...(fact.metadata || {}),
|
|
351
|
+
source: 'enrichment',
|
|
352
|
+
fact_origin: 'enriched_fact',
|
|
353
|
+
enrichment_run_id: runId,
|
|
354
|
+
parent_neuron_id: neuron.id
|
|
355
|
+
}
|
|
356
|
+
})));
|
|
357
|
+
const beliefIds = [];
|
|
358
|
+
for (const belief of result.beliefs || []) {
|
|
359
|
+
const upserted = this.beliefStore.upsert({
|
|
360
|
+
...belief,
|
|
361
|
+
sourceNeuronId: belief.sourceNeuronId || neuron.id,
|
|
362
|
+
sourceEventId: belief.sourceEventId || sourceEventId,
|
|
363
|
+
sourceType: belief.sourceType || 'llm_inference',
|
|
364
|
+
metadata: {
|
|
365
|
+
...(belief.metadata || {}),
|
|
366
|
+
source: 'enrichment',
|
|
367
|
+
enrichment_run_id: runId,
|
|
368
|
+
parent_neuron_id: neuron.id
|
|
369
|
+
}
|
|
370
|
+
}, Date.now());
|
|
371
|
+
if (upserted.belief)
|
|
372
|
+
beliefIds.push(upserted.belief.id);
|
|
373
|
+
}
|
|
374
|
+
return { entities, facts, beliefIds };
|
|
375
|
+
}
|
|
376
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MemoryGraph } from '../core/MemoryGraph.js';
|
|
2
|
+
export interface ConsolidationTriggerOptions {
|
|
3
|
+
episodicThreshold?: number;
|
|
4
|
+
cooldownMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ConsolidationCandidate {
|
|
7
|
+
topicPath: string;
|
|
8
|
+
episodicNeuronIds: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare class ConsolidationTrigger {
|
|
11
|
+
private readonly memoryGraph;
|
|
12
|
+
private readonly episodicThreshold;
|
|
13
|
+
private readonly cooldownMs;
|
|
14
|
+
constructor(memoryGraph: MemoryGraph, options?: ConsolidationTriggerOptions);
|
|
15
|
+
findCandidates(projectId: string): ConsolidationCandidate[];
|
|
16
|
+
private inCooldown;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ConsolidationTrigger.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export class ConsolidationTrigger {
|
|
2
|
+
memoryGraph;
|
|
3
|
+
episodicThreshold;
|
|
4
|
+
cooldownMs;
|
|
5
|
+
constructor(memoryGraph, options = {}) {
|
|
6
|
+
this.memoryGraph = memoryGraph;
|
|
7
|
+
this.episodicThreshold = options.episodicThreshold ?? 20;
|
|
8
|
+
this.cooldownMs = options.cooldownMs ?? 6 * 60 * 60 * 1000;
|
|
9
|
+
}
|
|
10
|
+
findCandidates(projectId) {
|
|
11
|
+
const now = Date.now();
|
|
12
|
+
const grouped = new Map();
|
|
13
|
+
const neurons = this.memoryGraph.getAllNeurons()
|
|
14
|
+
.filter((neuron) => neuron.metadata.projectId === projectId)
|
|
15
|
+
.filter((neuron) => isEpisodic(neuron));
|
|
16
|
+
for (const neuron of neurons) {
|
|
17
|
+
const topicPath = neuron.metadata.topicPath || 'global';
|
|
18
|
+
const bucket = grouped.get(topicPath) || [];
|
|
19
|
+
bucket.push(neuron);
|
|
20
|
+
grouped.set(topicPath, bucket);
|
|
21
|
+
}
|
|
22
|
+
const semantic = this.memoryGraph.getAllNeurons()
|
|
23
|
+
.filter((neuron) => neuron.metadata.projectId === projectId && neuron.metadata.type === 'semantic_consolidation');
|
|
24
|
+
return Array.from(grouped.entries())
|
|
25
|
+
.filter(([topicPath, items]) => items.length >= this.episodicThreshold && !this.inCooldown(topicPath, semantic, now))
|
|
26
|
+
.map(([topicPath, items]) => ({
|
|
27
|
+
topicPath,
|
|
28
|
+
episodicNeuronIds: items.map((neuron) => neuron.id)
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
inCooldown(topicPath, semantic, now) {
|
|
32
|
+
return semantic.some((neuron) => (neuron.metadata.tags || []).includes(`topic:${topicPath}`)
|
|
33
|
+
&& now - (neuron.metadata.createdAt || 0) < this.cooldownMs);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function isEpisodic(neuron) {
|
|
37
|
+
return neuron.metadata.type === 'chat'
|
|
38
|
+
|| neuron.metadata.type === 'agent_finding'
|
|
39
|
+
|| neuron.metadata.type === 'agent_observation'
|
|
40
|
+
|| neuron.metadata.type === 'doc';
|
|
41
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MemoryGraph } from '../core/MemoryGraph.js';
|
|
2
|
+
import type { IterativeLLMClarifier } from '../routing/IterativeLLMClarifier.js';
|
|
3
|
+
import type { CrossTopicTrigger } from './CrossTopicTrigger.js';
|
|
4
|
+
export interface CrossSynthesisInput {
|
|
5
|
+
projectId: string;
|
|
6
|
+
semanticNeuronIds: string[];
|
|
7
|
+
distinctTopics: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface CrossSynthesisResult {
|
|
10
|
+
principleNeuronId: string;
|
|
11
|
+
principle: string;
|
|
12
|
+
sourceTopics: string[];
|
|
13
|
+
createdAt: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class CrossTopicSynthesizer {
|
|
16
|
+
private readonly memoryGraph;
|
|
17
|
+
private readonly trigger;
|
|
18
|
+
private readonly clarifier;
|
|
19
|
+
private readonly options;
|
|
20
|
+
constructor(memoryGraph: MemoryGraph, trigger: CrossTopicTrigger, clarifier: IterativeLLMClarifier, options?: {
|
|
21
|
+
maxSourceNeuronsPerBatch?: number;
|
|
22
|
+
});
|
|
23
|
+
run(projectId: string): Promise<{
|
|
24
|
+
principleNeuronsCreated: number;
|
|
25
|
+
}>;
|
|
26
|
+
private synthesize;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=CrossTopicSynthesizer.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { NeuronFactory } from '../core/Neuron.js';
|
|
2
|
+
export class CrossTopicSynthesizer {
|
|
3
|
+
memoryGraph;
|
|
4
|
+
trigger;
|
|
5
|
+
clarifier;
|
|
6
|
+
options;
|
|
7
|
+
constructor(memoryGraph, trigger, clarifier, options = {}) {
|
|
8
|
+
this.memoryGraph = memoryGraph;
|
|
9
|
+
this.trigger = trigger;
|
|
10
|
+
this.clarifier = clarifier;
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
async run(projectId) {
|
|
14
|
+
let principleNeuronsCreated = 0;
|
|
15
|
+
for (const batch of this.trigger.findCandidateBatches(projectId)) {
|
|
16
|
+
const result = await this.synthesize({ projectId, ...batch });
|
|
17
|
+
if (result)
|
|
18
|
+
principleNeuronsCreated += 1;
|
|
19
|
+
}
|
|
20
|
+
return { principleNeuronsCreated };
|
|
21
|
+
}
|
|
22
|
+
async synthesize(input) {
|
|
23
|
+
const sources = input.semanticNeuronIds
|
|
24
|
+
.map((id) => this.memoryGraph.getNeuron(id))
|
|
25
|
+
.filter((neuron) => Boolean(neuron))
|
|
26
|
+
.filter((neuron) => neuron.metadata.projectId === input.projectId)
|
|
27
|
+
.slice(0, this.options.maxSourceNeuronsPerBatch ?? 20);
|
|
28
|
+
if (sources.length === 0)
|
|
29
|
+
return null;
|
|
30
|
+
const prompt = [
|
|
31
|
+
'Synthesize these semantic consolidations into one cross-domain principle.',
|
|
32
|
+
'Return the principle as plain text only.',
|
|
33
|
+
`Topics: ${input.distinctTopics.join(', ')}`,
|
|
34
|
+
JSON.stringify(sources.map((neuron) => ({ id: neuron.id, topic: neuron.metadata.topicPath, content: neuron.content.slice(0, 400) })))
|
|
35
|
+
].join('\n');
|
|
36
|
+
const result = await this.clarifier.clarify(prompt, emptyRecallResult(prompt));
|
|
37
|
+
const principle = result.finalAnswer.trim() || 'Multiple topics share a durable cross-domain operating principle.';
|
|
38
|
+
const createdAt = Date.now();
|
|
39
|
+
const neuron = NeuronFactory.create(principle, this.memoryGraph.getLatestNeuronSelfHash(input.projectId) || 'genesis', { T: createdAt, S: [0, 0, 0], V: [] }, {
|
|
40
|
+
projectId: input.projectId,
|
|
41
|
+
topicPath: 'cross_domain',
|
|
42
|
+
type: 'cross_domain_principle',
|
|
43
|
+
createdAt,
|
|
44
|
+
updatedAt: createdAt,
|
|
45
|
+
status: 'active',
|
|
46
|
+
tags: ['cross_domain', ...input.distinctTopics],
|
|
47
|
+
sourceType: 'llm_inference',
|
|
48
|
+
importanceLevel: 'permanent',
|
|
49
|
+
isPinned: true,
|
|
50
|
+
stability: 1,
|
|
51
|
+
lastReinforcedAt: createdAt,
|
|
52
|
+
aaak_summary: principle
|
|
53
|
+
});
|
|
54
|
+
this.memoryGraph.addNeuron(neuron);
|
|
55
|
+
for (const source of sources)
|
|
56
|
+
this.memoryGraph.addSynapse(neuron.id, { targetId: source.id, type: 'Referenced', weight: 1 });
|
|
57
|
+
return { principleNeuronId: neuron.id, principle, sourceTopics: input.distinctTopics, createdAt };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function emptyRecallResult(query) {
|
|
61
|
+
return {
|
|
62
|
+
query,
|
|
63
|
+
strategy: { primaryLevel: 'compiled_memory', fallbackUsed: false },
|
|
64
|
+
compiledMemory: { beliefs: [], facts: [], events: [], entityTimeline: [] },
|
|
65
|
+
rawEvidence: [],
|
|
66
|
+
fallbackSnippets: [],
|
|
67
|
+
profileSignals: [],
|
|
68
|
+
profileSurface: { userProfile: [], agentPersona: [] }
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MemoryGraph } from '../core/MemoryGraph.js';
|
|
2
|
+
export interface CrossTopicTriggerOptions {
|
|
3
|
+
semanticThreshold?: number;
|
|
4
|
+
minDistinctTopics?: number;
|
|
5
|
+
cooldownMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class CrossTopicTrigger {
|
|
8
|
+
private readonly memoryGraph;
|
|
9
|
+
private readonly options;
|
|
10
|
+
private readonly lastTriggeredByBatch;
|
|
11
|
+
constructor(memoryGraph: MemoryGraph, options?: CrossTopicTriggerOptions);
|
|
12
|
+
findCandidateBatches(projectId: string): Array<{
|
|
13
|
+
semanticNeuronIds: string[];
|
|
14
|
+
distinctTopics: string[];
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=CrossTopicTrigger.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class CrossTopicTrigger {
|
|
2
|
+
memoryGraph;
|
|
3
|
+
options;
|
|
4
|
+
lastTriggeredByBatch = new Map();
|
|
5
|
+
constructor(memoryGraph, options = {}) {
|
|
6
|
+
this.memoryGraph = memoryGraph;
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
findCandidateBatches(projectId) {
|
|
10
|
+
const semanticThreshold = this.options.semanticThreshold ?? 8;
|
|
11
|
+
const minDistinctTopics = this.options.minDistinctTopics ?? 3;
|
|
12
|
+
const cooldownMs = this.options.cooldownMs ?? 48 * 60 * 60 * 1000;
|
|
13
|
+
const semantic = this.memoryGraph.getAllNeurons()
|
|
14
|
+
.filter((neuron) => neuron.metadata.projectId === projectId)
|
|
15
|
+
.filter((neuron) => neuron.metadata.type === 'semantic_consolidation')
|
|
16
|
+
.sort((a, b) => (b.metadata.createdAt || 0) - (a.metadata.createdAt || 0));
|
|
17
|
+
const topics = Array.from(new Set(semantic.map((neuron) => neuron.metadata.topicPath || topicFromTags(neuron.metadata.tags || [])).filter((topic) => Boolean(topic))));
|
|
18
|
+
const ids = semantic.map((neuron) => neuron.id);
|
|
19
|
+
const key = ids.slice().sort().join('|');
|
|
20
|
+
const lastTriggered = this.lastTriggeredByBatch.get(key) || 0;
|
|
21
|
+
if (semantic.length < semanticThreshold || topics.length < minDistinctTopics || Date.now() - lastTriggered < cooldownMs)
|
|
22
|
+
return [];
|
|
23
|
+
this.lastTriggeredByBatch.set(key, Date.now());
|
|
24
|
+
return [{ semanticNeuronIds: ids, distinctTopics: topics }];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function topicFromTags(tags) {
|
|
28
|
+
return tags.find((tag) => tag.startsWith('topic:'))?.slice('topic:'.length);
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type DeepWriteMode = 'off' | 'shadow' | 'candidate' | 'promote_guarded';
|
|
2
|
+
export interface DeepWriteConfig {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
mode: DeepWriteMode;
|
|
5
|
+
contextTurns: number;
|
|
6
|
+
recallLimit: number;
|
|
7
|
+
minPromoteConfidence: number;
|
|
8
|
+
modelRole: 'memory';
|
|
9
|
+
allowCloud: boolean;
|
|
10
|
+
redactionEnabled: boolean;
|
|
11
|
+
promoteCausalLinks: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function resolveDeepWriteConfig(env?: Record<string, string | undefined>): DeepWriteConfig;
|
|
14
|
+
//# sourceMappingURL=DeepWriteConfig.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function parseBoolean(value, fallback = false) {
|
|
2
|
+
if (value === undefined)
|
|
3
|
+
return fallback;
|
|
4
|
+
const normalized = value.trim().toLowerCase();
|
|
5
|
+
return normalized === '1' || normalized === 'true' || normalized === 'yes' || normalized === 'y';
|
|
6
|
+
}
|
|
7
|
+
function parseNumber(value, fallback) {
|
|
8
|
+
const parsed = Number(value);
|
|
9
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
10
|
+
}
|
|
11
|
+
function parseMode(value) {
|
|
12
|
+
const normalized = (value || 'off').trim();
|
|
13
|
+
return normalized === 'shadow'
|
|
14
|
+
|| normalized === 'candidate'
|
|
15
|
+
|| normalized === 'promote_guarded'
|
|
16
|
+
|| normalized === 'off'
|
|
17
|
+
? normalized
|
|
18
|
+
: 'off';
|
|
19
|
+
}
|
|
20
|
+
export function resolveDeepWriteConfig(env = {}) {
|
|
21
|
+
const read = (name, legacyName) => env[name] ?? (legacyName ? env[legacyName] : undefined);
|
|
22
|
+
const enabled = parseBoolean(read('COGMEM_DEEP_WRITE_ENABLED', 'AGENT_BRAIN_DEEP_WRITE_ENABLED'), false);
|
|
23
|
+
const mode = enabled
|
|
24
|
+
? parseMode(read('COGMEM_DEEP_WRITE_MODE', 'AGENT_BRAIN_DEEP_WRITE_MODE') || 'shadow')
|
|
25
|
+
: 'off';
|
|
26
|
+
return {
|
|
27
|
+
enabled,
|
|
28
|
+
mode,
|
|
29
|
+
contextTurns: Math.min(100, Math.floor(parseNumber(read('COGMEM_DEEP_WRITE_CONTEXT_TURNS', 'AGENT_BRAIN_DEEP_WRITE_CONTEXT_TURNS'), 24))),
|
|
30
|
+
recallLimit: Math.min(50, Math.floor(parseNumber(read('COGMEM_DEEP_WRITE_RECALL_LIMIT', 'AGENT_BRAIN_DEEP_WRITE_RECALL_LIMIT'), 12))),
|
|
31
|
+
minPromoteConfidence: Math.min(1, Math.max(0, parseNumber(read('COGMEM_DEEP_WRITE_MIN_PROMOTE_CONFIDENCE', 'AGENT_BRAIN_DEEP_WRITE_MIN_PROMOTE_CONFIDENCE'), 0.86))),
|
|
32
|
+
modelRole: 'memory',
|
|
33
|
+
allowCloud: parseBoolean(read('COGMEM_DEEP_WRITE_ALLOW_CLOUD', 'AGENT_BRAIN_DEEP_WRITE_ALLOW_CLOUD'), false),
|
|
34
|
+
redactionEnabled: parseBoolean(read('COGMEM_DEEP_WRITE_REDACTION_ENABLED', 'AGENT_BRAIN_DEEP_WRITE_REDACTION_ENABLED'), true),
|
|
35
|
+
promoteCausalLinks: parseBoolean(read('COGMEM_DEEP_WRITE_PROMOTE_CAUSAL', 'AGENT_BRAIN_DEEP_WRITE_PROMOTE_CAUSAL'), false)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TextGenerateFn } from '../models/ModelRole.js';
|
|
2
|
+
export interface DeepWriteTurnInput {
|
|
3
|
+
role: 'user' | 'assistant';
|
|
4
|
+
content: string;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
turnId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DeepWriteRecallInput {
|
|
9
|
+
facts: unknown[];
|
|
10
|
+
beliefs: unknown[];
|
|
11
|
+
entities: unknown[];
|
|
12
|
+
rawEvidence: Array<{
|
|
13
|
+
neuronId: string;
|
|
14
|
+
content: string;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
tags?: string[];
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export interface DeepWriteMemoryCompilerInput {
|
|
20
|
+
projectId?: string;
|
|
21
|
+
sessionId?: string;
|
|
22
|
+
currentExchange: {
|
|
23
|
+
userTurnId?: string;
|
|
24
|
+
assistantTurnId?: string;
|
|
25
|
+
userText: string;
|
|
26
|
+
assistantText?: string;
|
|
27
|
+
createdAt: number;
|
|
28
|
+
};
|
|
29
|
+
recentTurns: DeepWriteTurnInput[];
|
|
30
|
+
recalledMemory: DeepWriteRecallInput;
|
|
31
|
+
}
|
|
32
|
+
export interface DeepWriteMemoryCompilerResult {
|
|
33
|
+
output: Record<string, unknown>;
|
|
34
|
+
rawOutput: string;
|
|
35
|
+
systemPrompt: string;
|
|
36
|
+
userPrompt: string;
|
|
37
|
+
}
|
|
38
|
+
export declare class DeepWriteMemoryCompiler {
|
|
39
|
+
private readonly generate;
|
|
40
|
+
constructor(generate: TextGenerateFn);
|
|
41
|
+
compile(input: DeepWriteMemoryCompilerInput): Promise<DeepWriteMemoryCompilerResult>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=DeepWriteMemoryCompiler.d.ts.map
|