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,62 @@
|
|
|
1
|
+
import Database from 'bun:sqlite';
|
|
2
|
+
export type TimelineEntryType = 'milestone' | 'decision' | 'correction' | 'belief_version';
|
|
3
|
+
export interface TimelineEntryRecord {
|
|
4
|
+
entryId: string;
|
|
5
|
+
projectId?: string;
|
|
6
|
+
entryType: TimelineEntryType;
|
|
7
|
+
canonicalKey?: string;
|
|
8
|
+
entityId?: string;
|
|
9
|
+
beliefId?: string;
|
|
10
|
+
title: string;
|
|
11
|
+
summary?: string;
|
|
12
|
+
reason?: string;
|
|
13
|
+
occurredAt: number;
|
|
14
|
+
evidenceEventIds: string[];
|
|
15
|
+
createdAt: number;
|
|
16
|
+
}
|
|
17
|
+
export interface RecordTimelineEntryInput {
|
|
18
|
+
projectId?: string;
|
|
19
|
+
entryType: TimelineEntryType;
|
|
20
|
+
canonicalKey?: string;
|
|
21
|
+
entityId?: string;
|
|
22
|
+
beliefId?: string;
|
|
23
|
+
title: string;
|
|
24
|
+
summary?: string;
|
|
25
|
+
reason?: string;
|
|
26
|
+
occurredAt?: number;
|
|
27
|
+
evidenceEventIds: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface TimelineListOptions {
|
|
30
|
+
projectId?: string;
|
|
31
|
+
canonicalKey?: string;
|
|
32
|
+
entityId?: string;
|
|
33
|
+
entryTypes?: TimelineEntryType[];
|
|
34
|
+
startTime?: number;
|
|
35
|
+
endTime?: number;
|
|
36
|
+
limit?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface TemporalBeliefRecord {
|
|
39
|
+
beliefId: string;
|
|
40
|
+
projectId?: string;
|
|
41
|
+
canonicalKey: string;
|
|
42
|
+
statement: string;
|
|
43
|
+
status: string;
|
|
44
|
+
version: number;
|
|
45
|
+
validFrom: number;
|
|
46
|
+
validTo?: number;
|
|
47
|
+
supersedesBeliefId?: string;
|
|
48
|
+
supersededByBeliefId?: string;
|
|
49
|
+
}
|
|
50
|
+
export declare class TemporalMemoryService {
|
|
51
|
+
private readonly db;
|
|
52
|
+
constructor(db: Database);
|
|
53
|
+
record(input: RecordTimelineEntryInput): TimelineEntryRecord;
|
|
54
|
+
get(entryId: string): TimelineEntryRecord | null;
|
|
55
|
+
list(options?: TimelineListOptions): TimelineEntryRecord[];
|
|
56
|
+
getBeliefAt(projectId: string | undefined, canonicalKey: string, atTime: number): TemporalBeliefRecord | null;
|
|
57
|
+
getBeliefHistory(projectId: string | undefined, canonicalKey: string): TemporalBeliefRecord[];
|
|
58
|
+
private mapTimelineRow;
|
|
59
|
+
private mapBeliefRow;
|
|
60
|
+
private initializeSchema;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=TemporalMemoryService.d.ts.map
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
export class TemporalMemoryService {
|
|
3
|
+
db;
|
|
4
|
+
constructor(db) {
|
|
5
|
+
this.db = db;
|
|
6
|
+
this.initializeSchema();
|
|
7
|
+
}
|
|
8
|
+
record(input) {
|
|
9
|
+
const title = input.title.trim();
|
|
10
|
+
if (!title)
|
|
11
|
+
throw new Error('timeline_title_required');
|
|
12
|
+
const now = Date.now();
|
|
13
|
+
const occurredAt = input.occurredAt ?? now;
|
|
14
|
+
const entryId = `timeline-${randomUUID()}`;
|
|
15
|
+
this.db.prepare(`
|
|
16
|
+
INSERT INTO memory_timeline_entries (
|
|
17
|
+
entry_id, project_id, entry_type, canonical_key, entity_id, belief_id,
|
|
18
|
+
title, summary, reason, occurred_at, evidence_event_ids_json, created_at
|
|
19
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
20
|
+
`).run(entryId, input.projectId ?? null, input.entryType, input.canonicalKey?.trim().toLowerCase() ?? null, input.entityId ?? null, input.beliefId ?? null, title, input.summary ?? null, input.reason ?? null, occurredAt, JSON.stringify([...new Set(input.evidenceEventIds)]), now);
|
|
21
|
+
return this.get(entryId);
|
|
22
|
+
}
|
|
23
|
+
get(entryId) {
|
|
24
|
+
const row = this.db.prepare(`SELECT * FROM memory_timeline_entries WHERE entry_id = ?`).get(entryId);
|
|
25
|
+
return row ? this.mapTimelineRow(row) : null;
|
|
26
|
+
}
|
|
27
|
+
list(options = {}) {
|
|
28
|
+
const conditions = [];
|
|
29
|
+
const params = [];
|
|
30
|
+
if (options.projectId) {
|
|
31
|
+
conditions.push('project_id = ?');
|
|
32
|
+
params.push(options.projectId);
|
|
33
|
+
}
|
|
34
|
+
if (options.canonicalKey) {
|
|
35
|
+
conditions.push('canonical_key = ?');
|
|
36
|
+
params.push(options.canonicalKey.trim().toLowerCase());
|
|
37
|
+
}
|
|
38
|
+
if (options.entityId) {
|
|
39
|
+
conditions.push('entity_id = ?');
|
|
40
|
+
params.push(options.entityId);
|
|
41
|
+
}
|
|
42
|
+
if (options.startTime !== undefined) {
|
|
43
|
+
conditions.push('occurred_at >= ?');
|
|
44
|
+
params.push(options.startTime);
|
|
45
|
+
}
|
|
46
|
+
if (options.endTime !== undefined) {
|
|
47
|
+
conditions.push('occurred_at < ?');
|
|
48
|
+
params.push(options.endTime);
|
|
49
|
+
}
|
|
50
|
+
if (options.entryTypes?.length) {
|
|
51
|
+
conditions.push(`entry_type IN (${options.entryTypes.map(() => '?').join(', ')})`);
|
|
52
|
+
params.push(...options.entryTypes);
|
|
53
|
+
}
|
|
54
|
+
const limit = Math.max(1, Math.min(500, options.limit ?? 100));
|
|
55
|
+
const rows = this.db.prepare(`
|
|
56
|
+
SELECT * FROM memory_timeline_entries
|
|
57
|
+
${conditions.length ? `WHERE ${conditions.join(' AND ')}` : ''}
|
|
58
|
+
ORDER BY occurred_at DESC, created_at DESC
|
|
59
|
+
LIMIT ?
|
|
60
|
+
`).all(...params, limit);
|
|
61
|
+
return rows.map((row) => this.mapTimelineRow(row));
|
|
62
|
+
}
|
|
63
|
+
getBeliefAt(projectId, canonicalKey, atTime) {
|
|
64
|
+
const row = this.db.prepare(`
|
|
65
|
+
SELECT * FROM belief_graph_nodes
|
|
66
|
+
WHERE canonical_key = ?
|
|
67
|
+
AND ((? IS NULL AND project_id IS NULL) OR project_id = ?)
|
|
68
|
+
AND valid_from <= ? AND (valid_to IS NULL OR valid_to > ?)
|
|
69
|
+
AND status != 'rejected' AND status != 'possible_conflict'
|
|
70
|
+
ORDER BY valid_from DESC LIMIT 1
|
|
71
|
+
`).get(canonicalKey.trim().toLowerCase(), projectId ?? null, projectId ?? null, atTime, atTime);
|
|
72
|
+
return row ? this.mapBeliefRow(row) : null;
|
|
73
|
+
}
|
|
74
|
+
getBeliefHistory(projectId, canonicalKey) {
|
|
75
|
+
const rows = this.db.prepare(`
|
|
76
|
+
SELECT * FROM belief_graph_nodes
|
|
77
|
+
WHERE canonical_key = ? AND ((? IS NULL AND project_id IS NULL) OR project_id = ?)
|
|
78
|
+
AND status != 'rejected' AND status != 'possible_conflict'
|
|
79
|
+
ORDER BY valid_from ASC, created_at ASC
|
|
80
|
+
`).all(canonicalKey.trim().toLowerCase(), projectId ?? null, projectId ?? null);
|
|
81
|
+
return rows.map((row) => this.mapBeliefRow(row));
|
|
82
|
+
}
|
|
83
|
+
mapTimelineRow(row) {
|
|
84
|
+
return {
|
|
85
|
+
entryId: String(row.entry_id),
|
|
86
|
+
projectId: row.project_id == null ? undefined : String(row.project_id),
|
|
87
|
+
entryType: row.entry_type,
|
|
88
|
+
canonicalKey: row.canonical_key == null ? undefined : String(row.canonical_key),
|
|
89
|
+
entityId: row.entity_id == null ? undefined : String(row.entity_id),
|
|
90
|
+
beliefId: row.belief_id == null ? undefined : String(row.belief_id),
|
|
91
|
+
title: String(row.title),
|
|
92
|
+
summary: row.summary == null ? undefined : String(row.summary),
|
|
93
|
+
reason: row.reason == null ? undefined : String(row.reason),
|
|
94
|
+
occurredAt: Number(row.occurred_at),
|
|
95
|
+
evidenceEventIds: JSON.parse(String(row.evidence_event_ids_json)),
|
|
96
|
+
createdAt: Number(row.created_at),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
mapBeliefRow(row) {
|
|
100
|
+
return {
|
|
101
|
+
beliefId: String(row.belief_id),
|
|
102
|
+
projectId: row.project_id == null ? undefined : String(row.project_id),
|
|
103
|
+
canonicalKey: String(row.canonical_key),
|
|
104
|
+
statement: String(row.statement),
|
|
105
|
+
status: String(row.status),
|
|
106
|
+
version: Number(row.version),
|
|
107
|
+
validFrom: Number(row.valid_from),
|
|
108
|
+
validTo: row.valid_to == null ? undefined : Number(row.valid_to),
|
|
109
|
+
supersedesBeliefId: row.supersedes_belief_id == null ? undefined : String(row.supersedes_belief_id),
|
|
110
|
+
supersededByBeliefId: row.superseded_by_belief_id == null ? undefined : String(row.superseded_by_belief_id),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
initializeSchema() {
|
|
114
|
+
this.db.exec(`
|
|
115
|
+
CREATE TABLE IF NOT EXISTS memory_timeline_entries (
|
|
116
|
+
entry_id TEXT PRIMARY KEY, project_id TEXT, entry_type TEXT NOT NULL, canonical_key TEXT,
|
|
117
|
+
entity_id TEXT, belief_id TEXT, title TEXT NOT NULL, summary TEXT, reason TEXT,
|
|
118
|
+
occurred_at INTEGER NOT NULL, evidence_event_ids_json TEXT NOT NULL, created_at INTEGER NOT NULL
|
|
119
|
+
);
|
|
120
|
+
CREATE INDEX IF NOT EXISTS idx_memory_timeline_project_time
|
|
121
|
+
ON memory_timeline_entries(project_id, occurred_at DESC);
|
|
122
|
+
CREATE INDEX IF NOT EXISTS idx_memory_timeline_canonical_time
|
|
123
|
+
ON memory_timeline_entries(project_id, canonical_key, occurred_at DESC);
|
|
124
|
+
CREATE INDEX IF NOT EXISTS idx_memory_timeline_entity_time
|
|
125
|
+
ON memory_timeline_entries(project_id, entity_id, occurred_at DESC);
|
|
126
|
+
`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TemporalMemoryService.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type Database from 'bun:sqlite';
|
|
2
|
+
import type { TopicAliasRecord, TopicCreatedBy } from './TopicTypes.js';
|
|
3
|
+
export declare class TopicAliasRegistry {
|
|
4
|
+
private readonly db;
|
|
5
|
+
constructor(db: Database);
|
|
6
|
+
add(input: {
|
|
7
|
+
projectId: string;
|
|
8
|
+
topicId: string;
|
|
9
|
+
alias: string;
|
|
10
|
+
createdBy: TopicCreatedBy;
|
|
11
|
+
confidence: number;
|
|
12
|
+
evidenceEventIds?: string[];
|
|
13
|
+
now?: number;
|
|
14
|
+
}): TopicAliasRecord;
|
|
15
|
+
resolve(projectId: string, alias: string): TopicAliasRecord | undefined;
|
|
16
|
+
matchText(projectId: string, text: string, limit?: number): TopicAliasRecord[];
|
|
17
|
+
archive(aliasId: string, projectId: string, now?: number): void;
|
|
18
|
+
get(aliasId: string): TopicAliasRecord | undefined;
|
|
19
|
+
}
|
|
20
|
+
export declare function normalizeTopicAlias(value: string): string;
|
|
21
|
+
//# sourceMappingURL=TopicAliasRegistry.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
export class TopicAliasRegistry {
|
|
3
|
+
db;
|
|
4
|
+
constructor(db) {
|
|
5
|
+
this.db = db;
|
|
6
|
+
}
|
|
7
|
+
add(input) {
|
|
8
|
+
const topic = this.db.prepare(`SELECT project_id FROM topic_nodes WHERE topic_id = ?`).get(input.topicId);
|
|
9
|
+
if (!topic)
|
|
10
|
+
throw new Error(`topic_not_found:${input.topicId}`);
|
|
11
|
+
if (topic.project_id !== input.projectId)
|
|
12
|
+
throw new Error(`topic_project_mismatch:${input.topicId}`);
|
|
13
|
+
const alias = input.alias.normalize('NFKC').trim();
|
|
14
|
+
const normalizedAlias = normalizeTopicAlias(alias);
|
|
15
|
+
if (!normalizedAlias)
|
|
16
|
+
throw new Error('topic_alias_required');
|
|
17
|
+
const collisions = this.db.prepare(`
|
|
18
|
+
SELECT DISTINCT topic_id FROM topic_aliases
|
|
19
|
+
WHERE project_id = ? AND normalized_alias = ? AND status IN ('active', 'needs_review') AND topic_id != ?
|
|
20
|
+
`).all(input.projectId, normalizedAlias, input.topicId);
|
|
21
|
+
const status = collisions.length
|
|
22
|
+
? 'needs_review'
|
|
23
|
+
: input.createdBy === 'model_candidate' ? 'candidate' : 'active';
|
|
24
|
+
const aliasId = `topic-alias-${randomUUID()}`;
|
|
25
|
+
const now = input.now ?? Date.now();
|
|
26
|
+
this.db.prepare(`
|
|
27
|
+
INSERT INTO topic_aliases (alias_id, project_id, normalized_alias, alias, topic_id, status,
|
|
28
|
+
created_by, confidence, evidence_event_ids_json, created_at, updated_at)
|
|
29
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
30
|
+
`).run(aliasId, input.projectId, normalizedAlias, alias, input.topicId, status, input.createdBy, Math.max(0, Math.min(1, input.confidence)), JSON.stringify(input.evidenceEventIds || []), now, now);
|
|
31
|
+
return this.get(aliasId);
|
|
32
|
+
}
|
|
33
|
+
resolve(projectId, alias) {
|
|
34
|
+
const rows = this.db.prepare(`
|
|
35
|
+
SELECT * FROM topic_aliases WHERE project_id = ? AND normalized_alias = ? AND status IN ('active', 'needs_review')
|
|
36
|
+
ORDER BY CASE status WHEN 'active' THEN 0 ELSE 1 END, confidence DESC
|
|
37
|
+
`).all(projectId, normalizeTopicAlias(alias));
|
|
38
|
+
if (new Set(rows.map((row) => row.topic_id)).size !== 1 || rows.some((row) => row.status === 'needs_review'))
|
|
39
|
+
return undefined;
|
|
40
|
+
return rows[0] ? mapAlias(rows[0]) : undefined;
|
|
41
|
+
}
|
|
42
|
+
matchText(projectId, text, limit = 10) {
|
|
43
|
+
const normalized = normalizeTopicAlias(text);
|
|
44
|
+
if (!normalized)
|
|
45
|
+
return [];
|
|
46
|
+
const rows = this.db.prepare(`
|
|
47
|
+
SELECT * FROM topic_aliases WHERE project_id = ? AND status = 'active' ORDER BY LENGTH(normalized_alias) DESC
|
|
48
|
+
`).all(projectId);
|
|
49
|
+
return rows.filter((row) => row.normalized_alias.length >= 2 && normalized.includes(row.normalized_alias)).slice(0, limit).map(mapAlias);
|
|
50
|
+
}
|
|
51
|
+
archive(aliasId, projectId, now = Date.now()) {
|
|
52
|
+
this.db.prepare(`UPDATE topic_aliases SET status = 'archived', updated_at = ? WHERE alias_id = ? AND project_id = ?`)
|
|
53
|
+
.run(now, aliasId, projectId);
|
|
54
|
+
}
|
|
55
|
+
get(aliasId) {
|
|
56
|
+
const row = this.db.prepare(`SELECT * FROM topic_aliases WHERE alias_id = ?`).get(aliasId);
|
|
57
|
+
return row ? mapAlias(row) : undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function normalizeTopicAlias(value) {
|
|
61
|
+
return String(value || '').normalize('NFKC').trim().toLocaleLowerCase().replace(/[_-]+/g, ' ').replace(/\s+/g, ' ');
|
|
62
|
+
}
|
|
63
|
+
function mapAlias(row) {
|
|
64
|
+
return { aliasId: row.alias_id, projectId: row.project_id, topicId: row.topic_id, alias: row.alias,
|
|
65
|
+
normalizedAlias: row.normalized_alias, status: row.status, createdBy: row.created_by, confidence: row.confidence,
|
|
66
|
+
evidenceEventIds: JSON.parse(row.evidence_event_ids_json), createdAt: row.created_at, updatedAt: row.updated_at };
|
|
67
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type Database from 'bun:sqlite';
|
|
2
|
+
import type { TopicAliasRegistry } from './TopicAliasRegistry.js';
|
|
3
|
+
import type { TopicPathRegistry } from './TopicPathRegistry.js';
|
|
4
|
+
import type { TopicRelationGraph } from './TopicRelationGraph.js';
|
|
5
|
+
import type { TopicOperationInput, TopicOperationRecord } from './TopicTypes.js';
|
|
6
|
+
export declare class TopicGovernance {
|
|
7
|
+
private readonly db;
|
|
8
|
+
private readonly paths;
|
|
9
|
+
private readonly aliases;
|
|
10
|
+
private readonly relations;
|
|
11
|
+
constructor(db: Database, paths: TopicPathRegistry, aliases: TopicAliasRegistry, relations: TopicRelationGraph);
|
|
12
|
+
apply(input: TopicOperationInput): TopicOperationRecord;
|
|
13
|
+
rollback(operationId: string, projectId: string, now?: number): TopicOperationRecord;
|
|
14
|
+
listOperations(input: {
|
|
15
|
+
projectId: string;
|
|
16
|
+
limit?: number;
|
|
17
|
+
}): TopicOperationRecord[];
|
|
18
|
+
getOperation(operationId: string): TopicOperationRecord | undefined;
|
|
19
|
+
private deleteTopicGraph;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=TopicGovernance.d.ts.map
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { isMemoryOntologyClass } from '../ontology/MemoryOntology.js';
|
|
3
|
+
const OPERATIONS = new Set([
|
|
4
|
+
'USER_DEFINED_TOPIC_CREATE', 'USER_DEFINED_TOPIC_RENAME', 'USER_DEFINED_TOPIC_ALIAS', 'USER_DEFINED_TOPIC_MOVE',
|
|
5
|
+
'USER_DEFINED_TOPIC_MERGE', 'USER_DEFINED_TOPIC_SPLIT', 'USER_DEFINED_TOPIC_REASSIGN',
|
|
6
|
+
'USER_DEFINED_TOPIC_RELATION_ADD', 'USER_DEFINED_TOPIC_RELATION_REMOVE', 'MODEL_PROPOSED_TOPIC',
|
|
7
|
+
'MODEL_PROPOSED_TOPIC_ALIAS', 'MODEL_PROPOSED_TOPIC_RELATION', 'SYSTEM_REPAIR_TOPIC',
|
|
8
|
+
]);
|
|
9
|
+
export class TopicGovernance {
|
|
10
|
+
db;
|
|
11
|
+
paths;
|
|
12
|
+
aliases;
|
|
13
|
+
relations;
|
|
14
|
+
constructor(db, paths, aliases, relations) {
|
|
15
|
+
this.db = db;
|
|
16
|
+
this.paths = paths;
|
|
17
|
+
this.aliases = aliases;
|
|
18
|
+
this.relations = relations;
|
|
19
|
+
}
|
|
20
|
+
apply(input) {
|
|
21
|
+
if (!OPERATIONS.has(input.operationType))
|
|
22
|
+
throw new Error(`invalid_topic_operation:${input.operationType}`);
|
|
23
|
+
const now = input.now ?? Date.now();
|
|
24
|
+
const operationId = `topic-operation-${randomUUID()}`;
|
|
25
|
+
let targetTopicId = input.targetTopicId;
|
|
26
|
+
let before;
|
|
27
|
+
let after;
|
|
28
|
+
let status = 'applied';
|
|
29
|
+
this.db.transaction(() => {
|
|
30
|
+
if (input.operationType === 'USER_DEFINED_TOPIC_CREATE' || input.operationType === 'MODEL_PROPOSED_TOPIC') {
|
|
31
|
+
const ontologyClass = input.payload.ontologyClass ?? 'Topic';
|
|
32
|
+
if (!isMemoryOntologyClass(ontologyClass))
|
|
33
|
+
throw new Error(`invalid_ontology_class:${String(ontologyClass)}`);
|
|
34
|
+
const created = this.paths.create({
|
|
35
|
+
projectId: input.projectId, topicPath: required(input.payload.topicPath, 'topicPath'),
|
|
36
|
+
canonicalName: required(input.payload.canonicalName, 'canonicalName'), ontologyClass,
|
|
37
|
+
parentTopicId: optional(input.payload.parentTopicId), createdBy: input.actor,
|
|
38
|
+
evidenceEventIds: input.evidenceEventIds, now,
|
|
39
|
+
});
|
|
40
|
+
targetTopicId = created.topicId;
|
|
41
|
+
this.aliases.add({
|
|
42
|
+
projectId: input.projectId, topicId: created.topicId, alias: created.canonicalName,
|
|
43
|
+
createdBy: input.actor, confidence: input.actor === 'user_explicit' ? 1 : 0.6,
|
|
44
|
+
evidenceEventIds: input.evidenceEventIds, now,
|
|
45
|
+
});
|
|
46
|
+
after = created;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (!targetTopicId)
|
|
50
|
+
throw new Error('target_topic_required');
|
|
51
|
+
before = this.paths.assertProject(targetTopicId, input.projectId);
|
|
52
|
+
if (input.operationType === 'USER_DEFINED_TOPIC_RENAME') {
|
|
53
|
+
after = this.paths.update(targetTopicId, input.projectId, { canonicalName: required(input.payload.canonicalName, 'canonicalName'), now });
|
|
54
|
+
}
|
|
55
|
+
else if (input.operationType === 'USER_DEFINED_TOPIC_MOVE' || input.operationType === 'USER_DEFINED_TOPIC_REASSIGN') {
|
|
56
|
+
after = this.paths.update(targetTopicId, input.projectId, {
|
|
57
|
+
topicPath: optional(input.payload.topicPath), parentTopicId: optional(input.payload.parentTopicId) ?? null, now,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else if (input.operationType === 'USER_DEFINED_TOPIC_ALIAS' || input.operationType === 'MODEL_PROPOSED_TOPIC_ALIAS') {
|
|
61
|
+
after = this.aliases.add({ projectId: input.projectId, topicId: targetTopicId,
|
|
62
|
+
alias: required(input.payload.alias, 'alias'), createdBy: input.actor,
|
|
63
|
+
confidence: input.actor === 'user_explicit' ? 1 : 0.6, evidenceEventIds: input.evidenceEventIds, now });
|
|
64
|
+
status = after.status === 'needs_review' ? 'needs_review' : 'applied';
|
|
65
|
+
}
|
|
66
|
+
else if (input.operationType === 'USER_DEFINED_TOPIC_MERGE') {
|
|
67
|
+
const destinationId = required(input.payload.destinationTopicId, 'destinationTopicId');
|
|
68
|
+
this.paths.assertProject(destinationId, input.projectId);
|
|
69
|
+
after = this.paths.update(targetTopicId, input.projectId, { status: 'merged', mergeCandidates: [destinationId], now });
|
|
70
|
+
}
|
|
71
|
+
else if (input.operationType === 'USER_DEFINED_TOPIC_SPLIT') {
|
|
72
|
+
const created = this.paths.create({ projectId: input.projectId,
|
|
73
|
+
topicPath: required(input.payload.topicPath, 'topicPath'), canonicalName: required(input.payload.canonicalName, 'canonicalName'),
|
|
74
|
+
ontologyClass: 'Topic', parentTopicId: before ? before.parentTopicId : undefined,
|
|
75
|
+
createdBy: input.actor, evidenceEventIds: input.evidenceEventIds, now });
|
|
76
|
+
after = { source: before, splitTopic: created };
|
|
77
|
+
}
|
|
78
|
+
else if (input.operationType === 'USER_DEFINED_TOPIC_RELATION_ADD' || input.operationType === 'MODEL_PROPOSED_TOPIC_RELATION') {
|
|
79
|
+
after = this.relations.add({ projectId: input.projectId, sourceTopicId: targetTopicId,
|
|
80
|
+
relation: required(input.payload.relation, 'relation'), targetTopicId: required(input.payload.targetTopicId, 'targetTopicId'),
|
|
81
|
+
createdBy: input.actor, evidenceEventIds: input.evidenceEventIds, now });
|
|
82
|
+
}
|
|
83
|
+
else if (input.operationType === 'USER_DEFINED_TOPIC_RELATION_REMOVE') {
|
|
84
|
+
const relationId = required(input.payload.relationId, 'relationId');
|
|
85
|
+
const relation = this.relations.get(relationId);
|
|
86
|
+
if (!relation || relation.projectId !== input.projectId)
|
|
87
|
+
throw new Error(`topic_relation_project_mismatch:${relationId}`);
|
|
88
|
+
before = relation;
|
|
89
|
+
this.relations.archive(relationId, input.projectId, now);
|
|
90
|
+
after = { relationId: input.payload.relationId, status: 'archived' };
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
after = this.paths.update(targetTopicId, input.projectId, { status: 'needs_review', now });
|
|
94
|
+
status = 'needs_review';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
this.db.prepare(`
|
|
98
|
+
INSERT INTO topic_operations (operation_id, project_id, operation_type, actor, target_topic_id, payload_json,
|
|
99
|
+
before_json, after_json, inverse_operation_json, status, evidence_event_ids_json, created_at)
|
|
100
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
101
|
+
`).run(operationId, input.projectId, input.operationType, input.actor, targetTopicId || null, JSON.stringify(input.payload), before === undefined ? null : JSON.stringify(before), after === undefined ? null : JSON.stringify(after), before === undefined ? null : JSON.stringify({ restoreTopic: before }), status, JSON.stringify(input.evidenceEventIds || []), now);
|
|
102
|
+
})();
|
|
103
|
+
return this.getOperation(operationId);
|
|
104
|
+
}
|
|
105
|
+
rollback(operationId, projectId, now = Date.now()) {
|
|
106
|
+
const operation = this.getOperation(operationId);
|
|
107
|
+
if (!operation)
|
|
108
|
+
throw new Error(`topic_operation_not_found:${operationId}`);
|
|
109
|
+
if (operation.projectId !== projectId)
|
|
110
|
+
throw new Error(`topic_operation_project_mismatch:${operationId}`);
|
|
111
|
+
if (operation.status === 'reverted')
|
|
112
|
+
return operation;
|
|
113
|
+
this.db.transaction(() => {
|
|
114
|
+
if (operation.operationType === 'USER_DEFINED_TOPIC_ALIAS' || operation.operationType === 'MODEL_PROPOSED_TOPIC_ALIAS') {
|
|
115
|
+
const aliasId = operation.after?.aliasId;
|
|
116
|
+
if (aliasId)
|
|
117
|
+
this.aliases.archive(aliasId, projectId, now);
|
|
118
|
+
}
|
|
119
|
+
else if (operation.operationType === 'USER_DEFINED_TOPIC_RELATION_ADD' || operation.operationType === 'MODEL_PROPOSED_TOPIC_RELATION') {
|
|
120
|
+
const relationId = operation.after?.relationId;
|
|
121
|
+
if (relationId)
|
|
122
|
+
this.relations.archive(relationId, projectId, now);
|
|
123
|
+
}
|
|
124
|
+
else if (operation.operationType === 'USER_DEFINED_TOPIC_RELATION_REMOVE') {
|
|
125
|
+
const relation = operation.before;
|
|
126
|
+
if (relation?.relationId && relation.status)
|
|
127
|
+
this.relations.setStatus(relation.relationId, projectId, relation.status, now);
|
|
128
|
+
}
|
|
129
|
+
else if (operation.operationType === 'USER_DEFINED_TOPIC_SPLIT') {
|
|
130
|
+
const splitTopicId = operation.after?.splitTopic?.topicId;
|
|
131
|
+
if (splitTopicId)
|
|
132
|
+
this.deleteTopicGraph(splitTopicId, projectId);
|
|
133
|
+
}
|
|
134
|
+
else if (operation.before && operation.targetTopicId) {
|
|
135
|
+
const before = operation.before;
|
|
136
|
+
this.paths.update(operation.targetTopicId, projectId, {
|
|
137
|
+
canonicalName: before.canonicalName, topicPath: before.topicPath, parentTopicId: before.parentTopicId ?? null,
|
|
138
|
+
status: before.status, mergeCandidates: before.mergeCandidates, now,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
else if (operation.targetTopicId && (operation.operationType === 'USER_DEFINED_TOPIC_CREATE' || operation.operationType === 'MODEL_PROPOSED_TOPIC')) {
|
|
142
|
+
this.deleteTopicGraph(operation.targetTopicId, projectId);
|
|
143
|
+
}
|
|
144
|
+
this.db.prepare(`UPDATE topic_operations SET status = 'reverted', reverted_at = ? WHERE operation_id = ?`).run(now, operationId);
|
|
145
|
+
})();
|
|
146
|
+
return this.getOperation(operationId);
|
|
147
|
+
}
|
|
148
|
+
listOperations(input) {
|
|
149
|
+
return this.db.prepare(`SELECT * FROM topic_operations WHERE project_id = ? ORDER BY created_at LIMIT ?`)
|
|
150
|
+
.all(input.projectId, Math.max(1, Math.min(input.limit ?? 100, 1000))).map(mapOperation);
|
|
151
|
+
}
|
|
152
|
+
getOperation(operationId) {
|
|
153
|
+
const row = this.db.prepare(`SELECT * FROM topic_operations WHERE operation_id = ?`).get(operationId);
|
|
154
|
+
return row ? mapOperation(row) : undefined;
|
|
155
|
+
}
|
|
156
|
+
deleteTopicGraph(topicId, projectId) {
|
|
157
|
+
this.paths.assertProject(topicId, projectId);
|
|
158
|
+
this.db.prepare(`DELETE FROM topic_relations WHERE project_id = ? AND (source_topic_id = ? OR target_topic_id = ?)`)
|
|
159
|
+
.run(projectId, topicId, topicId);
|
|
160
|
+
this.db.prepare(`DELETE FROM topic_aliases WHERE project_id = ? AND topic_id = ?`).run(projectId, topicId);
|
|
161
|
+
this.paths.delete(topicId, projectId);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function mapOperation(row) {
|
|
165
|
+
return { operationId: row.operation_id, projectId: row.project_id, operationType: row.operation_type, actor: row.actor,
|
|
166
|
+
targetTopicId: row.target_topic_id || undefined, payload: JSON.parse(row.payload_json),
|
|
167
|
+
before: row.before_json ? JSON.parse(row.before_json) : undefined, after: row.after_json ? JSON.parse(row.after_json) : undefined,
|
|
168
|
+
status: row.status, evidenceEventIds: JSON.parse(row.evidence_event_ids_json), createdAt: row.created_at,
|
|
169
|
+
revertedAt: row.reverted_at ?? undefined };
|
|
170
|
+
}
|
|
171
|
+
function required(value, name) { if (typeof value !== 'string' || !value.trim())
|
|
172
|
+
throw new Error(`${name}_required`); return value.trim(); }
|
|
173
|
+
function optional(value) { return typeof value === 'string' && value.trim() ? value.trim() : undefined; }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type Database from 'bun:sqlite';
|
|
2
|
+
import { type MemoryOntologyClass } from '../ontology/MemoryOntology.js';
|
|
3
|
+
import type { TopicCreatedBy, TopicNode, TopicStatus } from './TopicTypes.js';
|
|
4
|
+
export declare class TopicPathRegistry {
|
|
5
|
+
private readonly db;
|
|
6
|
+
constructor(db: Database);
|
|
7
|
+
create(input: {
|
|
8
|
+
projectId: string;
|
|
9
|
+
topicPath: string;
|
|
10
|
+
canonicalName: string;
|
|
11
|
+
parentTopicId?: string;
|
|
12
|
+
ontologyClass?: MemoryOntologyClass;
|
|
13
|
+
status?: TopicStatus;
|
|
14
|
+
createdBy: TopicCreatedBy;
|
|
15
|
+
confidence?: number;
|
|
16
|
+
evidenceEventIds?: string[];
|
|
17
|
+
evidenceEpisodeIds?: string[];
|
|
18
|
+
now?: number;
|
|
19
|
+
}): TopicNode;
|
|
20
|
+
get(topicId: string): TopicNode | undefined;
|
|
21
|
+
getByPath(projectId: string, topicPath: string): TopicNode | undefined;
|
|
22
|
+
list(projectId: string, statuses?: TopicStatus[]): TopicNode[];
|
|
23
|
+
update(topicId: string, projectId: string, patch: {
|
|
24
|
+
canonicalName?: string;
|
|
25
|
+
topicPath?: string;
|
|
26
|
+
parentTopicId?: string | null;
|
|
27
|
+
status?: TopicStatus;
|
|
28
|
+
mergeCandidates?: string[];
|
|
29
|
+
now?: number;
|
|
30
|
+
}): TopicNode;
|
|
31
|
+
delete(topicId: string, projectId: string): void;
|
|
32
|
+
assertProject(topicId: string, projectId: string): TopicNode;
|
|
33
|
+
private listAliases;
|
|
34
|
+
}
|
|
35
|
+
export declare function normalizeTopicPath(value: string): string;
|
|
36
|
+
//# sourceMappingURL=TopicPathRegistry.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { isMemoryOntologyClass } from '../ontology/MemoryOntology.js';
|
|
3
|
+
export class TopicPathRegistry {
|
|
4
|
+
db;
|
|
5
|
+
constructor(db) {
|
|
6
|
+
this.db = db;
|
|
7
|
+
}
|
|
8
|
+
create(input) {
|
|
9
|
+
const now = input.now ?? Date.now();
|
|
10
|
+
const topicPath = normalizeTopicPath(input.topicPath);
|
|
11
|
+
const ontologyClass = input.ontologyClass ?? 'Topic';
|
|
12
|
+
if (!input.projectId.trim())
|
|
13
|
+
throw new Error('topic_project_required');
|
|
14
|
+
if (!input.canonicalName.trim())
|
|
15
|
+
throw new Error('topic_name_required');
|
|
16
|
+
if (!isMemoryOntologyClass(ontologyClass))
|
|
17
|
+
throw new Error(`invalid_ontology_class:${ontologyClass}`);
|
|
18
|
+
if (input.parentTopicId)
|
|
19
|
+
this.assertProject(input.parentTopicId, input.projectId);
|
|
20
|
+
const topicId = `topic-${randomUUID()}`;
|
|
21
|
+
this.db.prepare(`
|
|
22
|
+
INSERT INTO topic_nodes (
|
|
23
|
+
topic_id, project_id, topic_path, canonical_name, parent_topic_id, ontology_class, status,
|
|
24
|
+
created_by, confidence, evidence_event_ids_json, evidence_episode_ids_json, last_used_at,
|
|
25
|
+
merge_candidates_json, created_at, updated_at
|
|
26
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '[]', ?, ?)
|
|
27
|
+
`).run(topicId, input.projectId, topicPath, input.canonicalName.trim(), input.parentTopicId || null, ontologyClass, input.status ?? (input.createdBy === 'model_candidate' ? 'candidate' : 'active'), input.createdBy, clamp(input.confidence ?? (input.createdBy === 'user_explicit' ? 1 : 0.6)), JSON.stringify(input.evidenceEventIds || []), JSON.stringify(input.evidenceEpisodeIds || []), now, now, now);
|
|
28
|
+
return this.get(topicId);
|
|
29
|
+
}
|
|
30
|
+
get(topicId) {
|
|
31
|
+
const row = this.db.prepare(`SELECT * FROM topic_nodes WHERE topic_id = ?`).get(topicId);
|
|
32
|
+
return row ? mapTopic(row, this.listAliases(row.project_id, row.topic_id)) : undefined;
|
|
33
|
+
}
|
|
34
|
+
getByPath(projectId, topicPath) {
|
|
35
|
+
const row = this.db.prepare(`SELECT * FROM topic_nodes WHERE project_id = ? AND topic_path = ?`)
|
|
36
|
+
.get(projectId, normalizeTopicPath(topicPath));
|
|
37
|
+
return row ? mapTopic(row, this.listAliases(row.project_id, row.topic_id)) : undefined;
|
|
38
|
+
}
|
|
39
|
+
list(projectId, statuses) {
|
|
40
|
+
const rows = statuses?.length
|
|
41
|
+
? this.db.prepare(`SELECT * FROM topic_nodes WHERE project_id = ? AND status IN (${statuses.map(() => '?').join(',')}) ORDER BY topic_path`)
|
|
42
|
+
.all(projectId, ...statuses)
|
|
43
|
+
: this.db.prepare(`SELECT * FROM topic_nodes WHERE project_id = ? ORDER BY topic_path`).all(projectId);
|
|
44
|
+
return rows.map((row) => mapTopic(row, this.listAliases(projectId, row.topic_id)));
|
|
45
|
+
}
|
|
46
|
+
update(topicId, projectId, patch) {
|
|
47
|
+
const current = this.assertProject(topicId, projectId);
|
|
48
|
+
if (patch.parentTopicId)
|
|
49
|
+
this.assertProject(patch.parentTopicId, projectId);
|
|
50
|
+
const next = {
|
|
51
|
+
canonicalName: patch.canonicalName?.trim() || current.canonicalName,
|
|
52
|
+
topicPath: patch.topicPath ? normalizeTopicPath(patch.topicPath) : current.topicPath,
|
|
53
|
+
parentTopicId: patch.parentTopicId === undefined ? current.parentTopicId : patch.parentTopicId || undefined,
|
|
54
|
+
status: patch.status || current.status,
|
|
55
|
+
mergeCandidates: patch.mergeCandidates ?? current.mergeCandidates ?? [],
|
|
56
|
+
};
|
|
57
|
+
this.db.prepare(`
|
|
58
|
+
UPDATE topic_nodes SET canonical_name = ?, topic_path = ?, parent_topic_id = ?, status = ?,
|
|
59
|
+
merge_candidates_json = ?, updated_at = ? WHERE topic_id = ? AND project_id = ?
|
|
60
|
+
`).run(next.canonicalName, next.topicPath, next.parentTopicId || null, next.status, JSON.stringify(next.mergeCandidates), patch.now ?? Date.now(), topicId, projectId);
|
|
61
|
+
return this.get(topicId);
|
|
62
|
+
}
|
|
63
|
+
delete(topicId, projectId) {
|
|
64
|
+
this.assertProject(topicId, projectId);
|
|
65
|
+
this.db.prepare(`DELETE FROM topic_nodes WHERE topic_id = ? AND project_id = ?`).run(topicId, projectId);
|
|
66
|
+
}
|
|
67
|
+
assertProject(topicId, projectId) {
|
|
68
|
+
const topic = this.get(topicId);
|
|
69
|
+
if (!topic)
|
|
70
|
+
throw new Error(`topic_not_found:${topicId}`);
|
|
71
|
+
if (topic.projectId !== projectId)
|
|
72
|
+
throw new Error(`topic_project_mismatch:${topicId}`);
|
|
73
|
+
return topic;
|
|
74
|
+
}
|
|
75
|
+
listAliases(projectId, topicId) {
|
|
76
|
+
return this.db.prepare(`SELECT alias FROM topic_aliases WHERE project_id = ? AND topic_id = ? AND status = 'active' ORDER BY created_at`)
|
|
77
|
+
.all(projectId, topicId).map((row) => row.alias);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export function normalizeTopicPath(value) {
|
|
81
|
+
const path = String(value || '').normalize('NFKC').trim().toLowerCase()
|
|
82
|
+
.replace(/[^\p{L}\p{N}/_-]+/gu, '-').replace(/_+/g, '-').replace(/\/{2,}/g, '/')
|
|
83
|
+
.replace(/^[/\-]+|[/\-]+$/g, '');
|
|
84
|
+
if (!path)
|
|
85
|
+
throw new Error('topic_path_required');
|
|
86
|
+
if (path.split('/').some((segment) => !segment || segment === '.' || segment === '..'))
|
|
87
|
+
throw new Error('invalid_topic_path');
|
|
88
|
+
return path;
|
|
89
|
+
}
|
|
90
|
+
function mapTopic(row, aliases) {
|
|
91
|
+
return {
|
|
92
|
+
topicId: row.topic_id, projectId: row.project_id, topicPath: row.topic_path, canonicalName: row.canonical_name,
|
|
93
|
+
aliases, parentTopicId: row.parent_topic_id || undefined, ontologyClass: row.ontology_class, status: row.status,
|
|
94
|
+
createdBy: row.created_by, confidence: row.confidence, evidenceEventIds: parse(row.evidence_event_ids_json, []),
|
|
95
|
+
evidenceEpisodeIds: parse(row.evidence_episode_ids_json, []), lastUsedAt: row.last_used_at,
|
|
96
|
+
mergeCandidates: parse(row.merge_candidates_json, []), createdAt: row.created_at, updatedAt: row.updated_at,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function parse(value, fallback) { try {
|
|
100
|
+
return value ? JSON.parse(value) : fallback;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return fallback;
|
|
104
|
+
} }
|
|
105
|
+
function clamp(value) { return Math.max(0, Math.min(1, Number.isFinite(value) ? value : 0)); }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type Database from 'bun:sqlite';
|
|
2
|
+
import type { TopicCreatedBy, TopicRelationRecord } from './TopicTypes.js';
|
|
3
|
+
export declare class TopicRelationGraph {
|
|
4
|
+
private readonly db;
|
|
5
|
+
constructor(db: Database);
|
|
6
|
+
add(input: {
|
|
7
|
+
projectId: string;
|
|
8
|
+
sourceTopicId: string;
|
|
9
|
+
relation: string;
|
|
10
|
+
targetTopicId: string;
|
|
11
|
+
createdBy: TopicCreatedBy;
|
|
12
|
+
confidence?: number;
|
|
13
|
+
evidenceEventIds?: string[];
|
|
14
|
+
evidenceEpisodeIds?: string[];
|
|
15
|
+
now?: number;
|
|
16
|
+
}): TopicRelationRecord;
|
|
17
|
+
get(relationId: string): TopicRelationRecord | undefined;
|
|
18
|
+
archive(relationId: string, projectId: string, now?: number): void;
|
|
19
|
+
setStatus(relationId: string, projectId: string, status: TopicRelationRecord['status'], now?: number): void;
|
|
20
|
+
list(projectId: string): TopicRelationRecord[];
|
|
21
|
+
private assertTopic;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=TopicRelationGraph.d.ts.map
|