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,33 @@
|
|
|
1
|
+
import type Database from 'bun:sqlite';
|
|
2
|
+
import type { DeepWritePromotionDecision, DeepWritePromotionPolicy } from '../engine/DeepWritePromotionPolicy.js';
|
|
3
|
+
import type { MemoryEvent } from '../types/index.js';
|
|
4
|
+
import type { CandidateReviewAction, CandidateReviewRecord, CandidateReviewStore } from '../store/CandidateReviewStore.js';
|
|
5
|
+
import type { DeepWriteCandidateRecord, DeepWriteCandidateStore } from '../store/DeepWriteCandidateStore.js';
|
|
6
|
+
export interface CandidateReviewInput {
|
|
7
|
+
candidateId: string;
|
|
8
|
+
projectId: string;
|
|
9
|
+
action: CandidateReviewAction;
|
|
10
|
+
actor: string;
|
|
11
|
+
reason: string;
|
|
12
|
+
confirmationEventId?: string;
|
|
13
|
+
targetBeliefId?: string;
|
|
14
|
+
replacementCandidateId?: string;
|
|
15
|
+
reviewAfter?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface CandidateReviewResult {
|
|
18
|
+
review: CandidateReviewRecord;
|
|
19
|
+
candidate: DeepWriteCandidateRecord;
|
|
20
|
+
decision?: DeepWritePromotionDecision;
|
|
21
|
+
}
|
|
22
|
+
export declare class CandidateReviewService {
|
|
23
|
+
private readonly db;
|
|
24
|
+
private readonly candidates;
|
|
25
|
+
private readonly reviews;
|
|
26
|
+
private readonly promotion;
|
|
27
|
+
private readonly eventLookup;
|
|
28
|
+
constructor(db: Database, candidates: DeepWriteCandidateStore, reviews: CandidateReviewStore, promotion: DeepWritePromotionPolicy, eventLookup: (eventId: string) => MemoryEvent | null);
|
|
29
|
+
review(input: CandidateReviewInput): CandidateReviewResult;
|
|
30
|
+
private requireUserConfirmation;
|
|
31
|
+
private requireReplacement;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=CandidateReviewService.d.ts.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export class CandidateReviewService {
|
|
2
|
+
db;
|
|
3
|
+
candidates;
|
|
4
|
+
reviews;
|
|
5
|
+
promotion;
|
|
6
|
+
eventLookup;
|
|
7
|
+
constructor(db, candidates, reviews, promotion, eventLookup) {
|
|
8
|
+
this.db = db;
|
|
9
|
+
this.candidates = candidates;
|
|
10
|
+
this.reviews = reviews;
|
|
11
|
+
this.promotion = promotion;
|
|
12
|
+
this.eventLookup = eventLookup;
|
|
13
|
+
}
|
|
14
|
+
review(input) {
|
|
15
|
+
return this.db.transaction(() => {
|
|
16
|
+
const actor = required(input.actor, 'actor');
|
|
17
|
+
const reason = required(input.reason, 'reason');
|
|
18
|
+
const candidate = this.candidates.getCandidate(required(input.candidateId, 'candidateId'));
|
|
19
|
+
if (!candidate)
|
|
20
|
+
throw new Error('candidate_not_found');
|
|
21
|
+
const run = this.candidates.getRun(candidate.runId);
|
|
22
|
+
if (!run || run.projectId !== input.projectId)
|
|
23
|
+
throw new Error('candidate_project_mismatch');
|
|
24
|
+
if (candidate.status !== 'needs_confirmation')
|
|
25
|
+
throw new Error('candidate_not_awaiting_confirmation');
|
|
26
|
+
const fromStatus = candidate.status;
|
|
27
|
+
let decision;
|
|
28
|
+
if (input.action === 'reject') {
|
|
29
|
+
this.candidates.updateCandidateStatus(candidate.candidateId, 'rejected', { reason: `manual_review_rejected:${reason}` });
|
|
30
|
+
}
|
|
31
|
+
else if (input.action === 'defer') {
|
|
32
|
+
if (!Number.isFinite(input.reviewAfter) || Number(input.reviewAfter) <= Date.now()) {
|
|
33
|
+
throw new Error('review_after_must_be_in_the_future');
|
|
34
|
+
}
|
|
35
|
+
this.candidates.updateCandidateStatus(candidate.candidateId, 'needs_confirmation', {
|
|
36
|
+
reason: `manual_review_deferred:${reason}`,
|
|
37
|
+
reviewAfter: input.reviewAfter,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else if (input.action === 'supersede') {
|
|
41
|
+
if (input.replacementCandidateId)
|
|
42
|
+
this.requireReplacement(input.replacementCandidateId, input.projectId);
|
|
43
|
+
this.candidates.updateCandidateStatus(candidate.candidateId, 'superseded', {
|
|
44
|
+
type: input.replacementCandidateId ? 'replacement_candidate' : 'manual_review',
|
|
45
|
+
id: input.replacementCandidateId || candidate.candidateId,
|
|
46
|
+
reason: `manual_review_superseded:${reason}`,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const confirmation = this.requireUserConfirmation(input.confirmationEventId, input.projectId);
|
|
51
|
+
let content = asObject(candidate.content);
|
|
52
|
+
let targetType = candidate.promotionTargetType;
|
|
53
|
+
let targetId = candidate.promotionTargetId;
|
|
54
|
+
if (input.action === 'relink') {
|
|
55
|
+
if (candidate.candidateType !== 'correction')
|
|
56
|
+
throw new Error('relink_requires_correction_candidate');
|
|
57
|
+
const belief = this.db.prepare(`SELECT id, canonical_key, project_id, status FROM beliefs WHERE id=?`).get(input.targetBeliefId || '');
|
|
58
|
+
if (!belief || belief.project_id !== input.projectId || belief.status !== 'active') {
|
|
59
|
+
throw new Error('target_belief_not_active_in_project');
|
|
60
|
+
}
|
|
61
|
+
content = { ...content, targetBeliefId: belief.id, correctedClaimKey: belief.canonical_key };
|
|
62
|
+
targetType = 'belief';
|
|
63
|
+
targetId = belief.id;
|
|
64
|
+
}
|
|
65
|
+
const evidence = appendConfirmationEvidence(candidate.evidence, confirmation.eventId);
|
|
66
|
+
this.candidates.updateCandidateReviewData(candidate.candidateId, {
|
|
67
|
+
content,
|
|
68
|
+
evidence,
|
|
69
|
+
promotionTargetType: targetType,
|
|
70
|
+
promotionTargetId: targetId,
|
|
71
|
+
status: 'candidate',
|
|
72
|
+
statusReason: `manual_review_${input.action}:${reason}`,
|
|
73
|
+
});
|
|
74
|
+
decision = this.promotion.evaluateAndApply(this.candidates.getCandidate(candidate.candidateId), { reviewConfirmed: true });
|
|
75
|
+
}
|
|
76
|
+
const reviewed = this.candidates.getCandidate(candidate.candidateId);
|
|
77
|
+
const review = this.reviews.insert({
|
|
78
|
+
candidateId: candidate.candidateId,
|
|
79
|
+
projectId: input.projectId,
|
|
80
|
+
action: input.action,
|
|
81
|
+
actor,
|
|
82
|
+
reason,
|
|
83
|
+
fromStatus,
|
|
84
|
+
toStatus: reviewed.status,
|
|
85
|
+
confirmationEventId: input.confirmationEventId,
|
|
86
|
+
targetBeliefId: input.targetBeliefId,
|
|
87
|
+
replacementCandidateId: input.replacementCandidateId,
|
|
88
|
+
reviewAfter: input.reviewAfter,
|
|
89
|
+
decision: decision ? { ...decision } : {},
|
|
90
|
+
});
|
|
91
|
+
return { review, candidate: reviewed, decision };
|
|
92
|
+
})();
|
|
93
|
+
}
|
|
94
|
+
requireUserConfirmation(eventId, projectId) {
|
|
95
|
+
if (!eventId)
|
|
96
|
+
throw new Error('confirmation_event_required');
|
|
97
|
+
const event = this.eventLookup(eventId);
|
|
98
|
+
if (!event)
|
|
99
|
+
throw new Error('confirmation_event_not_found');
|
|
100
|
+
if (event.projectId !== projectId)
|
|
101
|
+
throw new Error('confirmation_event_project_mismatch');
|
|
102
|
+
if (event.role !== 'user')
|
|
103
|
+
throw new Error('confirmation_event_must_be_user');
|
|
104
|
+
return event;
|
|
105
|
+
}
|
|
106
|
+
requireReplacement(candidateId, projectId) {
|
|
107
|
+
const replacement = this.candidates.getCandidate(candidateId);
|
|
108
|
+
const run = replacement ? this.candidates.getRun(replacement.runId) : null;
|
|
109
|
+
if (!replacement || run?.projectId !== projectId)
|
|
110
|
+
throw new Error('replacement_candidate_project_mismatch');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function appendConfirmationEvidence(value, eventId) {
|
|
114
|
+
const evidence = Array.isArray(value) ? [...value] : [];
|
|
115
|
+
if (!evidence.some((item) => asObject(item).eventId === eventId))
|
|
116
|
+
evidence.push({ eventId, role: 'user', source: 'manual_review_confirmation' });
|
|
117
|
+
return evidence;
|
|
118
|
+
}
|
|
119
|
+
function asObject(value) {
|
|
120
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
121
|
+
}
|
|
122
|
+
function required(value, field) {
|
|
123
|
+
if (!value?.trim())
|
|
124
|
+
throw new Error(`${field}_required`);
|
|
125
|
+
return value.trim();
|
|
126
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CredibilityScorer } from './CredibilityScorer.js';
|
|
2
|
+
export type ContradictionVerdict = 'new_wins' | 'old_wins' | 'contradiction_pending';
|
|
3
|
+
export type ContradictionStrategy = 'credibility_wins' | 'recency_wins' | 'evidence_wins';
|
|
4
|
+
type FactLike = {
|
|
5
|
+
sourceType?: string;
|
|
6
|
+
evidenceCount?: number;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
predicateValue: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class ContradictionResolver {
|
|
11
|
+
private scorer;
|
|
12
|
+
private readonly defaultStrategy;
|
|
13
|
+
constructor(scorer: CredibilityScorer, defaultStrategy?: ContradictionStrategy);
|
|
14
|
+
resolve(params: {
|
|
15
|
+
newFact: FactLike;
|
|
16
|
+
existingFact: FactLike;
|
|
17
|
+
strategy?: ContradictionStrategy;
|
|
18
|
+
}): ContradictionVerdict;
|
|
19
|
+
}
|
|
20
|
+
export declare function assertContradictionStrategy(value: unknown): asserts value is ContradictionStrategy;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=ContradictionResolver.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export class ContradictionResolver {
|
|
2
|
+
scorer;
|
|
3
|
+
defaultStrategy;
|
|
4
|
+
constructor(scorer, defaultStrategy = 'credibility_wins') {
|
|
5
|
+
this.scorer = scorer;
|
|
6
|
+
this.defaultStrategy = defaultStrategy;
|
|
7
|
+
assertContradictionStrategy(defaultStrategy);
|
|
8
|
+
}
|
|
9
|
+
resolve(params) {
|
|
10
|
+
const strategy = params.strategy ?? this.defaultStrategy;
|
|
11
|
+
assertContradictionStrategy(strategy);
|
|
12
|
+
if (params.newFact.predicateValue === params.existingFact.predicateValue) {
|
|
13
|
+
return 'contradiction_pending';
|
|
14
|
+
}
|
|
15
|
+
if (strategy === 'recency_wins') {
|
|
16
|
+
if (params.newFact.createdAt > params.existingFact.createdAt)
|
|
17
|
+
return 'new_wins';
|
|
18
|
+
if (params.existingFact.createdAt > params.newFact.createdAt)
|
|
19
|
+
return 'old_wins';
|
|
20
|
+
return 'contradiction_pending';
|
|
21
|
+
}
|
|
22
|
+
if (strategy === 'evidence_wins') {
|
|
23
|
+
const newEvidence = params.newFact.evidenceCount ?? 0;
|
|
24
|
+
const oldEvidence = params.existingFact.evidenceCount ?? 0;
|
|
25
|
+
if (newEvidence > oldEvidence)
|
|
26
|
+
return 'new_wins';
|
|
27
|
+
if (oldEvidence > newEvidence)
|
|
28
|
+
return 'old_wins';
|
|
29
|
+
return 'contradiction_pending';
|
|
30
|
+
}
|
|
31
|
+
const now = Date.now();
|
|
32
|
+
const newScore = this.scorer.scoreForFact({
|
|
33
|
+
sourceType: params.newFact.sourceType,
|
|
34
|
+
evidenceCount: params.newFact.evidenceCount,
|
|
35
|
+
recencyMs: Math.max(0, now - params.newFact.createdAt)
|
|
36
|
+
});
|
|
37
|
+
const oldScore = this.scorer.scoreForFact({
|
|
38
|
+
sourceType: params.existingFact.sourceType,
|
|
39
|
+
evidenceCount: params.existingFact.evidenceCount,
|
|
40
|
+
recencyMs: Math.max(0, now - params.existingFact.createdAt)
|
|
41
|
+
});
|
|
42
|
+
if (newScore > oldScore + 0.05)
|
|
43
|
+
return 'new_wins';
|
|
44
|
+
if (oldScore > newScore + 0.05)
|
|
45
|
+
return 'old_wins';
|
|
46
|
+
return 'contradiction_pending';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function assertContradictionStrategy(value) {
|
|
50
|
+
if (value === 'credibility_wins' || value === 'recency_wins' || value === 'evidence_wins') {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`Invalid contradictionStrategy: ${String(value)}. Expected credibility_wins, recency_wins, or evidence_wins.`);
|
|
54
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const SOURCE_CREDIBILITY: Record<string, number>;
|
|
2
|
+
export declare class CredibilityScorer {
|
|
3
|
+
score(sourceType: string): number;
|
|
4
|
+
scoreForFact(fact: {
|
|
5
|
+
sourceType?: string;
|
|
6
|
+
evidenceCount?: number;
|
|
7
|
+
recencyMs?: number;
|
|
8
|
+
}): number;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=CredibilityScorer.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
2
|
+
export const SOURCE_CREDIBILITY = {
|
|
3
|
+
user_direct: 1.0,
|
|
4
|
+
agent_finding: 0.8,
|
|
5
|
+
web_fetch_official: 0.7,
|
|
6
|
+
file_read: 0.6,
|
|
7
|
+
web_fetch_general: 0.5,
|
|
8
|
+
agent_observation: 0.4,
|
|
9
|
+
shell_exec_output: 0.3
|
|
10
|
+
};
|
|
11
|
+
export class CredibilityScorer {
|
|
12
|
+
score(sourceType) {
|
|
13
|
+
return SOURCE_CREDIBILITY[sourceType] ?? 0.5;
|
|
14
|
+
}
|
|
15
|
+
scoreForFact(fact) {
|
|
16
|
+
const baseCredibility = this.score(fact.sourceType || '');
|
|
17
|
+
const evidenceCount = Math.max(0, fact.evidenceCount ?? 0);
|
|
18
|
+
const evidenceMultiplier = Math.min(1 + evidenceCount * 0.05, 1.5);
|
|
19
|
+
const recencyMs = Math.max(0, fact.recencyMs ?? Number.MAX_SAFE_INTEGER);
|
|
20
|
+
const recencyFactor = recencyMs < DAY_MS
|
|
21
|
+
? 1.0
|
|
22
|
+
: recencyMs < 7 * DAY_MS
|
|
23
|
+
? 0.95
|
|
24
|
+
: recencyMs < 30 * DAY_MS
|
|
25
|
+
? 0.85
|
|
26
|
+
: 0.7;
|
|
27
|
+
return baseCredibility * evidenceMultiplier * recencyFactor;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class DecayPolicy {
|
|
2
|
+
private options;
|
|
3
|
+
private readonly decayThresholdDays;
|
|
4
|
+
private readonly decayFactor;
|
|
5
|
+
private readonly minWeight;
|
|
6
|
+
constructor(options?: {
|
|
7
|
+
decayThresholdDays?: number;
|
|
8
|
+
decayFactor?: number;
|
|
9
|
+
minWeight?: number;
|
|
10
|
+
});
|
|
11
|
+
computeWeight(params: {
|
|
12
|
+
baseWeight?: number;
|
|
13
|
+
lastAccessedAt: number;
|
|
14
|
+
now?: number;
|
|
15
|
+
}): number;
|
|
16
|
+
isExcluded(weight: number): boolean;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=DecayPolicy.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
2
|
+
export class DecayPolicy {
|
|
3
|
+
options;
|
|
4
|
+
decayThresholdDays;
|
|
5
|
+
decayFactor;
|
|
6
|
+
minWeight;
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.decayThresholdDays = options.decayThresholdDays ?? 30;
|
|
10
|
+
this.decayFactor = options.decayFactor ?? 0.8;
|
|
11
|
+
this.minWeight = options.minWeight ?? 0.1;
|
|
12
|
+
}
|
|
13
|
+
computeWeight(params) {
|
|
14
|
+
const now = params.now ?? Date.now();
|
|
15
|
+
const baseWeight = params.baseWeight ?? 1.0;
|
|
16
|
+
const elapsedMs = Math.max(0, now - params.lastAccessedAt);
|
|
17
|
+
if (elapsedMs < DAY_MS) {
|
|
18
|
+
return Math.max(baseWeight, this.minWeight);
|
|
19
|
+
}
|
|
20
|
+
const elapsedDays = elapsedMs / DAY_MS;
|
|
21
|
+
const periods = elapsedDays / this.decayThresholdDays;
|
|
22
|
+
const weight = baseWeight * (this.decayFactor ** periods);
|
|
23
|
+
return Math.max(weight, this.minWeight);
|
|
24
|
+
}
|
|
25
|
+
isExcluded(weight) {
|
|
26
|
+
return weight < this.minWeight;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type Database from 'bun:sqlite';
|
|
2
|
+
import { CredibilityScorer } from './CredibilityScorer.js';
|
|
3
|
+
import { DecayPolicy } from './DecayPolicy.js';
|
|
4
|
+
import { type SupersedeRecord } from './SupersedeChain.js';
|
|
5
|
+
export declare class MemoryExplain {
|
|
6
|
+
private db;
|
|
7
|
+
private scorer;
|
|
8
|
+
private decay;
|
|
9
|
+
private readonly chain;
|
|
10
|
+
constructor(db: Database, scorer: CredibilityScorer, decay: DecayPolicy);
|
|
11
|
+
explainRecall(params: {
|
|
12
|
+
query: string;
|
|
13
|
+
recalled: Array<{
|
|
14
|
+
factId: string;
|
|
15
|
+
content: string;
|
|
16
|
+
sourceType?: string;
|
|
17
|
+
lastAccessedAt?: number;
|
|
18
|
+
}>;
|
|
19
|
+
excluded: Array<{
|
|
20
|
+
factId: string;
|
|
21
|
+
content: string;
|
|
22
|
+
reason: 'decayed' | 'superseded' | 'low_credibility';
|
|
23
|
+
}>;
|
|
24
|
+
}): {
|
|
25
|
+
included: Array<{
|
|
26
|
+
factId: string;
|
|
27
|
+
reason: string;
|
|
28
|
+
credibilityScore: number;
|
|
29
|
+
weight: number;
|
|
30
|
+
}>;
|
|
31
|
+
excluded: Array<{
|
|
32
|
+
factId: string;
|
|
33
|
+
reason: string;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
explainFact(factId: string): {
|
|
37
|
+
factId: string;
|
|
38
|
+
credibilityScore: number;
|
|
39
|
+
currentWeight: number;
|
|
40
|
+
status: string;
|
|
41
|
+
supersedeChain: SupersedeRecord[];
|
|
42
|
+
lastAccessedAt?: number;
|
|
43
|
+
sourceType?: string;
|
|
44
|
+
} | null;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=MemoryExplain.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { SupersedeChain } from './SupersedeChain.js';
|
|
2
|
+
export class MemoryExplain {
|
|
3
|
+
db;
|
|
4
|
+
scorer;
|
|
5
|
+
decay;
|
|
6
|
+
chain;
|
|
7
|
+
constructor(db, scorer, decay) {
|
|
8
|
+
this.db = db;
|
|
9
|
+
this.scorer = scorer;
|
|
10
|
+
this.decay = decay;
|
|
11
|
+
this.chain = new SupersedeChain(db);
|
|
12
|
+
}
|
|
13
|
+
explainRecall(params) {
|
|
14
|
+
return {
|
|
15
|
+
included: params.recalled.map((fact) => {
|
|
16
|
+
const credibilityScore = this.scorer.score(fact.sourceType || '');
|
|
17
|
+
const lastAccessedAt = fact.lastAccessedAt ?? Date.now();
|
|
18
|
+
const weight = this.decay.computeWeight({ lastAccessedAt, now: Date.now() });
|
|
19
|
+
return {
|
|
20
|
+
factId: fact.factId,
|
|
21
|
+
reason: `matched query "${params.query}" and passed governance filters`,
|
|
22
|
+
credibilityScore,
|
|
23
|
+
weight
|
|
24
|
+
};
|
|
25
|
+
}),
|
|
26
|
+
excluded: params.excluded.map((fact) => ({
|
|
27
|
+
factId: fact.factId,
|
|
28
|
+
reason: fact.reason
|
|
29
|
+
}))
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
explainFact(factId) {
|
|
33
|
+
const row = this.db.prepare(`
|
|
34
|
+
SELECT fact_id, valid_from, metadata_json
|
|
35
|
+
FROM facts
|
|
36
|
+
WHERE fact_id = ?
|
|
37
|
+
`).get(factId);
|
|
38
|
+
if (!row)
|
|
39
|
+
return null;
|
|
40
|
+
const metadata = row.metadata_json ? JSON.parse(row.metadata_json) : {};
|
|
41
|
+
const sourceType = typeof metadata.sourceType === 'string' ? metadata.sourceType : undefined;
|
|
42
|
+
const evidenceCount = typeof metadata.evidenceCount === 'number' ? metadata.evidenceCount : undefined;
|
|
43
|
+
const lastAccessedAt = this.chain.getLastAccessedAt(factId);
|
|
44
|
+
const status = this.chain.getStatus(factId)?.status ?? 'canonical';
|
|
45
|
+
return {
|
|
46
|
+
factId,
|
|
47
|
+
credibilityScore: this.scorer.scoreForFact({
|
|
48
|
+
sourceType,
|
|
49
|
+
evidenceCount,
|
|
50
|
+
recencyMs: Math.max(0, Date.now() - row.valid_from)
|
|
51
|
+
}),
|
|
52
|
+
currentWeight: this.decay.computeWeight({
|
|
53
|
+
lastAccessedAt: lastAccessedAt ?? row.valid_from,
|
|
54
|
+
now: Date.now()
|
|
55
|
+
}),
|
|
56
|
+
status,
|
|
57
|
+
supersedeChain: this.chain.getChain(factId),
|
|
58
|
+
lastAccessedAt,
|
|
59
|
+
sourceType
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Database from 'bun:sqlite';
|
|
2
|
+
import { MemoryGovernanceStore } from '../store/MemoryGovernanceStore.js';
|
|
3
|
+
import type { MemoryGovernanceExecutionResult, MemoryGovernanceOperation, MemoryGovernanceOperationType, MemoryGovernancePlan } from './MemoryGovernancePlan.js';
|
|
4
|
+
import { MemoryGovernanceValidator } from './MemoryGovernanceValidator.js';
|
|
5
|
+
export interface MemoryGovernanceExecutionContext {
|
|
6
|
+
db: Database;
|
|
7
|
+
plan: MemoryGovernancePlan;
|
|
8
|
+
}
|
|
9
|
+
export type MemoryGovernanceOperationHandler = (operation: MemoryGovernanceOperation, context: MemoryGovernanceExecutionContext) => void;
|
|
10
|
+
export declare class MemoryGovernanceExecutor {
|
|
11
|
+
private readonly db;
|
|
12
|
+
private readonly store;
|
|
13
|
+
private readonly validator;
|
|
14
|
+
private readonly handlers;
|
|
15
|
+
constructor(db: Database, store: MemoryGovernanceStore, validator: MemoryGovernanceValidator, handlers?: Partial<Record<MemoryGovernanceOperationType, MemoryGovernanceOperationHandler>>);
|
|
16
|
+
execute(plan: MemoryGovernancePlan): MemoryGovernanceExecutionResult;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=MemoryGovernanceExecutor.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class MemoryGovernanceExecutor {
|
|
2
|
+
db;
|
|
3
|
+
store;
|
|
4
|
+
validator;
|
|
5
|
+
handlers;
|
|
6
|
+
constructor(db, store, validator, handlers = {}) {
|
|
7
|
+
this.db = db;
|
|
8
|
+
this.store = store;
|
|
9
|
+
this.validator = validator;
|
|
10
|
+
this.handlers = handlers;
|
|
11
|
+
}
|
|
12
|
+
execute(plan) {
|
|
13
|
+
if (this.store.isPlanApplied(plan.planId)) {
|
|
14
|
+
return { planId: plan.planId, status: 'already_applied', appliedOperationIds: this.store.listAppliedOperations(plan.planId) };
|
|
15
|
+
}
|
|
16
|
+
const validation = this.validator.validate(plan);
|
|
17
|
+
if (!validation.valid) {
|
|
18
|
+
throw new Error(`Memory governance plan rejected: ${validation.issues.map((issue) => issue.code).join(', ')}`);
|
|
19
|
+
}
|
|
20
|
+
const appliedOperationIds = [];
|
|
21
|
+
const transaction = this.db.transaction(() => {
|
|
22
|
+
for (const operation of plan.operations) {
|
|
23
|
+
if (this.store.isOperationApplied(operation.idempotencyKey))
|
|
24
|
+
continue;
|
|
25
|
+
const handler = this.handlers[operation.type];
|
|
26
|
+
if (!handler)
|
|
27
|
+
throw new Error(`unsupported_governance_operation:${operation.type}`);
|
|
28
|
+
handler(operation, { db: this.db, plan });
|
|
29
|
+
this.store.recordOperation(plan, operation);
|
|
30
|
+
appliedOperationIds.push(operation.operationId);
|
|
31
|
+
}
|
|
32
|
+
this.store.recordPlan(plan);
|
|
33
|
+
});
|
|
34
|
+
transaction();
|
|
35
|
+
return { planId: plan.planId, status: 'applied', appliedOperationIds };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type MemoryGovernanceOperationType = 'BIND_EVENT' | 'RECLASSIFY_TOPIC' | 'MERGE_CLUSTER' | 'SPLIT_CLUSTER' | 'LINK_ENTITY_ALIAS' | 'MERGE_ENTITY' | 'CREATE_BELIEF' | 'REINFORCE_BELIEF' | 'SUPERSEDE_BELIEF' | 'REJECT_BELIEF' | 'CREATE_TIME_ANCHOR' | 'EXPIRE_TIME_ANCHOR' | 'CREATE_PROSPECTIVE_MEMORY' | 'RESOLVE_PROSPECTIVE_MEMORY';
|
|
2
|
+
export type MemoryEvidenceRole = 'user' | 'assistant' | 'tool' | 'system';
|
|
3
|
+
export type MemoryOwnership = 'user' | 'project' | 'system';
|
|
4
|
+
export interface MemoryGovernanceOperation {
|
|
5
|
+
operationId: string;
|
|
6
|
+
type: MemoryGovernanceOperationType;
|
|
7
|
+
projectId?: string;
|
|
8
|
+
evidenceEventIds: string[];
|
|
9
|
+
sourceRole: MemoryEvidenceRole;
|
|
10
|
+
ownership: MemoryOwnership;
|
|
11
|
+
expectedVersion?: number;
|
|
12
|
+
idempotencyKey: string;
|
|
13
|
+
payload: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface MemoryGovernancePlan {
|
|
16
|
+
planId: string;
|
|
17
|
+
projectId?: string;
|
|
18
|
+
proposedBy: 'deterministic' | 'model_candidate' | 'operator';
|
|
19
|
+
createdAt: number;
|
|
20
|
+
operations: MemoryGovernanceOperation[];
|
|
21
|
+
}
|
|
22
|
+
export interface MemoryGovernanceIssue {
|
|
23
|
+
code: string;
|
|
24
|
+
message: string;
|
|
25
|
+
operationId?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface MemoryGovernanceValidationResult {
|
|
28
|
+
valid: boolean;
|
|
29
|
+
issues: MemoryGovernanceIssue[];
|
|
30
|
+
}
|
|
31
|
+
export interface MemoryGovernanceExecutionResult {
|
|
32
|
+
planId: string;
|
|
33
|
+
status: 'applied' | 'already_applied';
|
|
34
|
+
appliedOperationIds: string[];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=MemoryGovernancePlan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MemoryEvidenceRole, MemoryGovernancePlan, MemoryGovernanceValidationResult } from './MemoryGovernancePlan.js';
|
|
2
|
+
export interface GovernanceEvidenceRecord {
|
|
3
|
+
eventId: string;
|
|
4
|
+
projectId?: string;
|
|
5
|
+
role?: MemoryEvidenceRole | string;
|
|
6
|
+
}
|
|
7
|
+
export type GovernanceEvidenceLookup = (eventId: string) => GovernanceEvidenceRecord | undefined;
|
|
8
|
+
export declare class MemoryGovernanceValidator {
|
|
9
|
+
private readonly findEvidence;
|
|
10
|
+
constructor(findEvidence: GovernanceEvidenceLookup);
|
|
11
|
+
validate(plan: MemoryGovernancePlan): MemoryGovernanceValidationResult;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=MemoryGovernanceValidator.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export class MemoryGovernanceValidator {
|
|
2
|
+
findEvidence;
|
|
3
|
+
constructor(findEvidence) {
|
|
4
|
+
this.findEvidence = findEvidence;
|
|
5
|
+
}
|
|
6
|
+
validate(plan) {
|
|
7
|
+
const issues = [];
|
|
8
|
+
const operationIds = new Set();
|
|
9
|
+
const idempotencyKeys = new Set();
|
|
10
|
+
if (!plan.planId.trim())
|
|
11
|
+
issues.push({ code: 'missing_plan_id', message: 'planId is required.' });
|
|
12
|
+
if (plan.operations.length === 0)
|
|
13
|
+
issues.push({ code: 'empty_plan', message: 'At least one operation is required.' });
|
|
14
|
+
for (const operation of plan.operations) {
|
|
15
|
+
if (!operation.operationId.trim()) {
|
|
16
|
+
issues.push({ code: 'missing_operation_id', message: 'operationId is required.' });
|
|
17
|
+
}
|
|
18
|
+
else if (operationIds.has(operation.operationId)) {
|
|
19
|
+
issues.push({ code: 'duplicate_operation_id', message: 'operationId must be unique.', operationId: operation.operationId });
|
|
20
|
+
}
|
|
21
|
+
operationIds.add(operation.operationId);
|
|
22
|
+
if (!operation.idempotencyKey.trim()) {
|
|
23
|
+
issues.push({ code: 'missing_idempotency_key', message: 'idempotencyKey is required.', operationId: operation.operationId });
|
|
24
|
+
}
|
|
25
|
+
else if (idempotencyKeys.has(operation.idempotencyKey)) {
|
|
26
|
+
issues.push({ code: 'duplicate_idempotency_key', message: 'idempotencyKey must be unique inside a plan.', operationId: operation.operationId });
|
|
27
|
+
}
|
|
28
|
+
idempotencyKeys.add(operation.idempotencyKey);
|
|
29
|
+
if (operation.evidenceEventIds.length === 0) {
|
|
30
|
+
issues.push({ code: 'missing_evidence', message: 'Durable operations require raw event evidence.', operationId: operation.operationId });
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const evidence = operation.evidenceEventIds.map((eventId) => this.findEvidence(eventId));
|
|
34
|
+
if (evidence.some((record) => !record)) {
|
|
35
|
+
issues.push({ code: 'unknown_evidence', message: 'Every evidence event must exist in the Raw Ledger.', operationId: operation.operationId });
|
|
36
|
+
}
|
|
37
|
+
if (operation.projectId && evidence.some((record) => record?.projectId && record.projectId !== operation.projectId)) {
|
|
38
|
+
issues.push({ code: 'project_boundary_violation', message: 'Evidence must remain inside the operation project.', operationId: operation.operationId });
|
|
39
|
+
}
|
|
40
|
+
if (operation.ownership === 'user' && !evidence.some((record) => record?.role === 'user')) {
|
|
41
|
+
issues.push({
|
|
42
|
+
code: 'user_ownership_requires_user_evidence',
|
|
43
|
+
message: 'User-owned memory requires at least one explicit user event.',
|
|
44
|
+
operationId: operation.operationId,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (operation.expectedVersion !== undefined && (!Number.isInteger(operation.expectedVersion) || operation.expectedVersion < 0)) {
|
|
48
|
+
issues.push({ code: 'invalid_expected_version', message: 'expectedVersion must be a non-negative integer.', operationId: operation.operationId });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { valid: issues.length === 0, issues };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface HygieneRule {
|
|
2
|
+
id: string;
|
|
3
|
+
description: string;
|
|
4
|
+
check(content: string, meta: {
|
|
5
|
+
sourceType?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
}): boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const HYGIENE_RULES: HygieneRule[];
|
|
10
|
+
export declare function applyHygieneRules(content: string, meta: {
|
|
11
|
+
sourceType?: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
}, rules?: HygieneRule[]): {
|
|
14
|
+
shouldFilter: boolean;
|
|
15
|
+
triggeredRule?: string;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=ObservationHygieneRules.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const HYGIENE_RULES = [
|
|
2
|
+
{
|
|
3
|
+
id: 'empty_content',
|
|
4
|
+
description: 'Filter empty or whitespace-only content',
|
|
5
|
+
check: (content) => content.trim().length === 0
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
id: 'duplicate_noise',
|
|
9
|
+
description: 'Filter content that is only repeated characters',
|
|
10
|
+
check: (content) => /^(.)\1{9,}$/.test(content.trim())
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: 'shell_noise',
|
|
14
|
+
description: 'Filter shell outputs that are only exit codes or prompts',
|
|
15
|
+
check: (content, meta) => meta.sourceType === 'shell_exec_output' && /^(\$\s*|>\s*|exit\s*\d*\s*)$/.test(content.trim())
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'low_information_web',
|
|
19
|
+
description: 'Filter web content shorter than 20 chars that is likely a redirect or error page',
|
|
20
|
+
check: (content, meta) => meta.sourceType === 'web_fetch_general' && content.trim().length < 20
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
export function applyHygieneRules(content, meta, rules = HYGIENE_RULES) {
|
|
24
|
+
const triggered = rules.find((rule) => rule.check(content, meta));
|
|
25
|
+
return triggered
|
|
26
|
+
? { shouldFilter: true, triggeredRule: triggered.id }
|
|
27
|
+
: { shouldFilter: false };
|
|
28
|
+
}
|