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,47 @@
|
|
|
1
|
+
import Database from 'bun:sqlite';
|
|
2
|
+
import type { GovernanceEvidenceRecord } from '../governance/MemoryGovernanceValidator.js';
|
|
3
|
+
import { EntityStore } from '../store/EntityStore.js';
|
|
4
|
+
export type EntityMergeCandidateStatus = 'pending' | 'approved' | 'rejected' | 'applied' | 'reverted';
|
|
5
|
+
export interface EntityMergeCandidate {
|
|
6
|
+
candidateId: string;
|
|
7
|
+
projectId?: string;
|
|
8
|
+
sourceEntityId: string;
|
|
9
|
+
targetEntityId: string;
|
|
10
|
+
alias: string;
|
|
11
|
+
confidence: number;
|
|
12
|
+
status: EntityMergeCandidateStatus;
|
|
13
|
+
reviewReasons: string[];
|
|
14
|
+
evidenceEventIds: string[];
|
|
15
|
+
createdAt: number;
|
|
16
|
+
updatedAt: number;
|
|
17
|
+
version: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ProposeEntityMergeInput {
|
|
20
|
+
projectId?: string;
|
|
21
|
+
sourceEntityId: string;
|
|
22
|
+
targetEntityId: string;
|
|
23
|
+
alias: string;
|
|
24
|
+
confidence: number;
|
|
25
|
+
evidenceEventIds: string[];
|
|
26
|
+
now?: number;
|
|
27
|
+
}
|
|
28
|
+
export declare class EntityGovernanceService {
|
|
29
|
+
private readonly db;
|
|
30
|
+
private readonly entities;
|
|
31
|
+
private readonly findEvidence;
|
|
32
|
+
constructor(db: Database, entities: EntityStore, findEvidence: (eventId: string) => GovernanceEvidenceRecord | undefined);
|
|
33
|
+
proposeMerge(input: ProposeEntityMergeInput): EntityMergeCandidate;
|
|
34
|
+
apply(candidateId: string, now?: number): EntityMergeCandidate;
|
|
35
|
+
revert(candidateId: string, now?: number): EntityMergeCandidate;
|
|
36
|
+
get(candidateId: string): EntityMergeCandidate | null;
|
|
37
|
+
list(options?: {
|
|
38
|
+
projectId?: string;
|
|
39
|
+
status?: EntityMergeCandidateStatus;
|
|
40
|
+
limit?: number;
|
|
41
|
+
}): EntityMergeCandidate[];
|
|
42
|
+
private requireEntity;
|
|
43
|
+
private requireCandidate;
|
|
44
|
+
private updateStatus;
|
|
45
|
+
private initializeSchema;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=EntityGovernanceService.d.ts.map
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
export class EntityGovernanceService {
|
|
3
|
+
db;
|
|
4
|
+
entities;
|
|
5
|
+
findEvidence;
|
|
6
|
+
constructor(db, entities, findEvidence) {
|
|
7
|
+
this.db = db;
|
|
8
|
+
this.entities = entities;
|
|
9
|
+
this.findEvidence = findEvidence;
|
|
10
|
+
this.initializeSchema();
|
|
11
|
+
}
|
|
12
|
+
proposeMerge(input) {
|
|
13
|
+
const now = input.now ?? Date.now();
|
|
14
|
+
const source = this.requireEntity(input.sourceEntityId);
|
|
15
|
+
const target = this.requireEntity(input.targetEntityId);
|
|
16
|
+
const reasons = [];
|
|
17
|
+
const evidence = input.evidenceEventIds.map((eventId) => this.findEvidence(eventId)).filter(Boolean);
|
|
18
|
+
if (source.entityId === target.entityId)
|
|
19
|
+
reasons.push('same_entity');
|
|
20
|
+
if (source.type !== target.type)
|
|
21
|
+
reasons.push('entity_type_mismatch');
|
|
22
|
+
if (projectIdOf(source) && input.projectId && projectIdOf(source) !== input.projectId)
|
|
23
|
+
reasons.push('project_boundary_violation');
|
|
24
|
+
if (projectIdOf(target) && input.projectId && projectIdOf(target) !== input.projectId)
|
|
25
|
+
reasons.push('project_boundary_violation');
|
|
26
|
+
if (evidence.length !== input.evidenceEventIds.length)
|
|
27
|
+
reasons.push('unknown_evidence');
|
|
28
|
+
if (evidence.some((item) => item.projectId && input.projectId && item.projectId !== input.projectId))
|
|
29
|
+
reasons.push('project_boundary_violation');
|
|
30
|
+
const hasUserEvidence = evidence.some((item) => item.role === 'user');
|
|
31
|
+
if (source.type === 'person' && !hasUserEvidence)
|
|
32
|
+
reasons.push('person_merge_requires_explicit_user_evidence');
|
|
33
|
+
const fatal = reasons.some((reason) => ['same_entity', 'entity_type_mismatch', 'project_boundary_violation', 'unknown_evidence'].includes(reason));
|
|
34
|
+
const threshold = source.type === 'person' ? 0.99 : 0.95;
|
|
35
|
+
const status = fatal
|
|
36
|
+
? 'rejected'
|
|
37
|
+
: input.confidence >= threshold && (source.type !== 'person' || hasUserEvidence)
|
|
38
|
+
? 'approved'
|
|
39
|
+
: input.confidence < 0.6
|
|
40
|
+
? 'rejected'
|
|
41
|
+
: 'pending';
|
|
42
|
+
if (status === 'pending' && reasons.length === 0)
|
|
43
|
+
reasons.push('confidence_requires_review');
|
|
44
|
+
if (status === 'rejected' && reasons.length === 0)
|
|
45
|
+
reasons.push('confidence_below_minimum');
|
|
46
|
+
const candidateId = candidateIdFor(input);
|
|
47
|
+
this.db.prepare(`
|
|
48
|
+
INSERT INTO entity_merge_candidates (
|
|
49
|
+
candidate_id, project_id, source_entity_id, target_entity_id, alias, confidence,
|
|
50
|
+
status, review_reasons_json, evidence_event_ids_json, created_at, updated_at, version
|
|
51
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1)
|
|
52
|
+
ON CONFLICT(candidate_id) DO UPDATE SET
|
|
53
|
+
confidence = excluded.confidence,
|
|
54
|
+
status = excluded.status,
|
|
55
|
+
review_reasons_json = excluded.review_reasons_json,
|
|
56
|
+
evidence_event_ids_json = excluded.evidence_event_ids_json,
|
|
57
|
+
updated_at = excluded.updated_at,
|
|
58
|
+
version = entity_merge_candidates.version + 1
|
|
59
|
+
`).run(candidateId, input.projectId || null, source.entityId, target.entityId, input.alias, input.confidence, status, JSON.stringify(reasons), JSON.stringify(input.evidenceEventIds), now, now);
|
|
60
|
+
return this.get(candidateId);
|
|
61
|
+
}
|
|
62
|
+
apply(candidateId, now = Date.now()) {
|
|
63
|
+
const candidate = this.requireCandidate(candidateId);
|
|
64
|
+
if (candidate.status === 'applied')
|
|
65
|
+
return candidate;
|
|
66
|
+
if (candidate.status !== 'approved')
|
|
67
|
+
throw new Error(`Entity merge candidate is not approved: ${candidate.status}`);
|
|
68
|
+
const source = this.requireEntity(candidate.sourceEntityId);
|
|
69
|
+
const target = this.requireEntity(candidate.targetEntityId);
|
|
70
|
+
if (!source.canonicalEntityId || !target.canonicalEntityId)
|
|
71
|
+
throw new Error('Entity merge requires canonical entity ids.');
|
|
72
|
+
this.db.transaction(() => {
|
|
73
|
+
this.entities.addAlias(target.entityId, candidate.alias, now);
|
|
74
|
+
this.entities.redirectInstance({ sourceEntityId: source.entityId, targetCanonicalEntityId: target.canonicalEntityId, updatedAt: now });
|
|
75
|
+
this.db.prepare(`
|
|
76
|
+
INSERT INTO entity_resolution_log (
|
|
77
|
+
log_id, candidate_id, source_entity_id, target_entity_id, previous_canonical_entity_id,
|
|
78
|
+
previous_status, alias, action, created_at
|
|
79
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, 'merge', ?)
|
|
80
|
+
`).run(`elog:${candidateId}:merge`, candidateId, source.entityId, target.entityId, source.canonicalEntityId, source.status, candidate.alias, now);
|
|
81
|
+
this.updateStatus(candidateId, 'applied', now);
|
|
82
|
+
})();
|
|
83
|
+
return this.requireCandidate(candidateId);
|
|
84
|
+
}
|
|
85
|
+
revert(candidateId, now = Date.now()) {
|
|
86
|
+
const candidate = this.requireCandidate(candidateId);
|
|
87
|
+
if (candidate.status === 'reverted')
|
|
88
|
+
return candidate;
|
|
89
|
+
if (candidate.status !== 'applied')
|
|
90
|
+
throw new Error(`Entity merge candidate is not applied: ${candidate.status}`);
|
|
91
|
+
const log = this.db.prepare(`
|
|
92
|
+
SELECT * FROM entity_resolution_log WHERE candidate_id = ? AND action = 'merge'
|
|
93
|
+
ORDER BY created_at DESC LIMIT 1
|
|
94
|
+
`).get(candidateId);
|
|
95
|
+
if (!log)
|
|
96
|
+
throw new Error(`Missing entity merge audit log: ${candidateId}`);
|
|
97
|
+
this.db.transaction(() => {
|
|
98
|
+
this.entities.restoreInstance({
|
|
99
|
+
entityId: candidate.sourceEntityId,
|
|
100
|
+
canonicalEntityId: String(log.previous_canonical_entity_id),
|
|
101
|
+
status: String(log.previous_status),
|
|
102
|
+
updatedAt: now,
|
|
103
|
+
});
|
|
104
|
+
this.entities.removeAlias(candidate.targetEntityId, String(log.alias), now);
|
|
105
|
+
this.db.prepare(`
|
|
106
|
+
INSERT INTO entity_resolution_log (
|
|
107
|
+
log_id, candidate_id, source_entity_id, target_entity_id, previous_canonical_entity_id,
|
|
108
|
+
previous_status, alias, action, created_at
|
|
109
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, 'revert', ?)
|
|
110
|
+
`).run(`elog:${candidateId}:revert:${now}`, candidateId, candidate.sourceEntityId, candidate.targetEntityId, String(log.previous_canonical_entity_id), String(log.previous_status), String(log.alias), now);
|
|
111
|
+
this.updateStatus(candidateId, 'reverted', now);
|
|
112
|
+
})();
|
|
113
|
+
return this.requireCandidate(candidateId);
|
|
114
|
+
}
|
|
115
|
+
get(candidateId) {
|
|
116
|
+
const row = this.db.prepare(`SELECT * FROM entity_merge_candidates WHERE candidate_id = ?`).get(candidateId);
|
|
117
|
+
return row ? mapCandidate(row) : null;
|
|
118
|
+
}
|
|
119
|
+
list(options = {}) {
|
|
120
|
+
const clauses = [];
|
|
121
|
+
const params = [];
|
|
122
|
+
if (options.projectId) {
|
|
123
|
+
clauses.push('project_id = ?');
|
|
124
|
+
params.push(options.projectId);
|
|
125
|
+
}
|
|
126
|
+
if (options.status) {
|
|
127
|
+
clauses.push('status = ?');
|
|
128
|
+
params.push(options.status);
|
|
129
|
+
}
|
|
130
|
+
const where = clauses.length ? `WHERE ${clauses.join(' AND ')}` : '';
|
|
131
|
+
params.push(Math.max(1, Math.min(500, options.limit ?? 100)));
|
|
132
|
+
return this.db.prepare(`SELECT * FROM entity_merge_candidates ${where} ORDER BY updated_at DESC LIMIT ?`).all(...params)
|
|
133
|
+
.map(mapCandidate);
|
|
134
|
+
}
|
|
135
|
+
requireEntity(entityId) {
|
|
136
|
+
const entity = this.entities.findByEntityId(entityId);
|
|
137
|
+
if (!entity)
|
|
138
|
+
throw new Error(`Unknown entity: ${entityId}`);
|
|
139
|
+
return entity;
|
|
140
|
+
}
|
|
141
|
+
requireCandidate(candidateId) {
|
|
142
|
+
const candidate = this.get(candidateId);
|
|
143
|
+
if (!candidate)
|
|
144
|
+
throw new Error(`Unknown entity merge candidate: ${candidateId}`);
|
|
145
|
+
return candidate;
|
|
146
|
+
}
|
|
147
|
+
updateStatus(candidateId, status, now) {
|
|
148
|
+
this.db.prepare(`
|
|
149
|
+
UPDATE entity_merge_candidates SET status = ?, updated_at = ?, version = version + 1 WHERE candidate_id = ?
|
|
150
|
+
`).run(status, now, candidateId);
|
|
151
|
+
}
|
|
152
|
+
initializeSchema() {
|
|
153
|
+
this.db.exec(`
|
|
154
|
+
CREATE TABLE IF NOT EXISTS entity_merge_candidates (
|
|
155
|
+
candidate_id TEXT PRIMARY KEY,
|
|
156
|
+
project_id TEXT,
|
|
157
|
+
source_entity_id TEXT NOT NULL,
|
|
158
|
+
target_entity_id TEXT NOT NULL,
|
|
159
|
+
alias TEXT NOT NULL,
|
|
160
|
+
confidence REAL NOT NULL,
|
|
161
|
+
status TEXT NOT NULL,
|
|
162
|
+
review_reasons_json TEXT NOT NULL,
|
|
163
|
+
evidence_event_ids_json TEXT NOT NULL,
|
|
164
|
+
created_at INTEGER NOT NULL,
|
|
165
|
+
updated_at INTEGER NOT NULL,
|
|
166
|
+
version INTEGER NOT NULL DEFAULT 1
|
|
167
|
+
);
|
|
168
|
+
CREATE INDEX IF NOT EXISTS idx_entity_merge_candidates_project
|
|
169
|
+
ON entity_merge_candidates(project_id, status, updated_at DESC);
|
|
170
|
+
CREATE TABLE IF NOT EXISTS entity_resolution_log (
|
|
171
|
+
log_id TEXT PRIMARY KEY,
|
|
172
|
+
candidate_id TEXT NOT NULL,
|
|
173
|
+
source_entity_id TEXT NOT NULL,
|
|
174
|
+
target_entity_id TEXT NOT NULL,
|
|
175
|
+
previous_canonical_entity_id TEXT NOT NULL,
|
|
176
|
+
previous_status TEXT NOT NULL,
|
|
177
|
+
alias TEXT NOT NULL,
|
|
178
|
+
action TEXT NOT NULL,
|
|
179
|
+
created_at INTEGER NOT NULL
|
|
180
|
+
);
|
|
181
|
+
`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function candidateIdFor(input) {
|
|
185
|
+
const value = [input.projectId || '', input.sourceEntityId, input.targetEntityId, input.alias.toLowerCase()].join('\0');
|
|
186
|
+
return `emerge-${createHash('sha256').update(value).digest('hex').slice(0, 24)}`;
|
|
187
|
+
}
|
|
188
|
+
function projectIdOf(entity) {
|
|
189
|
+
return typeof entity.metadata?.projectId === 'string' ? entity.metadata.projectId : undefined;
|
|
190
|
+
}
|
|
191
|
+
function mapCandidate(row) {
|
|
192
|
+
return {
|
|
193
|
+
candidateId: String(row.candidate_id),
|
|
194
|
+
projectId: row.project_id ? String(row.project_id) : undefined,
|
|
195
|
+
sourceEntityId: String(row.source_entity_id),
|
|
196
|
+
targetEntityId: String(row.target_entity_id),
|
|
197
|
+
alias: String(row.alias),
|
|
198
|
+
confidence: Number(row.confidence),
|
|
199
|
+
status: String(row.status),
|
|
200
|
+
reviewReasons: parseArray(row.review_reasons_json),
|
|
201
|
+
evidenceEventIds: parseArray(row.evidence_event_ids_json),
|
|
202
|
+
createdAt: Number(row.created_at),
|
|
203
|
+
updatedAt: Number(row.updated_at),
|
|
204
|
+
version: Number(row.version),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function parseArray(value) {
|
|
208
|
+
try {
|
|
209
|
+
const parsed = JSON.parse(String(value || '[]'));
|
|
210
|
+
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === 'string') : [];
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EntityGovernanceService } from './EntityGovernanceService.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MemoryEvent } from '../types/index.js';
|
|
2
|
+
export declare class CogmemBlockStripper {
|
|
3
|
+
private readonly maxBlockChars;
|
|
4
|
+
constructor(options?: {
|
|
5
|
+
maxBlockChars?: number;
|
|
6
|
+
});
|
|
7
|
+
strip(value: string): string;
|
|
8
|
+
}
|
|
9
|
+
export declare function stripCogmemBlocks(value: string): string;
|
|
10
|
+
export declare function eventTextForMemory(event: Pick<MemoryEvent, 'payload'>): string;
|
|
11
|
+
//# sourceMappingURL=CogmemBlockStripper.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const CONTROL_BLOCKS = new Set([
|
|
2
|
+
'COGMEM_RECALL_CONTEXT', 'COGMEM_MEMORY_ATLAS', 'COGMEM_TURN_BRIDGE', 'COGMEM_SESSION_STATE', 'COGMEM_STRATEGY_CONTEXT',
|
|
3
|
+
]);
|
|
4
|
+
export class CogmemBlockStripper {
|
|
5
|
+
maxBlockChars;
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this.maxBlockChars = Math.max(64, Math.min(options.maxBlockChars ?? 256_000, 1_000_000));
|
|
8
|
+
}
|
|
9
|
+
strip(value) {
|
|
10
|
+
const text = String(value || '');
|
|
11
|
+
const token = /<\/?([A-Z0-9_]+)\b[^>]*>/giu;
|
|
12
|
+
const stack = [];
|
|
13
|
+
let result = '';
|
|
14
|
+
let cursor = 0;
|
|
15
|
+
let hiddenChars = 0;
|
|
16
|
+
for (const match of text.matchAll(token)) {
|
|
17
|
+
const index = match.index ?? 0;
|
|
18
|
+
const name = String(match[1] || '').toUpperCase();
|
|
19
|
+
if (!CONTROL_BLOCKS.has(name))
|
|
20
|
+
continue;
|
|
21
|
+
const closing = match[0].startsWith('</');
|
|
22
|
+
if (stack.length === 0)
|
|
23
|
+
result += text.slice(cursor, index);
|
|
24
|
+
else
|
|
25
|
+
hiddenChars += index - cursor;
|
|
26
|
+
if (closing) {
|
|
27
|
+
const position = stack.lastIndexOf(name);
|
|
28
|
+
if (position >= 0)
|
|
29
|
+
stack.splice(position);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
stack.push(name);
|
|
33
|
+
}
|
|
34
|
+
cursor = index + match[0].length;
|
|
35
|
+
if (hiddenChars > this.maxBlockChars && stack.length) {
|
|
36
|
+
cursor = text.length;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (stack.length === 0 && cursor < text.length)
|
|
41
|
+
result += text.slice(cursor);
|
|
42
|
+
return result.replace(/\s+/g, ' ').trim();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const DEFAULT_STRIPPER = new CogmemBlockStripper();
|
|
46
|
+
export function stripCogmemBlocks(value) {
|
|
47
|
+
return DEFAULT_STRIPPER.strip(value);
|
|
48
|
+
}
|
|
49
|
+
export function eventTextForMemory(event) {
|
|
50
|
+
const payload = event.payload;
|
|
51
|
+
if (!payload || typeof payload !== 'object')
|
|
52
|
+
return '';
|
|
53
|
+
for (const field of ['text', 'content', 'output', 'title', 'summary']) {
|
|
54
|
+
if (typeof payload[field] === 'string')
|
|
55
|
+
return stripCogmemBlocks(payload[field]);
|
|
56
|
+
}
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface CorrectionTarget {
|
|
2
|
+
beliefId: string;
|
|
3
|
+
canonicalKey?: string;
|
|
4
|
+
statement?: string;
|
|
5
|
+
projectId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CorrectionResolution {
|
|
8
|
+
status: 'resolved' | 'needs_review';
|
|
9
|
+
target?: CorrectionTarget;
|
|
10
|
+
candidates: CorrectionTarget[];
|
|
11
|
+
reason: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class CorrectionResolver {
|
|
14
|
+
private readonly searchActiveBeliefs;
|
|
15
|
+
constructor(searchActiveBeliefs: (input: {
|
|
16
|
+
projectId: string;
|
|
17
|
+
query: string;
|
|
18
|
+
topicPath?: string;
|
|
19
|
+
entities?: string[];
|
|
20
|
+
limit: number;
|
|
21
|
+
}) => CorrectionTarget[]);
|
|
22
|
+
resolve(input: {
|
|
23
|
+
projectId: string;
|
|
24
|
+
query: string;
|
|
25
|
+
claimKey?: string;
|
|
26
|
+
topicPath?: string;
|
|
27
|
+
entities?: string[];
|
|
28
|
+
}): CorrectionResolution;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=CorrectionResolver.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class CorrectionResolver {
|
|
2
|
+
searchActiveBeliefs;
|
|
3
|
+
constructor(searchActiveBeliefs) {
|
|
4
|
+
this.searchActiveBeliefs = searchActiveBeliefs;
|
|
5
|
+
}
|
|
6
|
+
resolve(input) {
|
|
7
|
+
const candidates = this.searchActiveBeliefs({
|
|
8
|
+
projectId: input.projectId, query: input.claimKey || input.query, topicPath: input.topicPath,
|
|
9
|
+
entities: input.entities, limit: 5,
|
|
10
|
+
}).filter((candidate) => !candidate.projectId || candidate.projectId === input.projectId);
|
|
11
|
+
const exact = input.claimKey ? candidates.filter((candidate) => candidate.canonicalKey === input.claimKey) : [];
|
|
12
|
+
const selected = exact.length === 1 ? exact[0] : candidates.length === 1 ? candidates[0] : undefined;
|
|
13
|
+
return selected
|
|
14
|
+
? { status: 'resolved', target: selected, candidates, reason: exact.length === 1 ? 'canonical_key_match' : 'single_bounded_semantic_match' }
|
|
15
|
+
: { status: 'needs_review', candidates, reason: candidates.length ? 'ambiguous_correction_target' : 'orphan_correction' };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { MemoryEvent } from '../types/index.js';
|
|
2
|
+
import { type TurnClassificationContext, type TurnRelationAdvisoryReviewer } from './TurnRelationClassifier.js';
|
|
3
|
+
import type { EpisodeClosureReceipt, MemoryEpisode } from './EpisodeTypes.js';
|
|
4
|
+
import { EpisodeStore } from './EpisodeStore.js';
|
|
5
|
+
export interface EpisodeAssemblyResult {
|
|
6
|
+
episode?: MemoryEpisode;
|
|
7
|
+
assignedEventIds: string[];
|
|
8
|
+
unassignedEventIds: string[];
|
|
9
|
+
ignoredEventIds: string[];
|
|
10
|
+
closureReceipt?: EpisodeClosureReceipt;
|
|
11
|
+
reopened: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class EpisodeAssembler {
|
|
14
|
+
private readonly store;
|
|
15
|
+
private readonly resolveEvent?;
|
|
16
|
+
private readonly softReopenWindowMs;
|
|
17
|
+
private readonly reviewer?;
|
|
18
|
+
private readonly resolveTopicContext?;
|
|
19
|
+
constructor(store: EpisodeStore, resolveEvent?: ((eventId: string) => MemoryEvent | null | undefined) | undefined, softReopenWindowMs?: number, reviewer?: TurnRelationAdvisoryReviewer | undefined, resolveTopicContext?: ((primary: MemoryEvent, episode?: MemoryEpisode) => Partial<TurnClassificationContext>) | undefined);
|
|
20
|
+
appendTurn(events: MemoryEvent[], input: {
|
|
21
|
+
projectId: string;
|
|
22
|
+
sessionId: string;
|
|
23
|
+
sourceAgent?: string;
|
|
24
|
+
conversationThreadId?: string;
|
|
25
|
+
now?: number;
|
|
26
|
+
batchSeal?: boolean;
|
|
27
|
+
forceBatchSeal?: boolean;
|
|
28
|
+
}): EpisodeAssemblyResult;
|
|
29
|
+
appendTurnAsync(events: MemoryEvent[], input: {
|
|
30
|
+
projectId: string;
|
|
31
|
+
sessionId: string;
|
|
32
|
+
sourceAgent?: string;
|
|
33
|
+
conversationThreadId?: string;
|
|
34
|
+
now?: number;
|
|
35
|
+
batchSeal?: boolean;
|
|
36
|
+
forceBatchSeal?: boolean;
|
|
37
|
+
}): Promise<EpisodeAssemblyResult>;
|
|
38
|
+
private appendTurnClassified;
|
|
39
|
+
appendEvent(event: MemoryEvent, input: {
|
|
40
|
+
projectId: string;
|
|
41
|
+
sessionId: string;
|
|
42
|
+
sourceAgent?: string;
|
|
43
|
+
now?: number;
|
|
44
|
+
}): EpisodeAssemblyResult;
|
|
45
|
+
appendEventAsync(event: MemoryEvent, input: {
|
|
46
|
+
projectId: string;
|
|
47
|
+
sessionId: string;
|
|
48
|
+
sourceAgent?: string;
|
|
49
|
+
now?: number;
|
|
50
|
+
}): Promise<EpisodeAssemblyResult>;
|
|
51
|
+
private classificationContext;
|
|
52
|
+
private classifyPrimary;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=EpisodeAssembler.d.ts.map
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { eventTextForMemory } from './CogmemBlockStripper.js';
|
|
2
|
+
import { classifyAssistantRelation, classifyTurnRelation, classifyTurnRelationHybrid } from './TurnRelationClassifier.js';
|
|
3
|
+
export class EpisodeAssembler {
|
|
4
|
+
store;
|
|
5
|
+
resolveEvent;
|
|
6
|
+
softReopenWindowMs;
|
|
7
|
+
reviewer;
|
|
8
|
+
resolveTopicContext;
|
|
9
|
+
constructor(store, resolveEvent, softReopenWindowMs = 30 * 60_000, reviewer, resolveTopicContext) {
|
|
10
|
+
this.store = store;
|
|
11
|
+
this.resolveEvent = resolveEvent;
|
|
12
|
+
this.softReopenWindowMs = softReopenWindowMs;
|
|
13
|
+
this.reviewer = reviewer;
|
|
14
|
+
this.resolveTopicContext = resolveTopicContext;
|
|
15
|
+
}
|
|
16
|
+
appendTurn(events, input) {
|
|
17
|
+
return this.appendTurnClassified(events, input);
|
|
18
|
+
}
|
|
19
|
+
async appendTurnAsync(events, input) {
|
|
20
|
+
const ordered = [...events].sort((a, b) => (a.eventOrdinal || 0) - (b.eventOrdinal || 0));
|
|
21
|
+
if (!ordered.length)
|
|
22
|
+
return { assignedEventIds: [], unassignedEventIds: [], ignoredEventIds: [], reopened: false };
|
|
23
|
+
const primary = ordered.find((event) => event.role === 'user') || ordered[0];
|
|
24
|
+
const threadId = input.conversationThreadId || primary.threadId || input.sessionId;
|
|
25
|
+
const episode = this.store.findActiveEpisode(input.projectId, input.sessionId, input.sourceAgent, threadId);
|
|
26
|
+
const decision = primary.role === 'user'
|
|
27
|
+
? await classifyTurnRelationHybrid(this.classificationContext(primary, episode, ordered), this.reviewer)
|
|
28
|
+
: this.classifyPrimary(primary, episode, ordered);
|
|
29
|
+
return this.appendTurnClassified(ordered, input, decision);
|
|
30
|
+
}
|
|
31
|
+
appendTurnClassified(events, input, decisionOverride) {
|
|
32
|
+
const ordered = [...events].sort((a, b) => (a.eventOrdinal || 0) - (b.eventOrdinal || 0));
|
|
33
|
+
if (!ordered.length)
|
|
34
|
+
return { assignedEventIds: [], unassignedEventIds: [], ignoredEventIds: [], reopened: false };
|
|
35
|
+
const mismatched = ordered.find((event) => event.projectId && event.projectId !== input.projectId);
|
|
36
|
+
if (mismatched)
|
|
37
|
+
throw new Error(`episode_project_mismatch:${mismatched.eventId}`);
|
|
38
|
+
const primary = ordered.find((event) => event.role === 'user') || ordered[0];
|
|
39
|
+
const conversationThreadId = input.conversationThreadId || primary.threadId || input.sessionId;
|
|
40
|
+
let episode = this.store.findActiveEpisode(input.projectId, input.sessionId, input.sourceAgent, conversationThreadId);
|
|
41
|
+
let legacyLinkedEpisodeId;
|
|
42
|
+
if (episode && !episode.sourceAgent && !episode.conversationThreadId) {
|
|
43
|
+
const legacyEpisodeId = episode.episodeId;
|
|
44
|
+
episode = this.store.claimLegacyEpisodeScope(legacyEpisodeId, input.sourceAgent, conversationThreadId);
|
|
45
|
+
if (!episode)
|
|
46
|
+
legacyLinkedEpisodeId = legacyEpisodeId;
|
|
47
|
+
}
|
|
48
|
+
const decision = decisionOverride ?? this.classifyPrimary(primary, episode, ordered);
|
|
49
|
+
let reopened = false;
|
|
50
|
+
let closureReceipt;
|
|
51
|
+
let linkedEpisodeId = legacyLinkedEpisodeId;
|
|
52
|
+
const now = input.now ?? Math.max(...ordered.map((event) => event.occurredAt || Date.now()));
|
|
53
|
+
if (decision.relation === 'noise') {
|
|
54
|
+
for (const event of ordered) {
|
|
55
|
+
this.store.markEventDisposition({
|
|
56
|
+
eventId: event.eventId, projectId: input.projectId, disposition: 'ignored', reason: 'deterministic_noise', now,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return { assignedEventIds: [], unassignedEventIds: [], ignoredEventIds: ordered.map((event) => event.eventId), reopened: false };
|
|
60
|
+
}
|
|
61
|
+
if (episode?.status === 'open' && ['hard_topic_switch', 'starts_new_topic', 'switches_topic'].includes(decision.relation)) {
|
|
62
|
+
closureReceipt = this.store.sealEpisode(episode.episodeId, {
|
|
63
|
+
mode: 'hard', reason: 'explicit_topic_switch', reasonCode: 'topic_switch', now,
|
|
64
|
+
});
|
|
65
|
+
episode = undefined;
|
|
66
|
+
}
|
|
67
|
+
if (episode?.status === 'open' && decision.relation === 'ambiguous_shift') {
|
|
68
|
+
linkedEpisodeId = episode.episodeId;
|
|
69
|
+
closureReceipt = this.store.sealEpisode(episode.episodeId, {
|
|
70
|
+
mode: 'soft', reason: 'ambiguous_topic_shift', reasonCode: 'topic_switch', requiresReview: true, now,
|
|
71
|
+
});
|
|
72
|
+
episode = undefined;
|
|
73
|
+
}
|
|
74
|
+
if (episode?.status === 'soft_sealed') {
|
|
75
|
+
const mayReopen = new Set([
|
|
76
|
+
'continues_previous', 'clarifies_previous', 'corrects_previous', 'returns_to_old_topic',
|
|
77
|
+
'answers_assistant_question', 'accepts_assistant_proposal', 'rejects_assistant_proposal', 'confirms_assistant_fact',
|
|
78
|
+
]).has(decision.relation)
|
|
79
|
+
&& now - (episode.sealedAt || episode.updatedAt) <= this.softReopenWindowMs;
|
|
80
|
+
if (mayReopen) {
|
|
81
|
+
episode = this.store.reopenSoftEpisode(episode.episodeId, now);
|
|
82
|
+
reopened = true;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
episode = undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!episode) {
|
|
89
|
+
episode = this.store.createEpisode({
|
|
90
|
+
projectId: input.projectId, sessionId: input.sessionId, sourceAgent: input.sourceAgent,
|
|
91
|
+
conversationThreadId,
|
|
92
|
+
topicPath: decision.topicPath,
|
|
93
|
+
episodeType: decision.episodeType, importance: decision.importance,
|
|
94
|
+
eventId: primary.eventId, globalSeq: primary.globalSeq, occurredAt: primary.occurredAt || now,
|
|
95
|
+
episodeTags: [decision.episodeType, ...decision.candidateTypes],
|
|
96
|
+
candidateTypes: decision.candidateTypes,
|
|
97
|
+
importanceSignals: decision.importanceSignals,
|
|
98
|
+
importanceReason: decision.rationale,
|
|
99
|
+
linkedEpisodeId,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const assignedEventIds = [];
|
|
103
|
+
for (const event of ordered) {
|
|
104
|
+
const existing = this.store.getEventLink(event.eventId);
|
|
105
|
+
if (existing) {
|
|
106
|
+
assignedEventIds.push(event.eventId);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const relation = event.role === 'assistant' || event.role === 'agent'
|
|
110
|
+
? classifyAssistantRelation(eventText(event), 'assistant')
|
|
111
|
+
: event.role === 'tool'
|
|
112
|
+
? 'tool_result_context'
|
|
113
|
+
: decision.relation;
|
|
114
|
+
this.store.appendEvent({
|
|
115
|
+
episodeId: episode.episodeId, eventId: event.eventId, relation,
|
|
116
|
+
confidence: event.eventId === primary.eventId ? decision.confidence : 0.9,
|
|
117
|
+
globalSeq: event.globalSeq, occurredAt: event.occurredAt || now,
|
|
118
|
+
episodeType: decision.episodeType, importance: decision.importance,
|
|
119
|
+
summaryText: summaryLine(event),
|
|
120
|
+
candidateTypes: decision.candidateTypes,
|
|
121
|
+
importanceSignals: decision.importanceSignals,
|
|
122
|
+
importanceReason: decision.rationale,
|
|
123
|
+
});
|
|
124
|
+
assignedEventIds.push(event.eventId);
|
|
125
|
+
}
|
|
126
|
+
if (input.batchSeal) {
|
|
127
|
+
const confidence = averageConfidence(this.store.listEventLinks(episode.episodeId));
|
|
128
|
+
const requiresReview = !input.forceBatchSeal && confidence < 0.6;
|
|
129
|
+
closureReceipt = this.store.sealEpisode(episode.episodeId, {
|
|
130
|
+
mode: requiresReview ? 'soft' : 'batch', reason: requiresReview ? 'batch_low_confidence_review' : 'batch_boundary',
|
|
131
|
+
reasonCode: 'batch_boundary', requiresReview, now,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
else if (decision.relation === 'closes_episode') {
|
|
135
|
+
closureReceipt = this.store.sealEpisode(episode.episodeId, {
|
|
136
|
+
mode: 'hard', reason: 'explicit_user_closure', reasonCode: 'explicit_user_closure', now,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return { episode: this.store.getEpisode(episode.episodeId), assignedEventIds, unassignedEventIds: [], ignoredEventIds: [], closureReceipt, reopened };
|
|
140
|
+
}
|
|
141
|
+
appendEvent(event, input) {
|
|
142
|
+
const active = this.store.findActiveEpisode(input.projectId, input.sessionId, input.sourceAgent, event.threadId || input.sessionId);
|
|
143
|
+
if (!active && event.role !== 'user') {
|
|
144
|
+
return { assignedEventIds: [], unassignedEventIds: [event.eventId], ignoredEventIds: [], reopened: false };
|
|
145
|
+
}
|
|
146
|
+
return this.appendTurn([event], input);
|
|
147
|
+
}
|
|
148
|
+
async appendEventAsync(event, input) {
|
|
149
|
+
const active = this.store.findActiveEpisode(input.projectId, input.sessionId, input.sourceAgent, event.threadId || input.sessionId);
|
|
150
|
+
if (!active && event.role !== 'user') {
|
|
151
|
+
return { assignedEventIds: [], unassignedEventIds: [event.eventId], ignoredEventIds: [], reopened: false };
|
|
152
|
+
}
|
|
153
|
+
return this.appendTurnAsync([event], input);
|
|
154
|
+
}
|
|
155
|
+
classificationContext(primary, episode, currentEvents = []) {
|
|
156
|
+
const context = {
|
|
157
|
+
currentUserText: eventText(primary),
|
|
158
|
+
activeEpisodeSummary: episode?.semanticSummary?.userPosition || episode?.summary,
|
|
159
|
+
activeEpisodeTopicPath: episode?.topicPath,
|
|
160
|
+
currentAssistantText: currentEvents.find((event) => event.role === 'assistant' || event.role === 'agent')
|
|
161
|
+
? eventText(currentEvents.find((event) => event.role === 'assistant' || event.role === 'agent'))
|
|
162
|
+
: undefined,
|
|
163
|
+
};
|
|
164
|
+
Object.assign(context, this.resolveTopicContext?.(primary, episode) || {});
|
|
165
|
+
if (!episode || !this.resolveEvent)
|
|
166
|
+
return context;
|
|
167
|
+
const prior = this.store.listEventLinks(episode.episodeId)
|
|
168
|
+
.map((link) => this.resolveEvent(link.eventId))
|
|
169
|
+
.filter((event) => Boolean(event));
|
|
170
|
+
const previousUser = [...prior].reverse().find((event) => event.role === 'user');
|
|
171
|
+
const previousAssistant = [...prior].reverse().find((event) => event.role === 'assistant' || event.role === 'agent');
|
|
172
|
+
context.previousUserText = previousUser ? eventText(previousUser) : undefined;
|
|
173
|
+
context.previousAssistantText = previousAssistant ? eventText(previousAssistant) : undefined;
|
|
174
|
+
context.recentRelations = this.store.listEventLinks(episode.episodeId).slice(-5).map((link) => link.relation);
|
|
175
|
+
return context;
|
|
176
|
+
}
|
|
177
|
+
classifyPrimary(primary, episode, currentEvents = []) {
|
|
178
|
+
if (primary.role === 'user')
|
|
179
|
+
return classifyTurnRelation(this.classificationContext(primary, episode, currentEvents));
|
|
180
|
+
return {
|
|
181
|
+
relation: classifyAssistantRelation(eventText(primary), primary.role || 'assistant'),
|
|
182
|
+
confidence: 0.9,
|
|
183
|
+
signals: ['non_user_context_only'],
|
|
184
|
+
needsLlmReview: false,
|
|
185
|
+
candidateTypes: [],
|
|
186
|
+
closureCandidate: false,
|
|
187
|
+
episodeType: 'discussion',
|
|
188
|
+
importance: 0.3,
|
|
189
|
+
importanceSignals: ['non_user_context_only'],
|
|
190
|
+
rationale: 'non_user_event_requires_later_user_evidence',
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function eventText(event) {
|
|
195
|
+
return eventTextForMemory(event);
|
|
196
|
+
}
|
|
197
|
+
function summaryLine(event) {
|
|
198
|
+
const text = eventText(event).replace(/\s+/g, ' ').trim().slice(0, 240);
|
|
199
|
+
return `${event.role || event.rawEventType || 'event'}: ${text}`;
|
|
200
|
+
}
|
|
201
|
+
function averageConfidence(links) {
|
|
202
|
+
return links.length ? links.reduce((total, link) => total + link.confidence, 0) / links.length : 0;
|
|
203
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface StableImportIdentityInput {
|
|
2
|
+
role: string;
|
|
3
|
+
text: string;
|
|
4
|
+
timestamp?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function createStableImportIdentityFactory(sourceAgent: string, sourceSessionId: string): (input: StableImportIdentityInput) => string;
|
|
7
|
+
//# sourceMappingURL=EpisodeImportIdentity.d.ts.map
|