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,832 @@
|
|
|
1
|
+
import { KernelAgentMemoryBackend } from '../agent/index.js';
|
|
2
|
+
import { createStableImportIdentityFactory } from '../episode/EpisodeImportIdentity.js';
|
|
3
|
+
import { createMemoryKernel, createMemoryKernelFromConfig, } from '../factory.js';
|
|
4
|
+
import { explainRecallWithKernel } from '../recall/RecallExplanation.js';
|
|
5
|
+
const STRING_SCHEMA = { type: 'string' };
|
|
6
|
+
const NUMBER_SCHEMA = { type: 'number' };
|
|
7
|
+
const STRING_ARRAY_SCHEMA = { type: 'array', items: STRING_SCHEMA };
|
|
8
|
+
const TURN_INGEST_MODE_SCHEMA = {
|
|
9
|
+
type: 'string',
|
|
10
|
+
enum: ['immediate_compile', 'selective_compile', 'raw_archive_only', 'raw_then_dream'],
|
|
11
|
+
};
|
|
12
|
+
const EPISODE_MESSAGE_SCHEMA = {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
role: { type: 'string', enum: ['user', 'assistant', 'agent', 'tool', 'system', 'narrator'] },
|
|
16
|
+
text: STRING_SCHEMA,
|
|
17
|
+
externalMessageId: STRING_SCHEMA,
|
|
18
|
+
timestamp: NUMBER_SCHEMA,
|
|
19
|
+
},
|
|
20
|
+
required: ['role', 'text'],
|
|
21
|
+
};
|
|
22
|
+
export function listCogmemMcpTools() {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
name: 'cogmem_remember_turn',
|
|
26
|
+
description: 'Write one user/agent turn into cogmem memory.',
|
|
27
|
+
inputSchema: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
agentId: STRING_SCHEMA,
|
|
31
|
+
projectId: STRING_SCHEMA,
|
|
32
|
+
sessionId: STRING_SCHEMA,
|
|
33
|
+
userText: STRING_SCHEMA,
|
|
34
|
+
assistantText: STRING_SCHEMA,
|
|
35
|
+
ingestMode: TURN_INGEST_MODE_SCHEMA,
|
|
36
|
+
collection: STRING_SCHEMA,
|
|
37
|
+
timestamp: NUMBER_SCHEMA,
|
|
38
|
+
},
|
|
39
|
+
required: ['agentId', 'projectId', 'sessionId', 'userText'],
|
|
40
|
+
},
|
|
41
|
+
annotations: {
|
|
42
|
+
title: 'Remember Turn',
|
|
43
|
+
readOnlyHint: false,
|
|
44
|
+
destructiveHint: false,
|
|
45
|
+
idempotentHint: false,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'cogmem_recall',
|
|
50
|
+
description: 'Recall governed agent-facing memory context from cogmem using the same path as cogmem memory recall, including raw ledger fallback with labeled sourceContext events, sourceContext.window metadata, char/source ranges when available, and locator commands when vectors or compiled evidence are unavailable. Suppressed evidence is omitted from active context; use cogmem_explain_recall to inspect filteredEvidence.',
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
query: STRING_SCHEMA,
|
|
55
|
+
agentId: STRING_SCHEMA,
|
|
56
|
+
projectId: STRING_SCHEMA,
|
|
57
|
+
collection: STRING_SCHEMA,
|
|
58
|
+
limit: NUMBER_SCHEMA,
|
|
59
|
+
since: { oneOf: [STRING_SCHEMA, NUMBER_SCHEMA] },
|
|
60
|
+
until: { oneOf: [STRING_SCHEMA, NUMBER_SCHEMA] },
|
|
61
|
+
},
|
|
62
|
+
required: ['query'],
|
|
63
|
+
},
|
|
64
|
+
annotations: {
|
|
65
|
+
title: 'Recall Memory',
|
|
66
|
+
readOnlyHint: true,
|
|
67
|
+
destructiveHint: false,
|
|
68
|
+
idempotentHint: true,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'cogmem_explain_recall',
|
|
73
|
+
description: 'Explain why cogmem recalled specific memory context, including pulse trace, temporal traversal, runtime path, evidence, filteredEvidence, and governanceReason for suppressed candidates.',
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
query: STRING_SCHEMA,
|
|
78
|
+
agentId: STRING_SCHEMA,
|
|
79
|
+
projectId: STRING_SCHEMA,
|
|
80
|
+
collection: STRING_SCHEMA,
|
|
81
|
+
limit: NUMBER_SCHEMA,
|
|
82
|
+
since: { oneOf: [STRING_SCHEMA, NUMBER_SCHEMA] },
|
|
83
|
+
until: { oneOf: [STRING_SCHEMA, NUMBER_SCHEMA] },
|
|
84
|
+
},
|
|
85
|
+
required: ['query'],
|
|
86
|
+
},
|
|
87
|
+
annotations: {
|
|
88
|
+
title: 'Explain Recall',
|
|
89
|
+
readOnlyHint: true,
|
|
90
|
+
destructiveHint: false,
|
|
91
|
+
idempotentHint: true,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'cogmem_strategy_plan',
|
|
96
|
+
description: 'Return the deterministic current-turn memory strategy capsule with no instruction authority. This tool does not recall, write, or mutate memory.',
|
|
97
|
+
inputSchema: {
|
|
98
|
+
type: 'object',
|
|
99
|
+
properties: {
|
|
100
|
+
query: STRING_SCHEMA,
|
|
101
|
+
projectId: STRING_SCHEMA,
|
|
102
|
+
},
|
|
103
|
+
required: ['query'],
|
|
104
|
+
},
|
|
105
|
+
annotations: {
|
|
106
|
+
title: 'Plan Memory Strategy',
|
|
107
|
+
readOnlyHint: true,
|
|
108
|
+
destructiveHint: false,
|
|
109
|
+
idempotentHint: true,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'cogmem_episode_append',
|
|
114
|
+
description: 'Append one bounded raw message and assign it to a session episode. This never runs Dream or promotes durable memory.',
|
|
115
|
+
inputSchema: {
|
|
116
|
+
type: 'object',
|
|
117
|
+
properties: {
|
|
118
|
+
projectId: STRING_SCHEMA, sessionId: STRING_SCHEMA, sourceAgent: STRING_SCHEMA,
|
|
119
|
+
role: { type: 'string', enum: ['user', 'assistant', 'agent', 'tool', 'system', 'narrator'] },
|
|
120
|
+
text: STRING_SCHEMA, externalMessageId: STRING_SCHEMA, timestamp: NUMBER_SCHEMA,
|
|
121
|
+
},
|
|
122
|
+
required: ['projectId', 'sessionId', 'sourceAgent', 'role', 'text', 'externalMessageId'],
|
|
123
|
+
},
|
|
124
|
+
annotations: { title: 'Append Episode Message', readOnlyHint: false, destructiveHint: false, idempotentHint: true },
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'cogmem_episode_import',
|
|
128
|
+
description: 'Import up to 200 bounded messages into Raw Ledger and the shared episode assembler. Dream is never implicit.',
|
|
129
|
+
inputSchema: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: {
|
|
132
|
+
projectId: STRING_SCHEMA, sessionId: STRING_SCHEMA, sourceAgent: STRING_SCHEMA,
|
|
133
|
+
messages: { type: 'array', items: EPISODE_MESSAGE_SCHEMA, maxItems: 200 },
|
|
134
|
+
sealBatch: { type: 'boolean' },
|
|
135
|
+
forceSeal: { type: 'boolean' },
|
|
136
|
+
},
|
|
137
|
+
required: ['projectId', 'sessionId', 'sourceAgent', 'messages'],
|
|
138
|
+
},
|
|
139
|
+
annotations: { title: 'Import Episode Messages', readOnlyHint: false, destructiveHint: false, idempotentHint: true },
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'cogmem_episode_status',
|
|
143
|
+
description: 'Inspect open and sealed episodes plus Dream backlog. Read-only.',
|
|
144
|
+
inputSchema: { type: 'object', properties: { projectId: STRING_SCHEMA, sessionId: STRING_SCHEMA, limit: NUMBER_SCHEMA } },
|
|
145
|
+
annotations: { title: 'Episode Status', readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'cogmem_topic_list',
|
|
149
|
+
description: 'List project-scoped user-shaped topic nodes and audited relations. Read-only.',
|
|
150
|
+
inputSchema: { type: 'object', properties: { projectId: STRING_SCHEMA }, required: ['projectId'] },
|
|
151
|
+
annotations: { title: 'List Memory Topics', readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'cogmem_topic_operate',
|
|
155
|
+
description: 'Apply an auditable user-explicit or model-candidate topic create/rename/alias/move/merge/split/relation operation. Model operations never activate directly.',
|
|
156
|
+
inputSchema: {
|
|
157
|
+
type: 'object', properties: {
|
|
158
|
+
projectId: STRING_SCHEMA, operationType: STRING_SCHEMA, actor: { type: 'string', enum: ['user_explicit', 'model_candidate', 'import', 'repair'] },
|
|
159
|
+
targetTopicId: STRING_SCHEMA, payload: { type: 'object' }, evidenceEventIds: STRING_ARRAY_SCHEMA,
|
|
160
|
+
}, required: ['projectId', 'operationType', 'actor', 'payload'],
|
|
161
|
+
},
|
|
162
|
+
annotations: { title: 'Operate Memory Topic', readOnlyHint: false, destructiveHint: true, idempotentHint: false },
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: 'cogmem_topic_rollback',
|
|
166
|
+
description: 'Revert one audited topic operation inside its original project scope.',
|
|
167
|
+
inputSchema: {
|
|
168
|
+
type: 'object', properties: { projectId: STRING_SCHEMA, operationId: STRING_SCHEMA },
|
|
169
|
+
required: ['projectId', 'operationId'],
|
|
170
|
+
},
|
|
171
|
+
annotations: { title: 'Rollback Memory Topic Operation', readOnlyHint: false, destructiveHint: true, idempotentHint: true },
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'cogmem_episode_repair',
|
|
175
|
+
description: 'Run audited episode surgery: split, merge, move-event, reclassify, requeue-dream, or invalidate-dream-run.',
|
|
176
|
+
inputSchema: {
|
|
177
|
+
type: 'object', properties: {
|
|
178
|
+
projectId: STRING_SCHEMA, operation: STRING_SCHEMA, episodeId: STRING_SCHEMA, sourceEpisodeId: STRING_SCHEMA,
|
|
179
|
+
targetEpisodeId: STRING_SCHEMA, eventId: STRING_SCHEMA, eventIds: STRING_ARRAY_SCHEMA,
|
|
180
|
+
episodeType: STRING_SCHEMA, topicPath: STRING_SCHEMA, importance: NUMBER_SCHEMA, mode: STRING_SCHEMA,
|
|
181
|
+
}, required: ['projectId', 'operation'],
|
|
182
|
+
},
|
|
183
|
+
annotations: { title: 'Repair Episode', readOnlyHint: false, destructiveHint: true, idempotentHint: false },
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: 'cogmem_episode_seal',
|
|
187
|
+
description: 'Explicitly seal one episode and enqueue it for conditional Dream processing.',
|
|
188
|
+
inputSchema: {
|
|
189
|
+
type: 'object', properties: { episodeId: STRING_SCHEMA, mode: { type: 'string', enum: ['soft', 'hard', 'manual', 'batch'] }, reason: STRING_SCHEMA },
|
|
190
|
+
required: ['episodeId'],
|
|
191
|
+
},
|
|
192
|
+
annotations: { title: 'Seal Episode', readOnlyHint: false, destructiveHint: false, idempotentHint: true },
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: 'cogmem_dream_tick',
|
|
196
|
+
description: 'Maintenance-only conditional Dream tick over sealed episodes only. Do not call during normal answer generation. Without maintenanceMode=true it returns a recommendation and does not process backlog.',
|
|
197
|
+
inputSchema: {
|
|
198
|
+
type: 'object', properties: {
|
|
199
|
+
projectId: STRING_SCHEMA,
|
|
200
|
+
mode: { type: 'string', enum: ['auto', 'micro', 'normal', 'deep'] },
|
|
201
|
+
maxEpisodes: NUMBER_SCHEMA,
|
|
202
|
+
maintenanceMode: { type: 'boolean' },
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
annotations: { title: 'Dream Tick', readOnlyHint: false, destructiveHint: false, idempotentHint: false },
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: 'cogmem_dream_status',
|
|
209
|
+
description: 'Inspect the episode Dream backlog without running consolidation.',
|
|
210
|
+
inputSchema: { type: 'object', properties: { projectId: STRING_SCHEMA } },
|
|
211
|
+
annotations: { title: 'Dream Status', readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'cogmem_memory_map',
|
|
215
|
+
description: 'Return the self-describing cogmem memory map: anatomy, data lanes, bounds, counters, and commands an agent should use.',
|
|
216
|
+
inputSchema: {
|
|
217
|
+
type: 'object',
|
|
218
|
+
properties: {
|
|
219
|
+
projectId: STRING_SCHEMA,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
annotations: {
|
|
223
|
+
title: 'Memory Map',
|
|
224
|
+
readOnlyHint: true,
|
|
225
|
+
destructiveHint: false,
|
|
226
|
+
idempotentHint: true,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: 'cogmem_candidate_review',
|
|
231
|
+
description: 'Apply one audited human review action to a needs-confirmation Dream candidate. Approve and correction relink require a distinct same-project raw user confirmation event; review never bypasses missing evidence or project scope.',
|
|
232
|
+
inputSchema: {
|
|
233
|
+
type: 'object',
|
|
234
|
+
properties: {
|
|
235
|
+
candidateId: STRING_SCHEMA,
|
|
236
|
+
projectId: STRING_SCHEMA,
|
|
237
|
+
action: { type: 'string', enum: ['approve', 'reject', 'defer', 'supersede', 'relink'] },
|
|
238
|
+
actor: STRING_SCHEMA,
|
|
239
|
+
reason: STRING_SCHEMA,
|
|
240
|
+
confirmationEventId: STRING_SCHEMA,
|
|
241
|
+
targetBeliefId: STRING_SCHEMA,
|
|
242
|
+
replacementCandidateId: STRING_SCHEMA,
|
|
243
|
+
reviewAfter: NUMBER_SCHEMA,
|
|
244
|
+
},
|
|
245
|
+
required: ['candidateId', 'projectId', 'action', 'actor', 'reason'],
|
|
246
|
+
},
|
|
247
|
+
annotations: {
|
|
248
|
+
title: 'Review Memory Candidate',
|
|
249
|
+
readOnlyHint: false,
|
|
250
|
+
destructiveHint: true,
|
|
251
|
+
idempotentHint: false,
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
graphTool('cogmem_graph_overview', 'Overview Memory Atlas', 'List a bounded content map of remembered topics, entities, clusters, episodes, actions, and time nodes.', {
|
|
255
|
+
projectId: STRING_SCHEMA, limit: NUMBER_SCHEMA,
|
|
256
|
+
}, ['projectId']),
|
|
257
|
+
graphTool('cogmem_graph_search', 'Search Memory Atlas', 'Locate matching Memory Atlas nodes without expanding the graph.', {
|
|
258
|
+
projectId: STRING_SCHEMA, query: STRING_SCHEMA, limit: NUMBER_SCHEMA,
|
|
259
|
+
}, ['projectId', 'query']),
|
|
260
|
+
graphTool('cogmem_graph_explore', 'Explore Memory Atlas', 'Use for broad memory inventory, project-state, or historical questions; returns a bounded local graph and drilldown actions.', {
|
|
261
|
+
projectId: STRING_SCHEMA, query: STRING_SCHEMA, limit: NUMBER_SCHEMA, evidenceLimit: NUMBER_SCHEMA, now: NUMBER_SCHEMA,
|
|
262
|
+
}, ['projectId', 'query']),
|
|
263
|
+
graphTool('cogmem_graph_node', 'Inspect Memory Node', 'Inspect one source-anchored node, its neighbors, evidence event ids, and exact raw drilldown commands.', {
|
|
264
|
+
projectId: STRING_SCHEMA, id: STRING_SCHEMA, includeEvidence: { type: 'boolean' }, evidenceLimit: NUMBER_SCHEMA,
|
|
265
|
+
}, ['projectId', 'id']),
|
|
266
|
+
graphTool('cogmem_graph_neighbors', 'Expand Memory Neighbors', 'Expand one Memory Atlas node by one or two bounded hops.', {
|
|
267
|
+
projectId: STRING_SCHEMA, id: STRING_SCHEMA, hops: NUMBER_SCHEMA, limit: NUMBER_SCHEMA,
|
|
268
|
+
}, ['projectId', 'id']),
|
|
269
|
+
graphTool('cogmem_graph_path', 'Find Memory Path', 'Find an evidence-backed bounded path between two Memory Atlas nodes.', {
|
|
270
|
+
projectId: STRING_SCHEMA, from: STRING_SCHEMA, to: STRING_SCHEMA, maxHops: NUMBER_SCHEMA,
|
|
271
|
+
}, ['projectId', 'from', 'to']),
|
|
272
|
+
graphTool('cogmem_graph_timeline', 'Reconstruct Memory Timeline', 'Reconstruct timestamped memory with the available query facets; action frames are included when applicable but are not required.', {
|
|
273
|
+
projectId: STRING_SCHEMA, query: STRING_SCHEMA, limit: NUMBER_SCHEMA, includeEvidence: { type: 'boolean' }, evidenceLimit: NUMBER_SCHEMA, now: NUMBER_SCHEMA,
|
|
274
|
+
}, ['projectId', 'query']),
|
|
275
|
+
{
|
|
276
|
+
name: 'cogmem_graph_touch',
|
|
277
|
+
description: 'Explicitly record that selected Atlas nodes were used in an answer or decision. Discovery queries stay read-only; call this only for nodes actually consumed.',
|
|
278
|
+
inputSchema: { type: 'object', properties: {
|
|
279
|
+
projectId: STRING_SCHEMA, nodeIds: STRING_ARRAY_SCHEMA, reason: STRING_SCHEMA, query: STRING_SCHEMA,
|
|
280
|
+
}, required: ['projectId', 'nodeIds', 'reason'] },
|
|
281
|
+
annotations: { title: 'Touch Used Memory Nodes', readOnlyHint: false, destructiveHint: false, idempotentHint: false },
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
name: 'cogmem_maintenance_tick',
|
|
285
|
+
description: 'Run one explicit host-owned maintenance tick. This decays activation and returns suggested upkeep commands such as dream, govern, re-embed, or cogmem memory bind for unbound raw events; it never starts a hidden daemon.',
|
|
286
|
+
inputSchema: {
|
|
287
|
+
type: 'object',
|
|
288
|
+
properties: {
|
|
289
|
+
projectId: STRING_SCHEMA,
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
annotations: {
|
|
293
|
+
title: 'Maintenance Tick',
|
|
294
|
+
readOnlyHint: false,
|
|
295
|
+
destructiveHint: false,
|
|
296
|
+
idempotentHint: false,
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: 'cogmem_prospective',
|
|
301
|
+
description: 'Manage evidence-backed future-memory candidates. It lists due state but never executes tasks or tools; confirmation requires a distinct Raw Ledger user event.',
|
|
302
|
+
inputSchema: {
|
|
303
|
+
type: 'object',
|
|
304
|
+
properties: {
|
|
305
|
+
action: { type: 'string', enum: ['list', 'due', 'create', 'confirm', 'reject', 'defer', 'complete', 'expire'] },
|
|
306
|
+
projectId: STRING_SCHEMA,
|
|
307
|
+
statuses: STRING_ARRAY_SCHEMA,
|
|
308
|
+
candidateId: STRING_SCHEMA,
|
|
309
|
+
candidateType: { type: 'string', enum: ['intention', 'commitment', 'reminder', 'open_loop', 'plan'] },
|
|
310
|
+
canonicalKey: STRING_SCHEMA,
|
|
311
|
+
title: STRING_SCHEMA,
|
|
312
|
+
details: STRING_SCHEMA,
|
|
313
|
+
evidenceEventIds: STRING_ARRAY_SCHEMA,
|
|
314
|
+
confirmationEvidenceEventId: STRING_SCHEMA,
|
|
315
|
+
dueAt: NUMBER_SCHEMA,
|
|
316
|
+
deferredUntil: NUMBER_SCHEMA,
|
|
317
|
+
atTime: NUMBER_SCHEMA,
|
|
318
|
+
limit: NUMBER_SCHEMA,
|
|
319
|
+
},
|
|
320
|
+
required: ['action'],
|
|
321
|
+
},
|
|
322
|
+
annotations: {
|
|
323
|
+
title: 'Prospective Memory',
|
|
324
|
+
readOnlyHint: false,
|
|
325
|
+
destructiveHint: true,
|
|
326
|
+
idempotentHint: false,
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
];
|
|
330
|
+
}
|
|
331
|
+
export async function callCogmemMcpTool(name, args, runtime = {}) {
|
|
332
|
+
const input = args || {};
|
|
333
|
+
const opened = openRuntimeKernel(runtime);
|
|
334
|
+
try {
|
|
335
|
+
switch (name) {
|
|
336
|
+
case 'cogmem_remember_turn':
|
|
337
|
+
return await rememberTurn(opened.kernel, input);
|
|
338
|
+
case 'cogmem_recall':
|
|
339
|
+
return recall(opened.kernel, input, false);
|
|
340
|
+
case 'cogmem_explain_recall':
|
|
341
|
+
return recall(opened.kernel, input, true);
|
|
342
|
+
case 'cogmem_strategy_plan': {
|
|
343
|
+
const query = requiredString(input.query, 'query');
|
|
344
|
+
const intent = opened.kernel.contextCortex.classifyIntent(query);
|
|
345
|
+
return jsonResult(opened.kernel.strategyCortex.plan({
|
|
346
|
+
query,
|
|
347
|
+
intent,
|
|
348
|
+
projectId: optionalString(input.projectId),
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
case 'cogmem_episode_append':
|
|
352
|
+
return await episodeAppend(opened.kernel, input);
|
|
353
|
+
case 'cogmem_episode_import':
|
|
354
|
+
return await episodeImport(opened.kernel, input);
|
|
355
|
+
case 'cogmem_episode_status':
|
|
356
|
+
return episodeStatus(opened.kernel, input);
|
|
357
|
+
case 'cogmem_topic_list': {
|
|
358
|
+
const projectId = requiredString(input.projectId, 'projectId');
|
|
359
|
+
return jsonResult({ topics: opened.kernel.userTopicPathRegistry.list(projectId), relations: opened.kernel.topicRelationGraph.list(projectId) });
|
|
360
|
+
}
|
|
361
|
+
case 'cogmem_topic_operate':
|
|
362
|
+
return jsonResult(opened.kernel.topicGovernance.apply({
|
|
363
|
+
projectId: requiredString(input.projectId, 'projectId'),
|
|
364
|
+
operationType: requiredString(input.operationType, 'operationType'),
|
|
365
|
+
actor: requiredString(input.actor, 'actor'),
|
|
366
|
+
targetTopicId: optionalString(input.targetTopicId),
|
|
367
|
+
payload: input.payload && typeof input.payload === 'object' ? input.payload : {},
|
|
368
|
+
evidenceEventIds: Array.isArray(input.evidenceEventIds) ? input.evidenceEventIds.map(String) : [],
|
|
369
|
+
}));
|
|
370
|
+
case 'cogmem_topic_rollback':
|
|
371
|
+
return jsonResult(opened.kernel.topicGovernance.rollback(requiredString(input.operationId, 'operationId'), requiredString(input.projectId, 'projectId')));
|
|
372
|
+
case 'cogmem_episode_repair':
|
|
373
|
+
return jsonResult(episodeRepair(opened.kernel, input));
|
|
374
|
+
case 'cogmem_episode_seal':
|
|
375
|
+
return jsonResult(opened.kernel.sealEpisode(requiredString(input.episodeId, 'episodeId'), {
|
|
376
|
+
mode: optionalEpisodeClosureMode(input.mode),
|
|
377
|
+
reason: optionalString(input.reason) || 'mcp_manual_seal',
|
|
378
|
+
}));
|
|
379
|
+
case 'cogmem_dream_tick':
|
|
380
|
+
if (input.maintenanceMode !== true) {
|
|
381
|
+
return jsonResult(dreamRecommendation(opened.kernel, optionalString(input.projectId), optionalDreamMode(input.mode)));
|
|
382
|
+
}
|
|
383
|
+
return jsonResult(await opened.kernel.runDreamTick({
|
|
384
|
+
projectId: optionalString(input.projectId), mode: optionalDreamMode(input.mode), maxEpisodes: optionalNumber(input.maxEpisodes),
|
|
385
|
+
}));
|
|
386
|
+
case 'cogmem_dream_status':
|
|
387
|
+
return jsonResult(opened.kernel.getEpisodeDreamStatus(optionalString(input.projectId)));
|
|
388
|
+
case 'cogmem_memory_map':
|
|
389
|
+
return jsonResult(opened.kernel.buildMemoryMap({ projectId: optionalString(input.projectId) }));
|
|
390
|
+
case 'cogmem_candidate_review':
|
|
391
|
+
return jsonResult(opened.kernel.reviewDreamCandidate({
|
|
392
|
+
candidateId: requiredString(input.candidateId, 'candidateId'),
|
|
393
|
+
projectId: requiredString(input.projectId, 'projectId'),
|
|
394
|
+
action: requiredCandidateReviewAction(input.action),
|
|
395
|
+
actor: requiredString(input.actor, 'actor'),
|
|
396
|
+
reason: requiredString(input.reason, 'reason'),
|
|
397
|
+
confirmationEventId: optionalString(input.confirmationEventId),
|
|
398
|
+
targetBeliefId: optionalString(input.targetBeliefId),
|
|
399
|
+
replacementCandidateId: optionalString(input.replacementCandidateId),
|
|
400
|
+
reviewAfter: optionalNumber(input.reviewAfter),
|
|
401
|
+
}));
|
|
402
|
+
case 'cogmem_graph_overview': {
|
|
403
|
+
const projectId = requiredString(input.projectId, 'projectId');
|
|
404
|
+
return jsonResult(opened.kernel.graphOverview({ projectId, limit: optionalNumber(input.limit) }));
|
|
405
|
+
}
|
|
406
|
+
case 'cogmem_graph_search': {
|
|
407
|
+
const projectId = requiredString(input.projectId, 'projectId');
|
|
408
|
+
return jsonResult(opened.kernel.graphSearch(requiredString(input.query, 'query'), { projectId, limit: optionalNumber(input.limit) }));
|
|
409
|
+
}
|
|
410
|
+
case 'cogmem_graph_explore': {
|
|
411
|
+
const projectId = requiredString(input.projectId, 'projectId');
|
|
412
|
+
return jsonResult(opened.kernel.graphExplore(requiredString(input.query, 'query'), { projectId, limit: optionalNumber(input.limit),
|
|
413
|
+
evidenceLimit: optionalNumber(input.evidenceLimit), now: optionalNumber(input.now) }));
|
|
414
|
+
}
|
|
415
|
+
case 'cogmem_graph_node': {
|
|
416
|
+
const projectId = requiredString(input.projectId, 'projectId');
|
|
417
|
+
const result = opened.kernel.graphNode(requiredString(input.id, 'id'), { projectId, includeEvidence: input.includeEvidence === true, evidenceLimit: optionalNumber(input.evidenceLimit) });
|
|
418
|
+
if (!result)
|
|
419
|
+
throw new Error('Memory Atlas node not found in the requested project');
|
|
420
|
+
return jsonResult(result);
|
|
421
|
+
}
|
|
422
|
+
case 'cogmem_graph_neighbors': {
|
|
423
|
+
const projectId = requiredString(input.projectId, 'projectId');
|
|
424
|
+
return jsonResult(opened.kernel.graphNeighbors(requiredString(input.id, 'id'), { projectId, hops: optionalNumber(input.hops), limit: optionalNumber(input.limit) }));
|
|
425
|
+
}
|
|
426
|
+
case 'cogmem_graph_path': {
|
|
427
|
+
const projectId = requiredString(input.projectId, 'projectId');
|
|
428
|
+
return jsonResult(opened.kernel.graphPath(requiredString(input.from, 'from'), requiredString(input.to, 'to'), { projectId, maxHops: optionalNumber(input.maxHops) }));
|
|
429
|
+
}
|
|
430
|
+
case 'cogmem_graph_timeline': {
|
|
431
|
+
const projectId = requiredString(input.projectId, 'projectId');
|
|
432
|
+
return jsonResult(opened.kernel.graphTimeline(requiredString(input.query, 'query'), { projectId, limit: optionalNumber(input.limit), includeEvidence: input.includeEvidence === true, evidenceLimit: optionalNumber(input.evidenceLimit), now: optionalNumber(input.now) }));
|
|
433
|
+
}
|
|
434
|
+
case 'cogmem_graph_touch':
|
|
435
|
+
return jsonResult(opened.kernel.touchMemoryAtlas({
|
|
436
|
+
projectId: requiredString(input.projectId, 'projectId'),
|
|
437
|
+
nodeIds: requiredStringArray(input.nodeIds, 'nodeIds'),
|
|
438
|
+
reason: requiredString(input.reason, 'reason'), query: optionalString(input.query),
|
|
439
|
+
}));
|
|
440
|
+
case 'cogmem_maintenance_tick':
|
|
441
|
+
return jsonResult(opened.kernel.runMaintenanceTick({ projectId: optionalString(input.projectId) }));
|
|
442
|
+
case 'cogmem_prospective':
|
|
443
|
+
return prospective(opened.kernel, input);
|
|
444
|
+
default:
|
|
445
|
+
return jsonResult({ error: `Unknown cogmem MCP tool: ${name}` }, true);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
catch (error) {
|
|
449
|
+
return jsonResult({ error: error instanceof Error ? error.message : String(error) }, true);
|
|
450
|
+
}
|
|
451
|
+
finally {
|
|
452
|
+
if (opened.shouldClose)
|
|
453
|
+
opened.kernel.close();
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
function graphTool(name, title, description, properties, required) {
|
|
457
|
+
return {
|
|
458
|
+
name,
|
|
459
|
+
description: `${description} Canonical memory and activation telemetry remain unchanged until cogmem_graph_touch explicitly records selected nodes.`,
|
|
460
|
+
inputSchema: { type: 'object', properties, required },
|
|
461
|
+
annotations: { title, readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
async function episodeAppend(kernel, input) {
|
|
465
|
+
const text = requiredString(input.text, 'text');
|
|
466
|
+
if (text.length > 16_000)
|
|
467
|
+
throw new Error('text exceeds the 16000 character MCP episode limit');
|
|
468
|
+
return jsonResult(await kernel.appendEpisodeMessageAsync({
|
|
469
|
+
projectId: requiredString(input.projectId, 'projectId'),
|
|
470
|
+
sessionId: requiredString(input.sessionId, 'sessionId'),
|
|
471
|
+
sourceAgent: requiredString(input.sourceAgent, 'sourceAgent'),
|
|
472
|
+
role: requiredEpisodeRole(input.role), text,
|
|
473
|
+
externalMessageId: requiredString(input.externalMessageId, 'externalMessageId'), timestamp: optionalNumber(input.timestamp),
|
|
474
|
+
}));
|
|
475
|
+
}
|
|
476
|
+
async function episodeImport(kernel, input) {
|
|
477
|
+
if (!Array.isArray(input.messages))
|
|
478
|
+
throw new Error('messages must be an array');
|
|
479
|
+
if (input.messages.length > 200)
|
|
480
|
+
throw new Error('messages exceeds the 200 item MCP import limit');
|
|
481
|
+
const projectId = requiredString(input.projectId, 'projectId');
|
|
482
|
+
const sessionId = requiredString(input.sessionId, 'sessionId');
|
|
483
|
+
const sourceAgent = requiredString(input.sourceAgent, 'sourceAgent');
|
|
484
|
+
const stableIdentity = createStableImportIdentityFactory(sourceAgent, sessionId);
|
|
485
|
+
let totalChars = 0;
|
|
486
|
+
let autoIdentityUsed = false;
|
|
487
|
+
const messages = input.messages.map((value, index) => {
|
|
488
|
+
if (!value || typeof value !== 'object')
|
|
489
|
+
throw new Error(`messages[${index}] must be an object`);
|
|
490
|
+
const message = value;
|
|
491
|
+
const text = requiredString(message.text, `messages[${index}].text`);
|
|
492
|
+
totalChars += text.length;
|
|
493
|
+
if (text.length > 16_000 || totalChars > 1_000_000)
|
|
494
|
+
throw new Error('episode import exceeds bounded text limits');
|
|
495
|
+
const role = requiredEpisodeRole(message.role);
|
|
496
|
+
const timestamp = optionalNumber(message.timestamp);
|
|
497
|
+
const suppliedIdentity = optionalString(message.externalMessageId);
|
|
498
|
+
if (!suppliedIdentity)
|
|
499
|
+
autoIdentityUsed = true;
|
|
500
|
+
return {
|
|
501
|
+
role, text, timestamp,
|
|
502
|
+
externalMessageId: suppliedIdentity
|
|
503
|
+
|| stableIdentity({ role, text, timestamp }),
|
|
504
|
+
};
|
|
505
|
+
});
|
|
506
|
+
const results = [];
|
|
507
|
+
const messageResults = [];
|
|
508
|
+
for (const [index, message] of messages.entries()) {
|
|
509
|
+
try {
|
|
510
|
+
const result = await kernel.appendEpisodeMessageAsync({ projectId, sessionId, sourceAgent, ...message });
|
|
511
|
+
results.push(result);
|
|
512
|
+
messageResults.push({ index, processed: true, externalMessageId: message.externalMessageId, ...result });
|
|
513
|
+
}
|
|
514
|
+
catch (error) {
|
|
515
|
+
const failedMessage = error instanceof Error ? error.message : String(error);
|
|
516
|
+
messageResults.push({ index, processed: false, externalMessageId: message.externalMessageId, error: failedMessage });
|
|
517
|
+
return jsonResult({
|
|
518
|
+
processedCount: results.length, failedIndex: index, failedMessage,
|
|
519
|
+
resumeFromIndex: index, messageResults,
|
|
520
|
+
warnings: autoIdentityUsed ? ['auto_identity_not_safe_across_split_batches'] : [],
|
|
521
|
+
}, true);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const episodeIds = [...new Set(results.map((result) => result.episodeId).filter((id) => Boolean(id)))];
|
|
525
|
+
const receipts = input.sealBatch === true
|
|
526
|
+
? episodeIds.map((episodeId) => kernel.sealImportedEpisode(episodeId, { reason: 'mcp_batch_boundary', force: input.forceSeal === true }))
|
|
527
|
+
: [];
|
|
528
|
+
return jsonResult({
|
|
529
|
+
imported: results.filter((result) => result.created).length,
|
|
530
|
+
duplicates: results.filter((result) => !result.created).length,
|
|
531
|
+
episodeIds,
|
|
532
|
+
unassignedEventIds: results.filter((result) => !result.assigned && !result.ignored).map((result) => result.eventId),
|
|
533
|
+
ignoredEventIds: results.filter((result) => result.ignored).map((result) => result.eventId),
|
|
534
|
+
closureReceipts: receipts, dreamRan: false,
|
|
535
|
+
processedCount: results.length, messageResults,
|
|
536
|
+
warnings: autoIdentityUsed ? ['auto_identity_not_safe_across_split_batches'] : [],
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
function episodeStatus(kernel, input) {
|
|
540
|
+
const projectId = optionalString(input.projectId);
|
|
541
|
+
const episodes = kernel.listEpisodes({
|
|
542
|
+
projectId, sessionId: optionalString(input.sessionId), limit: optionalNumber(input.limit),
|
|
543
|
+
});
|
|
544
|
+
const dream = kernel.getEpisodeDreamStatus(projectId);
|
|
545
|
+
const dreamBacklogAvailable = dream.pending + dream.retryScheduled + dream.processing > 0;
|
|
546
|
+
const failedDreamAvailable = dream.failedRetryable + dream.failedTerminal > 0;
|
|
547
|
+
const recentRawAvailable = episodes.length > 0 || kernel.episodeStore.countUnassignedRawEvents(projectId) > 0;
|
|
548
|
+
const recommendedActions = [];
|
|
549
|
+
if (dreamBacklogAvailable)
|
|
550
|
+
recommendedActions.push('cogmem_dream_tick_with_maintenance_mode');
|
|
551
|
+
if (dream.failedRetryable > 0)
|
|
552
|
+
recommendedActions.push('cogmem_dream_retry');
|
|
553
|
+
if (dream.failedTerminal > 0)
|
|
554
|
+
recommendedActions.push('inspect_terminal_dream_failure');
|
|
555
|
+
if (kernel.episodeStore.countUnassignedRawEvents(projectId) > 0)
|
|
556
|
+
recommendedActions.push('cogmem_episode_repair');
|
|
557
|
+
const highValueOpen = episodes.some((episode) => episode.status === 'open' && episode.importance >= 0.8);
|
|
558
|
+
const maturingSoftSeal = episodes.some((episode) => episode.status === 'soft_sealed');
|
|
559
|
+
const semanticMemoryMayLag = dreamBacklogAvailable || failedDreamAvailable || highValueOpen || maturingSoftSeal
|
|
560
|
+
|| kernel.episodeStore.countUnassignedRawEvents(projectId) > 0;
|
|
561
|
+
return jsonResult({
|
|
562
|
+
episodes,
|
|
563
|
+
dream,
|
|
564
|
+
recentRawAvailable,
|
|
565
|
+
recentEpisodesAvailable: episodes.length > 0,
|
|
566
|
+
dreamBacklogAvailable,
|
|
567
|
+
semanticMemoryMayLag,
|
|
568
|
+
recommendedActions,
|
|
569
|
+
recommendedAction: recommendedActions[0] || 'none',
|
|
570
|
+
warnings: recentRawAvailable ? [] : ['no_recent_episode_ingestion_detected'],
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
function episodeRepair(kernel, input) {
|
|
574
|
+
const projectId = requiredString(input.projectId, 'projectId');
|
|
575
|
+
const operation = requiredString(input.operation, 'operation');
|
|
576
|
+
if (operation === 'move-event')
|
|
577
|
+
return kernel.repairEpisode({
|
|
578
|
+
operation, projectId, eventId: requiredString(input.eventId, 'eventId'), targetEpisodeId: requiredString(input.targetEpisodeId, 'targetEpisodeId'),
|
|
579
|
+
});
|
|
580
|
+
if (operation === 'split')
|
|
581
|
+
return kernel.repairEpisode({
|
|
582
|
+
operation, projectId, episodeId: requiredString(input.episodeId, 'episodeId'),
|
|
583
|
+
eventIds: Array.isArray(input.eventIds) ? input.eventIds.map(String) : [],
|
|
584
|
+
});
|
|
585
|
+
if (operation === 'merge')
|
|
586
|
+
return kernel.repairEpisode({
|
|
587
|
+
operation, projectId, sourceEpisodeId: requiredString(input.sourceEpisodeId, 'sourceEpisodeId'),
|
|
588
|
+
targetEpisodeId: requiredString(input.targetEpisodeId, 'targetEpisodeId'),
|
|
589
|
+
});
|
|
590
|
+
if (operation === 'reclassify')
|
|
591
|
+
return kernel.repairEpisode({
|
|
592
|
+
operation, projectId, episodeId: requiredString(input.episodeId, 'episodeId'),
|
|
593
|
+
episodeType: optionalString(input.episodeType), topicPath: optionalString(input.topicPath), importance: optionalNumber(input.importance),
|
|
594
|
+
});
|
|
595
|
+
if (operation === 'requeue-dream' || operation === 'invalidate-dream-run')
|
|
596
|
+
return kernel.repairEpisode({
|
|
597
|
+
operation, projectId, episodeId: requiredString(input.episodeId, 'episodeId'), mode: optionalDreamMode(input.mode) === 'auto' ? 'normal' : optionalDreamMode(input.mode),
|
|
598
|
+
});
|
|
599
|
+
throw new Error(`invalid episode repair operation: ${operation}`);
|
|
600
|
+
}
|
|
601
|
+
function dreamRecommendation(kernel, projectId, requestedMode) {
|
|
602
|
+
const status = kernel.getEpisodeDreamStatus(projectId);
|
|
603
|
+
const backlog = status.pending + status.retryScheduled;
|
|
604
|
+
return {
|
|
605
|
+
dryRun: true,
|
|
606
|
+
maintenanceModeRequired: true,
|
|
607
|
+
requestedMode: requestedMode || 'auto',
|
|
608
|
+
recommendedMode: backlog === 0 ? 'none' : backlog === 1 ? 'micro' : 'normal',
|
|
609
|
+
backlog,
|
|
610
|
+
status,
|
|
611
|
+
instruction: 'Call only during idle maintenance or an explicit user/admin maintenance request with maintenanceMode=true.',
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
function optionalEpisodeClosureMode(value) {
|
|
615
|
+
const mode = optionalString(value) || 'manual';
|
|
616
|
+
if (mode === 'soft' || mode === 'hard' || mode === 'manual' || mode === 'batch')
|
|
617
|
+
return mode;
|
|
618
|
+
throw new Error('mode must be soft, hard, manual, or batch');
|
|
619
|
+
}
|
|
620
|
+
function prospective(kernel, input) {
|
|
621
|
+
const service = kernel.prospectiveMemoryService;
|
|
622
|
+
const action = requiredString(input.action, 'action');
|
|
623
|
+
if (action === 'list') {
|
|
624
|
+
const statuses = optionalProspectiveStatuses(input.statuses);
|
|
625
|
+
return jsonResult({ items: service.list({
|
|
626
|
+
projectId: requiredString(input.projectId, 'projectId'),
|
|
627
|
+
statuses,
|
|
628
|
+
limit: optionalNumber(input.limit),
|
|
629
|
+
}) });
|
|
630
|
+
}
|
|
631
|
+
if (action === 'due') {
|
|
632
|
+
return jsonResult({ items: service.listDue({
|
|
633
|
+
projectId: requiredString(input.projectId, 'projectId'),
|
|
634
|
+
atTime: optionalNumber(input.atTime),
|
|
635
|
+
limit: optionalNumber(input.limit),
|
|
636
|
+
}) });
|
|
637
|
+
}
|
|
638
|
+
if (action === 'create') {
|
|
639
|
+
return jsonResult(service.propose({
|
|
640
|
+
projectId: requiredString(input.projectId, 'projectId'),
|
|
641
|
+
candidateType: requiredString(input.candidateType, 'candidateType'),
|
|
642
|
+
canonicalKey: requiredString(input.canonicalKey, 'canonicalKey'),
|
|
643
|
+
title: requiredString(input.title, 'title'),
|
|
644
|
+
details: optionalString(input.details),
|
|
645
|
+
evidenceEventIds: requiredStringArray(input.evidenceEventIds, 'evidenceEventIds'),
|
|
646
|
+
proposedBy: 'operator',
|
|
647
|
+
dueAt: optionalNumber(input.dueAt),
|
|
648
|
+
}));
|
|
649
|
+
}
|
|
650
|
+
const candidateId = requiredString(input.candidateId, 'candidateId');
|
|
651
|
+
const projectId = requiredString(input.projectId, 'projectId');
|
|
652
|
+
if (action === 'confirm') {
|
|
653
|
+
return jsonResult(service.resolve(candidateId, {
|
|
654
|
+
action,
|
|
655
|
+
confirmationEvidenceEventId: requiredString(input.confirmationEvidenceEventId, 'confirmationEvidenceEventId'),
|
|
656
|
+
}, projectId));
|
|
657
|
+
}
|
|
658
|
+
if (action === 'defer') {
|
|
659
|
+
const deferredUntil = optionalNumber(input.deferredUntil);
|
|
660
|
+
if (deferredUntil === undefined)
|
|
661
|
+
throw new Error('deferredUntil must be a finite number');
|
|
662
|
+
return jsonResult(service.resolve(candidateId, { action, deferredUntil }, projectId));
|
|
663
|
+
}
|
|
664
|
+
if (action === 'reject' || action === 'complete' || action === 'expire') {
|
|
665
|
+
return jsonResult(service.resolve(candidateId, { action }, projectId));
|
|
666
|
+
}
|
|
667
|
+
throw new Error(`Unknown prospective action: ${action}`);
|
|
668
|
+
}
|
|
669
|
+
async function rememberTurn(kernel, input) {
|
|
670
|
+
const memory = new KernelAgentMemoryBackend(kernel);
|
|
671
|
+
const result = await memory.rememberTurnWithResult({
|
|
672
|
+
agentId: requiredString(input.agentId, 'agentId'),
|
|
673
|
+
projectId: requiredString(input.projectId, 'projectId'),
|
|
674
|
+
sessionId: requiredString(input.sessionId, 'sessionId'),
|
|
675
|
+
userText: requiredString(input.userText, 'userText'),
|
|
676
|
+
assistantText: optionalString(input.assistantText),
|
|
677
|
+
ingestMode: optionalTurnIngestMode(input.ingestMode),
|
|
678
|
+
collection: optionalString(input.collection),
|
|
679
|
+
timestamp: optionalNumber(input.timestamp),
|
|
680
|
+
});
|
|
681
|
+
return jsonResult({ ok: true, ...result });
|
|
682
|
+
}
|
|
683
|
+
function recall(kernel, input, includeExplanation) {
|
|
684
|
+
const query = requiredString(input.query, 'query');
|
|
685
|
+
const requestedAgentId = optionalString(input.agentId);
|
|
686
|
+
const requestedProjectId = optionalString(input.projectId);
|
|
687
|
+
const limit = optionalNumber(input.limit);
|
|
688
|
+
const startTime = optionalTime(input.since, 'since');
|
|
689
|
+
const endTime = optionalTime(input.until, 'until');
|
|
690
|
+
const agentId = requestedAgentId || requestedProjectId || 'openclaw';
|
|
691
|
+
const projectId = requestedProjectId || agentId;
|
|
692
|
+
if (!includeExplanation) {
|
|
693
|
+
const memory = new KernelAgentMemoryBackend(kernel);
|
|
694
|
+
const intent = kernel.contextCortex.classifyIntent(query);
|
|
695
|
+
const strategyCapsule = kernel.strategyCortex.plan({ query, intent, projectId });
|
|
696
|
+
const result = memory.recall({
|
|
697
|
+
agentId,
|
|
698
|
+
projectId,
|
|
699
|
+
collection: optionalString(input.collection),
|
|
700
|
+
query,
|
|
701
|
+
limit,
|
|
702
|
+
startTime,
|
|
703
|
+
endTime,
|
|
704
|
+
retrievalPolicy: strategyCapsule.retrievalPolicy,
|
|
705
|
+
});
|
|
706
|
+
const episodes = kernel.listEpisodes({ projectId, limit: 20 });
|
|
707
|
+
const recentEpisodeIngestion = episodes.length > 0;
|
|
708
|
+
const semanticMemoryMayLag = !recentEpisodeIngestion
|
|
709
|
+
|| episodes.some((episode) => episode.status !== 'sealed' || episode.dreamStatus === 'queued' || episode.dreamStatus === 'failed')
|
|
710
|
+
|| kernel.episodeStore.countUnassignedRawEvents(projectId) > 0;
|
|
711
|
+
const warnings = recentEpisodeIngestion ? [] : ['no_recent_episode_ingestion_detected', 'semantic_memory_may_lag'];
|
|
712
|
+
return jsonResult({
|
|
713
|
+
query,
|
|
714
|
+
projectId,
|
|
715
|
+
agentId,
|
|
716
|
+
recallMode: result.recallMode,
|
|
717
|
+
fallbackUsed: result.fallbackUsed,
|
|
718
|
+
queryPlan: result.queryPlan,
|
|
719
|
+
decisionTrace: result.decisionTrace,
|
|
720
|
+
strategyCapsule,
|
|
721
|
+
narrative: result.narrative,
|
|
722
|
+
temporalLabels: result.temporalTraversal?.labels,
|
|
723
|
+
items: result.items,
|
|
724
|
+
warnings,
|
|
725
|
+
semanticMemoryMayLag,
|
|
726
|
+
suggestedTool: recentEpisodeIngestion ? undefined : 'cogmem_episode_append_or_import',
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
const explanation = explainRecallWithKernel(kernel, {
|
|
730
|
+
query,
|
|
731
|
+
agentId,
|
|
732
|
+
projectId,
|
|
733
|
+
collection: optionalString(input.collection),
|
|
734
|
+
limit,
|
|
735
|
+
startTime,
|
|
736
|
+
endTime,
|
|
737
|
+
});
|
|
738
|
+
return jsonResult(explanation);
|
|
739
|
+
}
|
|
740
|
+
function openRuntimeKernel(runtime) {
|
|
741
|
+
if (runtime.kernel)
|
|
742
|
+
return { kernel: runtime.kernel, shouldClose: false };
|
|
743
|
+
if (runtime.dbPath) {
|
|
744
|
+
return { kernel: createMemoryKernel({ dbPath: runtime.dbPath }), shouldClose: true };
|
|
745
|
+
}
|
|
746
|
+
return {
|
|
747
|
+
kernel: createMemoryKernelFromConfig({
|
|
748
|
+
configPath: runtime.configPath,
|
|
749
|
+
cwd: runtime.cwd,
|
|
750
|
+
}),
|
|
751
|
+
shouldClose: true,
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
function jsonResult(payload, isError = false) {
|
|
755
|
+
return {
|
|
756
|
+
content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
|
|
757
|
+
structuredContent: payload,
|
|
758
|
+
isError: isError || undefined,
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
function requiredString(value, field) {
|
|
762
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
763
|
+
throw new Error(`${field} must be a non-empty string`);
|
|
764
|
+
}
|
|
765
|
+
return value;
|
|
766
|
+
}
|
|
767
|
+
function optionalString(value) {
|
|
768
|
+
return typeof value === 'string' && value.trim() ? value : undefined;
|
|
769
|
+
}
|
|
770
|
+
function requiredCandidateReviewAction(value) {
|
|
771
|
+
const action = requiredString(value, 'action');
|
|
772
|
+
if (action === 'approve' || action === 'reject' || action === 'defer' || action === 'supersede' || action === 'relink')
|
|
773
|
+
return action;
|
|
774
|
+
throw new Error('action must be approve, reject, defer, supersede, or relink');
|
|
775
|
+
}
|
|
776
|
+
function requiredStringArray(value, field) {
|
|
777
|
+
if (!Array.isArray(value) || value.length === 0 || value.some((item) => typeof item !== 'string' || item.trim() === '')) {
|
|
778
|
+
throw new Error(`${field} must be a non-empty string array`);
|
|
779
|
+
}
|
|
780
|
+
return value;
|
|
781
|
+
}
|
|
782
|
+
function optionalProspectiveStatuses(value) {
|
|
783
|
+
if (value === undefined)
|
|
784
|
+
return undefined;
|
|
785
|
+
const statuses = requiredStringArray(value, 'statuses');
|
|
786
|
+
const allowed = new Set(['pending', 'confirmed', 'deferred', 'rejected', 'completed', 'expired']);
|
|
787
|
+
if (statuses.some((status) => !allowed.has(status)))
|
|
788
|
+
throw new Error('statuses contains an invalid prospective status');
|
|
789
|
+
return statuses;
|
|
790
|
+
}
|
|
791
|
+
function optionalNumber(value) {
|
|
792
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
793
|
+
}
|
|
794
|
+
function optionalTurnIngestMode(value) {
|
|
795
|
+
if (value === undefined || value === null || value === '')
|
|
796
|
+
return undefined;
|
|
797
|
+
if (value === 'immediate_compile'
|
|
798
|
+
|| value === 'selective_compile'
|
|
799
|
+
|| value === 'raw_archive_only'
|
|
800
|
+
|| value === 'raw_then_dream') {
|
|
801
|
+
return value;
|
|
802
|
+
}
|
|
803
|
+
throw new Error('ingestMode must be one of immediate_compile, selective_compile, raw_archive_only, raw_then_dream');
|
|
804
|
+
}
|
|
805
|
+
function requiredEpisodeRole(value) {
|
|
806
|
+
const role = requiredString(value, 'role');
|
|
807
|
+
if (role === 'user' || role === 'assistant' || role === 'agent' || role === 'tool' || role === 'system' || role === 'narrator')
|
|
808
|
+
return role;
|
|
809
|
+
throw new Error('role must be one of user, assistant, agent, tool, system, narrator');
|
|
810
|
+
}
|
|
811
|
+
function optionalDreamMode(value) {
|
|
812
|
+
const mode = optionalString(value);
|
|
813
|
+
if (!mode)
|
|
814
|
+
return undefined;
|
|
815
|
+
if (mode === 'auto' || mode === 'micro' || mode === 'normal' || mode === 'deep')
|
|
816
|
+
return mode;
|
|
817
|
+
throw new Error('mode must be one of auto, micro, normal, deep');
|
|
818
|
+
}
|
|
819
|
+
function optionalTime(value, field) {
|
|
820
|
+
if (value === undefined || value === null)
|
|
821
|
+
return undefined;
|
|
822
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
823
|
+
return value;
|
|
824
|
+
if (typeof value === 'string') {
|
|
825
|
+
if (/^\d+$/.test(value))
|
|
826
|
+
return Number(value);
|
|
827
|
+
const parsed = Date.parse(value);
|
|
828
|
+
if (!Number.isNaN(parsed))
|
|
829
|
+
return parsed;
|
|
830
|
+
}
|
|
831
|
+
throw new Error(`${field} must be a timestamp or parseable date`);
|
|
832
|
+
}
|