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,908 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import { isOperationalNoiseText } from '../recall/RecallGovernance.js';
|
|
3
|
+
import { eventTextForMemory } from '../episode/CogmemBlockStripper.js';
|
|
4
|
+
const PREFERENCE_PATTERN = /(请以后|以后请|始终|总是|偏好|喜欢|希望|不要|别|必须|一定要|长期目标|目标是|约束|边界|本地优先|local-first|prefer|preference|always|never|must|do not|don't|goal|constraint|boundary)/iu;
|
|
5
|
+
const CORRECTION_PATTERN = /((?:^|[。!?.!?\s])不[,,]|(?<!对)不对|(?<!是)不是|纠正|更正|应该是|推翻|修正|actually|correction|instead)/iu;
|
|
6
|
+
const LEADING_CORRECTION_PATTERN = /^\s*不[,,]/u;
|
|
7
|
+
export class DreamCuratorWorker {
|
|
8
|
+
deps;
|
|
9
|
+
constructor(deps) {
|
|
10
|
+
this.deps = deps;
|
|
11
|
+
}
|
|
12
|
+
async run(options = {}) {
|
|
13
|
+
const before = this.deps.dreamLedgerStore.getStatus(options.projectId);
|
|
14
|
+
const explicitEpisodeRun = Array.isArray(options.eventIds);
|
|
15
|
+
const events = explicitEpisodeRun
|
|
16
|
+
? options.eventIds
|
|
17
|
+
.slice(0, Math.max(1, Math.min(options.limit ?? 100, 500)))
|
|
18
|
+
.map((eventId) => this.deps.eventStore.getEvent(eventId))
|
|
19
|
+
.filter((event) => Boolean(event))
|
|
20
|
+
.filter((event) => !options.projectId || event.projectId === options.projectId)
|
|
21
|
+
: this.deps.eventStore.listRawEventsAfterGlobalSeq({
|
|
22
|
+
projectId: options.projectId,
|
|
23
|
+
afterGlobalSeq: before.lastDreamedGlobalSeq,
|
|
24
|
+
limit: options.limit ?? 100,
|
|
25
|
+
});
|
|
26
|
+
if (events.length === 0) {
|
|
27
|
+
return {
|
|
28
|
+
projectId: options.projectId,
|
|
29
|
+
skipped: true,
|
|
30
|
+
reason: explicitEpisodeRun ? 'episode_has_no_raw_events' : 'no_undreamed_raw_events',
|
|
31
|
+
processedEventCount: 0,
|
|
32
|
+
dreamableEventCount: 0,
|
|
33
|
+
candidateCount: 0,
|
|
34
|
+
status: before,
|
|
35
|
+
candidates: [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const now = options.now ?? Date.now();
|
|
39
|
+
const maxGlobalSeq = Math.max(...events.map((event) => event.globalSeq || 0));
|
|
40
|
+
const dreamableEvents = events.filter((event) => this.isDreamableEvent(event));
|
|
41
|
+
const allowedEvidence = new Set(options.sourceEpisodeEventIds || events.map((event) => event.eventId));
|
|
42
|
+
const candidateInputs = (await this.buildCandidates(dreamableEvents, options, now))
|
|
43
|
+
.filter((candidate) => {
|
|
44
|
+
const evidence = Array.isArray(candidate.evidence) ? candidate.evidence : [];
|
|
45
|
+
const content = objectRecord(candidate.content);
|
|
46
|
+
if (candidate.status === 'rejected' && content.source === 'dream_curator_provider_warning') {
|
|
47
|
+
return evidence.length === 1
|
|
48
|
+
&& typeof evidence[0].eventId === 'string'
|
|
49
|
+
&& evidence[0].eventId.startsWith('system-diagnostic:');
|
|
50
|
+
}
|
|
51
|
+
return evidence.length > 0
|
|
52
|
+
&& evidence.every((item) => typeof item.eventId === 'string' && allowedEvidence.has(item.eventId));
|
|
53
|
+
})
|
|
54
|
+
.slice(0, Math.max(1, Math.min(options.maxCandidates ?? 500, 500)))
|
|
55
|
+
.map((candidate) => ({
|
|
56
|
+
...candidate,
|
|
57
|
+
content: options.sourceEpisodeId && objectRecord(candidate.content).source !== 'dream_curator_provider_warning'
|
|
58
|
+
? {
|
|
59
|
+
...objectRecord(candidate.content),
|
|
60
|
+
sourceEpisodeId: options.sourceEpisodeId,
|
|
61
|
+
evidenceAuthority: 'raw_event_ids_only',
|
|
62
|
+
evidenceEventIds: candidate.evidence.map((item) => item.eventId).filter(Boolean),
|
|
63
|
+
dreamMode: options.dreamMode || 'normal',
|
|
64
|
+
episodeType: options.episodeType,
|
|
65
|
+
closureReason: options.closureReason,
|
|
66
|
+
}
|
|
67
|
+
: candidate.content,
|
|
68
|
+
}));
|
|
69
|
+
const providerConfig = this.resolveProviderConfig(options);
|
|
70
|
+
const run = this.deps.candidateStore.insertRun({
|
|
71
|
+
projectId: options.projectId,
|
|
72
|
+
sessionId: this.singleSessionId(dreamableEvents),
|
|
73
|
+
sourceNeuronIds: [],
|
|
74
|
+
modelProvider: providerConfig.provider,
|
|
75
|
+
modelName: providerConfig.modelName,
|
|
76
|
+
mode: `dream_curator_${providerConfig.provider}_${options.mode ?? 'candidate'}_${options.dreamMode ?? 'normal'}_v1`,
|
|
77
|
+
promptHash: hash(JSON.stringify(events.map((event) => ({
|
|
78
|
+
eventId: event.eventId,
|
|
79
|
+
globalSeq: event.globalSeq,
|
|
80
|
+
contentHash: event.contentHash,
|
|
81
|
+
})))),
|
|
82
|
+
outputHash: hash(JSON.stringify(candidateInputs.map((candidate) => ({
|
|
83
|
+
candidateType: candidate.candidateType,
|
|
84
|
+
content: candidate.content,
|
|
85
|
+
evidence: candidate.evidence,
|
|
86
|
+
})))),
|
|
87
|
+
status: 'succeeded',
|
|
88
|
+
createdAt: now,
|
|
89
|
+
});
|
|
90
|
+
const inserted = this.deps.candidateStore.insertCandidates(candidateInputs.map((candidate) => ({ ...candidate, runId: run.runId, createdAt: now })));
|
|
91
|
+
const status = explicitEpisodeRun
|
|
92
|
+
? before
|
|
93
|
+
: this.deps.dreamLedgerStore.markDreamed(options.projectId, maxGlobalSeq, now);
|
|
94
|
+
return {
|
|
95
|
+
runId: run.runId,
|
|
96
|
+
projectId: options.projectId,
|
|
97
|
+
skipped: false,
|
|
98
|
+
processedEventCount: events.length,
|
|
99
|
+
dreamableEventCount: dreamableEvents.length,
|
|
100
|
+
candidateCount: inserted.length,
|
|
101
|
+
maxGlobalSeq,
|
|
102
|
+
status,
|
|
103
|
+
candidates: inserted,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async buildCandidates(events, options, now) {
|
|
107
|
+
if (events.length === 0)
|
|
108
|
+
return [];
|
|
109
|
+
const status = options.mode === 'shadow' ? 'shadow' : 'candidate';
|
|
110
|
+
const candidates = [];
|
|
111
|
+
const userEvents = events.filter((event) => event.role === 'user');
|
|
112
|
+
if (userEvents.length > 0) {
|
|
113
|
+
candidates.push({
|
|
114
|
+
candidateType: 'summary',
|
|
115
|
+
status,
|
|
116
|
+
confidence: 0.74,
|
|
117
|
+
content: {
|
|
118
|
+
projectId: options.projectId,
|
|
119
|
+
sessionId: this.singleSessionId(events),
|
|
120
|
+
scope: this.singleSessionId(events) ? 'session' : 'turn_window',
|
|
121
|
+
summary: summarizeEvents(events),
|
|
122
|
+
topics: extractTopics(events.map(eventText).join('\n')),
|
|
123
|
+
source: 'mixed_user_assistant_raw_ledger',
|
|
124
|
+
durability: 'session',
|
|
125
|
+
session_hint_only: true,
|
|
126
|
+
not_user_owned: true,
|
|
127
|
+
not_durable_belief: true,
|
|
128
|
+
risk: 'curator_summary_candidate_requires_governance',
|
|
129
|
+
windowStart: Math.min(...events.map((event) => event.occurredAt)),
|
|
130
|
+
windowEnd: Math.max(...events.map((event) => event.occurredAt)),
|
|
131
|
+
},
|
|
132
|
+
evidence: events.map((event) => this.toEvidence(event)),
|
|
133
|
+
createdAt: now,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
for (const event of userEvents) {
|
|
137
|
+
const text = eventText(event);
|
|
138
|
+
if (PREFERENCE_PATTERN.test(text)) {
|
|
139
|
+
candidates.push({
|
|
140
|
+
candidateType: 'preferences',
|
|
141
|
+
status,
|
|
142
|
+
confidence: 0.8,
|
|
143
|
+
content: {
|
|
144
|
+
projectId: event.projectId || options.projectId,
|
|
145
|
+
subject: 'user',
|
|
146
|
+
predicate: preferencePredicate(text),
|
|
147
|
+
object: text,
|
|
148
|
+
statement: text,
|
|
149
|
+
category: preferenceCategory(text),
|
|
150
|
+
tags: preferenceTags(text),
|
|
151
|
+
source: 'explicit_user_statement',
|
|
152
|
+
durability: 'durable',
|
|
153
|
+
risk: 'curator_preference_candidate_requires_governance',
|
|
154
|
+
},
|
|
155
|
+
evidence: [this.toEvidence(event)],
|
|
156
|
+
createdAt: now,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (isExplicitCorrectionCandidate(text)) {
|
|
160
|
+
const resolution = this.deps.correctionResolver?.resolve({
|
|
161
|
+
projectId: event.projectId || options.projectId || '', query: text,
|
|
162
|
+
topicPath: typeof event.payload === 'object' && event.payload && typeof event.payload.topicPath === 'string'
|
|
163
|
+
? String(event.payload.topicPath)
|
|
164
|
+
: undefined,
|
|
165
|
+
}) ?? { status: 'needs_review', candidates: [], reason: 'correction_resolver_unavailable' };
|
|
166
|
+
candidates.push({
|
|
167
|
+
candidateType: 'correction',
|
|
168
|
+
status: resolution.status === 'resolved' ? status : 'needs_confirmation',
|
|
169
|
+
statusReason: resolution.status === 'resolved'
|
|
170
|
+
? undefined
|
|
171
|
+
: 'orphan_correction_requires_target_review',
|
|
172
|
+
confidence: 0.78,
|
|
173
|
+
content: {
|
|
174
|
+
projectId: event.projectId || options.projectId,
|
|
175
|
+
statement: text,
|
|
176
|
+
sourceEventId: event.eventId,
|
|
177
|
+
source: 'explicit_user_statement',
|
|
178
|
+
durability: 'event',
|
|
179
|
+
correctionKind: 'user_clarification_or_revision',
|
|
180
|
+
correctedClaimKey: resolution.target?.canonicalKey || null,
|
|
181
|
+
correctedBeliefCandidateIds: resolution.target ? [resolution.target.beliefId] : [],
|
|
182
|
+
correctionResolution: resolution.status,
|
|
183
|
+
correctionResolutionReason: resolution.reason,
|
|
184
|
+
correctionTargetSearchQuery: truncate(text, 240),
|
|
185
|
+
governance: 'organizational_trace_only',
|
|
186
|
+
risk: 'correction_requires_prior_claim_binding_before_belief_change',
|
|
187
|
+
},
|
|
188
|
+
evidence: [this.toEvidence(event)],
|
|
189
|
+
createdAt: now,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (options.episodeType === 'decision' || options.semanticSummary?.candidateTypes.includes('decision')) {
|
|
194
|
+
const decisionEvidence = userEvents.length ? userEvents : events;
|
|
195
|
+
candidates.push({
|
|
196
|
+
candidateType: 'temporal_fact_update',
|
|
197
|
+
status: userEvents.length ? status : 'needs_confirmation',
|
|
198
|
+
confidence: userEvents.length ? 0.82 : 0.58,
|
|
199
|
+
content: {
|
|
200
|
+
projectId: options.projectId,
|
|
201
|
+
timelineType: 'decision',
|
|
202
|
+
statement: options.semanticSummary?.decision || summarizeEvents(decisionEvidence),
|
|
203
|
+
occurredAt: Math.min(...decisionEvidence.map((event) => event.occurredAt)),
|
|
204
|
+
startSeq: minDefined(decisionEvidence.map((event) => event.globalSeq)),
|
|
205
|
+
endSeq: maxDefined(decisionEvidence.map((event) => event.globalSeq)),
|
|
206
|
+
source: userEvents.length ? 'explicit_user_decision_episode' : 'mixed_decision_episode_requires_review',
|
|
207
|
+
governance: 'candidate_only_cpu_governance_required',
|
|
208
|
+
notDurableWithoutUserEvidence: userEvents.length === 0,
|
|
209
|
+
},
|
|
210
|
+
evidence: decisionEvidence.map((event) => this.toEvidence(event)),
|
|
211
|
+
promotionTargetType: 'temporal_decision',
|
|
212
|
+
createdAt: now,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
const relationByEvent = new Map((options.episodeRelations || []).map((item) => [item.eventId, item.relation]));
|
|
216
|
+
for (let index = 0; index < events.length; index += 1) {
|
|
217
|
+
const confirmation = events[index];
|
|
218
|
+
if (relationByEvent.get(confirmation.eventId) !== 'accepts_assistant_proposal' || confirmation.role !== 'user')
|
|
219
|
+
continue;
|
|
220
|
+
let proposal;
|
|
221
|
+
for (let priorIndex = index - 1; priorIndex >= Math.max(0, index - 8); priorIndex -= 1) {
|
|
222
|
+
const prior = events[priorIndex];
|
|
223
|
+
const relation = relationByEvent.get(prior.eventId);
|
|
224
|
+
if (prior.role === 'user' && (relation === 'rejects_assistant_proposal' || relation === 'corrects_previous'))
|
|
225
|
+
break;
|
|
226
|
+
if (relation === 'assistant_proposal'
|
|
227
|
+
&& prior.sessionId === confirmation.sessionId
|
|
228
|
+
&& (!prior.threadId || !confirmation.threadId || prior.threadId === confirmation.threadId)) {
|
|
229
|
+
proposal = prior;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (proposal) {
|
|
234
|
+
candidates.push({
|
|
235
|
+
candidateType: 'semantic_relation',
|
|
236
|
+
status,
|
|
237
|
+
confidence: 0.88,
|
|
238
|
+
content: {
|
|
239
|
+
projectId: options.projectId,
|
|
240
|
+
relation: 'assistant_proposal_confirmed_by_user',
|
|
241
|
+
proposalEvidenceEventId: proposal.eventId,
|
|
242
|
+
confirmationEvidenceEventId: confirmation.eventId,
|
|
243
|
+
evidenceKind: 'assistant_proposal_confirmed_by_user',
|
|
244
|
+
governance: 'candidate_only_cpu_governance_required',
|
|
245
|
+
},
|
|
246
|
+
evidence: [this.toEvidence(proposal), this.toEvidence(confirmation)],
|
|
247
|
+
promotionTargetType: 'confirmed_proposal_relation',
|
|
248
|
+
createdAt: now,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
for (const event of events) {
|
|
253
|
+
if (event.rawEventType === 'tool_result' && event.parentEventId) {
|
|
254
|
+
candidates.push({
|
|
255
|
+
candidateType: 'causalLinks',
|
|
256
|
+
status,
|
|
257
|
+
confidence: 0.68,
|
|
258
|
+
content: {
|
|
259
|
+
projectId: event.projectId || options.projectId,
|
|
260
|
+
relation: 'tool_result_for',
|
|
261
|
+
causeEventId: event.parentEventId,
|
|
262
|
+
effectEventId: event.eventId,
|
|
263
|
+
statement: eventText(event),
|
|
264
|
+
source: 'tool_observation_candidate',
|
|
265
|
+
risk: 'tool_observation_requires_governance',
|
|
266
|
+
},
|
|
267
|
+
evidence: [this.toEvidence(event)],
|
|
268
|
+
createdAt: now,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
candidates.push(...this.buildSemanticOrganizationCandidates(events, now, status, options));
|
|
273
|
+
const providerCandidates = await this.buildProviderCandidates(events, options, now, status);
|
|
274
|
+
candidates.push(...providerCandidates);
|
|
275
|
+
return candidates;
|
|
276
|
+
}
|
|
277
|
+
async buildProviderCandidates(events, options, now, status) {
|
|
278
|
+
const generate = this.resolveGenerateText(options);
|
|
279
|
+
if (!generate)
|
|
280
|
+
return [];
|
|
281
|
+
const systemPrompt = [
|
|
282
|
+
'You are the Cogmem Memory Curator / Dream Worker.',
|
|
283
|
+
'You inspect raw chronological ledger events and propose memory governance candidates only.',
|
|
284
|
+
'',
|
|
285
|
+
'Authority boundaries:',
|
|
286
|
+
'- You do not promote anything to active memory.',
|
|
287
|
+
'- You do not rewrite verified facts.',
|
|
288
|
+
'- You do not decide final memory status.',
|
|
289
|
+
'- CPU governance will validate, promote, reject, suppress, or supersede candidates later.',
|
|
290
|
+
'',
|
|
291
|
+
'Evidence rules:',
|
|
292
|
+
'- Every candidate must be traceable to exact evidenceEventIds from the supplied raw ledger events.',
|
|
293
|
+
'- User-owned durable candidates such as preferences, goals, boundaries, corrections, and long-term constraints must be supported by raw ledger events whose role is "user".',
|
|
294
|
+
'- Assistant messages may provide conversational context, but they must not be treated as user preferences, user goals, user corrections, or user boundaries unless a user event explicitly confirms them.',
|
|
295
|
+
'- Tool results and task events are observations only. They may support diagnostic or causal-link candidates, but they must not create user-owned memory by themselves.',
|
|
296
|
+
'- If an event contains <COGMEM_RECALL_CONTEXT>, <COGMEM_TURN_BRIDGE>, <COGMEM_SESSION_STATE>, or <COGMEM_STRATEGY_CONTEXT>, treat that content as host-side memory context metadata, not as user-authored evidence.',
|
|
297
|
+
'',
|
|
298
|
+
'Output rules:',
|
|
299
|
+
'- Return concise strict JSON only.',
|
|
300
|
+
'- Do not include markdown.',
|
|
301
|
+
'- Do not expose hidden chain-of-thought.',
|
|
302
|
+
'- Include uncertainty and source limitations inside candidate fields, not as reasoning prose.',
|
|
303
|
+
'',
|
|
304
|
+
'Dream mode rules:',
|
|
305
|
+
'- micro: extract only direct high-value candidates from this episode; do not infer cross-episode conclusions.',
|
|
306
|
+
'- normal: perform bounded deduplication and conflict hints inside the supplied episode.',
|
|
307
|
+
'- deep: inspect consistency across all supplied raw events, but never invent or scan evidence outside them.',
|
|
308
|
+
].join('\n');
|
|
309
|
+
const userPrompt = JSON.stringify({
|
|
310
|
+
task: 'Generate candidate-only memory curation output.',
|
|
311
|
+
dreamMode: options.dreamMode || 'normal',
|
|
312
|
+
episodeType: options.episodeType,
|
|
313
|
+
closureReason: options.closureReason,
|
|
314
|
+
semanticSummaryHint: options.semanticSummary
|
|
315
|
+
? { ...options.semanticSummary, evidencePolicy: 'hint_only_not_evidence' }
|
|
316
|
+
: undefined,
|
|
317
|
+
allowedCandidateBuckets: [
|
|
318
|
+
'userPreferenceCandidates',
|
|
319
|
+
'projectMemoryCandidates',
|
|
320
|
+
'longTermGoalCandidates',
|
|
321
|
+
'boundaryCandidates',
|
|
322
|
+
'failureLessonCandidates',
|
|
323
|
+
'diagnosticConclusionCandidates',
|
|
324
|
+
'sessionSummaryCandidates',
|
|
325
|
+
'topicSummaryCandidates',
|
|
326
|
+
'temporalFactUpdateCandidates',
|
|
327
|
+
'conflictCandidates',
|
|
328
|
+
'semanticTagCandidates',
|
|
329
|
+
'indexingDecisionCandidates',
|
|
330
|
+
'semanticRelationCandidates',
|
|
331
|
+
'edgeAdjustmentCandidates',
|
|
332
|
+
],
|
|
333
|
+
rawLedgerEvents: events.map((event) => ({
|
|
334
|
+
eventId: event.eventId,
|
|
335
|
+
role: event.role,
|
|
336
|
+
rawEventType: event.rawEventType,
|
|
337
|
+
threadId: event.threadId,
|
|
338
|
+
sessionId: event.sessionId,
|
|
339
|
+
projectId: event.projectId,
|
|
340
|
+
globalSeq: event.globalSeq,
|
|
341
|
+
occurredAt: event.occurredAt,
|
|
342
|
+
text: truncate(eventText(event), 1200),
|
|
343
|
+
})),
|
|
344
|
+
outputContract: {
|
|
345
|
+
format: 'strict JSON object',
|
|
346
|
+
rule: 'LLM suggests candidates only; CPU governance decides status later.',
|
|
347
|
+
requiredPerCandidate: [
|
|
348
|
+
'claim',
|
|
349
|
+
'confidence',
|
|
350
|
+
'evidenceEventIds',
|
|
351
|
+
'evidenceRoles',
|
|
352
|
+
'sourceLimitations',
|
|
353
|
+
],
|
|
354
|
+
evidenceEventIds: options.sourceEpisodeId
|
|
355
|
+
? 'non-empty array of exact raw event ids from this episode. Never use ["all"].'
|
|
356
|
+
: 'array of exact raw event ids. Use ["all"] only for legacy window-level session/topic summaries, never for user preferences, goals, corrections, or boundaries.',
|
|
357
|
+
sourcePolicy: {
|
|
358
|
+
userOwnedDurableMemory: 'requires at least one explicit user-role evidence event',
|
|
359
|
+
assistantEvidence: 'context only unless confirmed by user',
|
|
360
|
+
toolEvidence: 'observation only',
|
|
361
|
+
taskEventEvidence: 'trace only',
|
|
362
|
+
cogmemContextBlocks: 'not user-authored evidence',
|
|
363
|
+
},
|
|
364
|
+
forbidden: [
|
|
365
|
+
'hidden chain-of-thought',
|
|
366
|
+
'promotion decisions',
|
|
367
|
+
'durable user memory from assistant/tool/task-only evidence',
|
|
368
|
+
'durable user memory from COGMEM_* context blocks',
|
|
369
|
+
],
|
|
370
|
+
},
|
|
371
|
+
});
|
|
372
|
+
let raw = '';
|
|
373
|
+
try {
|
|
374
|
+
raw = await generate(systemPrompt, userPrompt);
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
const diagnostic = this.providerDiagnosticCandidate(events, now, options.projectId, 'dream_curator_provider_exception', error);
|
|
378
|
+
return diagnostic ? [diagnostic] : [];
|
|
379
|
+
}
|
|
380
|
+
const parsed = parseJsonObjectFromModel(raw);
|
|
381
|
+
if (!parsed) {
|
|
382
|
+
const diagnostic = this.providerDiagnosticCandidate(events, now, options.projectId, 'dream_curator_provider_invalid_output', raw);
|
|
383
|
+
return diagnostic ? [diagnostic] : [];
|
|
384
|
+
}
|
|
385
|
+
this.supersedeProviderWarnings(options.projectId);
|
|
386
|
+
return this.flattenProviderCandidates(parsed, events, now, status, Boolean(options.sourceEpisodeId), options.projectId);
|
|
387
|
+
}
|
|
388
|
+
flattenProviderCandidates(parsed, events, now, status, requireExactEvidence = false, authoritativeProjectId) {
|
|
389
|
+
const buckets = [
|
|
390
|
+
['userPreferenceCandidates', 'user_preference', 'user_preference'],
|
|
391
|
+
['projectMemoryCandidates', 'project_memory', 'project_memory'],
|
|
392
|
+
['longTermGoalCandidates', 'long_term_goal', 'long_term_goal'],
|
|
393
|
+
['boundaryCandidates', 'boundary', 'boundary'],
|
|
394
|
+
['failureLessonCandidates', 'failure_lesson', 'failure_lesson'],
|
|
395
|
+
['diagnosticConclusionCandidates', 'diagnostic_conclusion', 'diagnostic_conclusion'],
|
|
396
|
+
['sessionSummaryCandidates', 'session_summary', 'session_summary'],
|
|
397
|
+
['topicSummaryCandidates', 'topic_summary', 'topic_summary'],
|
|
398
|
+
['temporalFactUpdateCandidates', 'temporal_fact_update', 'temporal_fact_update'],
|
|
399
|
+
['conflictCandidates', 'conflict_candidate', 'conflict_candidate'],
|
|
400
|
+
['semanticTagCandidates', 'semantic_tags', 'semantic_tags'],
|
|
401
|
+
['indexingDecisionCandidates', 'indexing_decision', 'indexing_decision'],
|
|
402
|
+
['semanticRelationCandidates', 'semantic_relation', 'semantic_relation'],
|
|
403
|
+
['edgeAdjustmentCandidates', 'edge_adjustment', 'edge_adjustment'],
|
|
404
|
+
];
|
|
405
|
+
const candidates = [];
|
|
406
|
+
const validEventIds = new Set(events.map((event) => event.eventId));
|
|
407
|
+
for (const [bucket, candidateType, promotionTargetType] of buckets) {
|
|
408
|
+
const values = Array.isArray(parsed[bucket]) ? parsed[bucket] : [];
|
|
409
|
+
for (const value of values) {
|
|
410
|
+
if (!value || typeof value !== 'object')
|
|
411
|
+
continue;
|
|
412
|
+
const record = value;
|
|
413
|
+
const rawEvidenceIds = Array.isArray(record.evidenceEventIds)
|
|
414
|
+
? record.evidenceEventIds.map((id) => String(id)).filter(Boolean)
|
|
415
|
+
: [];
|
|
416
|
+
if (requireExactEvidence && (rawEvidenceIds.length === 0
|
|
417
|
+
|| rawEvidenceIds.includes('all')
|
|
418
|
+
|| rawEvidenceIds.some((id) => !validEventIds.has(id))))
|
|
419
|
+
continue;
|
|
420
|
+
if (isUserOwnedDurableProviderBucket(bucket)) {
|
|
421
|
+
if (rawEvidenceIds.length === 0)
|
|
422
|
+
continue;
|
|
423
|
+
if (rawEvidenceIds.includes('all'))
|
|
424
|
+
continue;
|
|
425
|
+
if (rawEvidenceIds.some((id) => !validEventIds.has(id)))
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
if (bucket === 'conflictCandidates') {
|
|
429
|
+
if (!hasPairedConflictClaims(record))
|
|
430
|
+
continue;
|
|
431
|
+
const distinctEvidenceIds = new Set(rawEvidenceIds);
|
|
432
|
+
if (rawEvidenceIds.includes('all')
|
|
433
|
+
|| distinctEvidenceIds.size < 2
|
|
434
|
+
|| rawEvidenceIds.some((id) => !validEventIds.has(id))) {
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
const evidence = this.providerEvidenceFor(record, events);
|
|
439
|
+
if (evidence.length === 0)
|
|
440
|
+
continue;
|
|
441
|
+
if (isUserOwnedDurableProviderBucket(bucket) && !evidence.some((item) => item.role === 'user')) {
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
candidates.push({
|
|
445
|
+
candidateType,
|
|
446
|
+
status,
|
|
447
|
+
confidence: clampConfidence(record.confidence, 0.68),
|
|
448
|
+
content: {
|
|
449
|
+
...record,
|
|
450
|
+
source: 'llm_dream_curator_candidate',
|
|
451
|
+
governance: 'candidate_only_cpu_governance_required',
|
|
452
|
+
projectId: authoritativeProjectId || events[0]?.projectId,
|
|
453
|
+
...(typeof record.projectId === 'string' && record.projectId !== (authoritativeProjectId || events[0]?.projectId)
|
|
454
|
+
? { providerProjectIdWarning: record.projectId }
|
|
455
|
+
: {}),
|
|
456
|
+
candidateBucket: bucket,
|
|
457
|
+
},
|
|
458
|
+
evidence,
|
|
459
|
+
promotionTargetType,
|
|
460
|
+
createdAt: now,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return candidates;
|
|
465
|
+
}
|
|
466
|
+
buildSemanticOrganizationCandidates(events, now, status, options) {
|
|
467
|
+
const candidates = [];
|
|
468
|
+
const readable = events.filter((event) => eventText(event).trim());
|
|
469
|
+
if (readable.length === 0)
|
|
470
|
+
return candidates;
|
|
471
|
+
const combined = readable.map(eventText).join('\n');
|
|
472
|
+
const topics = extractTopics(combined);
|
|
473
|
+
const topicPath = inferTopicPath(combined, topics);
|
|
474
|
+
const semanticTags = inferSemanticTags(combined, topics);
|
|
475
|
+
if (semanticTags.length > 0) {
|
|
476
|
+
candidates.push({
|
|
477
|
+
candidateType: 'semantic_tags',
|
|
478
|
+
status,
|
|
479
|
+
confidence: 0.7,
|
|
480
|
+
content: {
|
|
481
|
+
projectId: readable[0]?.projectId,
|
|
482
|
+
topicPath,
|
|
483
|
+
tags: semanticTags,
|
|
484
|
+
topics,
|
|
485
|
+
source: 'deterministic_dream_curator_semantic_tagging',
|
|
486
|
+
governance: 'candidate_only_cpu_governance_required',
|
|
487
|
+
purpose: 'help future recall route by stable semantic cues instead of full-sentence matching',
|
|
488
|
+
},
|
|
489
|
+
evidence: readable.slice(0, 8).map((event) => this.toEvidence(event)),
|
|
490
|
+
promotionTargetType: 'semantic_tags',
|
|
491
|
+
createdAt: now,
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
for (const event of readable) {
|
|
495
|
+
const text = eventText(event);
|
|
496
|
+
const eventTopics = extractTopics(text);
|
|
497
|
+
const importance = memoryIndexImportance(text, event);
|
|
498
|
+
candidates.push({
|
|
499
|
+
candidateType: 'indexing_decision',
|
|
500
|
+
status,
|
|
501
|
+
confidence: importance.shouldEmbed ? 0.72 : 0.62,
|
|
502
|
+
content: {
|
|
503
|
+
projectId: event.projectId,
|
|
504
|
+
sourceEventId: event.eventId,
|
|
505
|
+
shouldEmbed: importance.shouldEmbed,
|
|
506
|
+
storeAs: importance.storeAs,
|
|
507
|
+
topicPath: inferTopicPath(text, eventTopics),
|
|
508
|
+
tags: inferSemanticTags(text, eventTopics),
|
|
509
|
+
reason: importance.reason,
|
|
510
|
+
rawPreservation: 'raw_ledger_must_remain',
|
|
511
|
+
source: 'deterministic_dream_curator_indexing_decision',
|
|
512
|
+
governance: 'candidate_only_cpu_governance_required',
|
|
513
|
+
},
|
|
514
|
+
evidence: [this.toEvidence(event)],
|
|
515
|
+
promotionTargetType: 'indexing_decision',
|
|
516
|
+
createdAt: now,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
for (let index = 0; index < readable.length - 1; index += 1) {
|
|
520
|
+
const current = readable[index];
|
|
521
|
+
const next = readable[index + 1];
|
|
522
|
+
if (!current.sessionId || !next.sessionId || current.sessionId !== next.sessionId)
|
|
523
|
+
continue;
|
|
524
|
+
if (current.threadId && next.threadId && current.threadId !== next.threadId)
|
|
525
|
+
continue;
|
|
526
|
+
if (current.orderingConfidence === 'low' || next.orderingConfidence === 'low')
|
|
527
|
+
continue;
|
|
528
|
+
const nextRelation = options.episodeRelations?.find((item) => item.eventId === next.eventId)?.relation;
|
|
529
|
+
if (nextRelation && ['hard_topic_switch', 'ambiguous_shift', 'starts_new_topic', 'switches_topic'].includes(nextRelation))
|
|
530
|
+
continue;
|
|
531
|
+
const relation = current.role === 'user' && next.role === 'assistant'
|
|
532
|
+
? 'answered_by'
|
|
533
|
+
: next.parentEventId === current.eventId
|
|
534
|
+
? next.causalityType || 'caused'
|
|
535
|
+
: 'chronologically_followed_by';
|
|
536
|
+
const relationSummary = [
|
|
537
|
+
`${current.role || current.rawEventType || 'event'}: ${truncate(eventText(current), 140)}`,
|
|
538
|
+
`${next.role || next.rawEventType || 'event'}: ${truncate(eventText(next), 140)}`,
|
|
539
|
+
].join('\n');
|
|
540
|
+
candidates.push({
|
|
541
|
+
candidateType: 'semantic_relation',
|
|
542
|
+
status,
|
|
543
|
+
confidence: relation === 'answered_by' ? 0.74 : 0.62,
|
|
544
|
+
content: {
|
|
545
|
+
projectId: current.projectId || next.projectId,
|
|
546
|
+
relation,
|
|
547
|
+
summary: relationSummary,
|
|
548
|
+
sourceEventId: current.eventId,
|
|
549
|
+
targetEventId: next.eventId,
|
|
550
|
+
topicPath: inferTopicPath(`${eventText(current)}\n${eventText(next)}`, extractTopics(`${eventText(current)}\n${eventText(next)}`)),
|
|
551
|
+
source: 'deterministic_dream_curator_event_relation',
|
|
552
|
+
governance: 'candidate_only_cpu_governance_required',
|
|
553
|
+
},
|
|
554
|
+
evidence: [this.toEvidence(current), this.toEvidence(next)],
|
|
555
|
+
promotionTargetType: 'semantic_relation',
|
|
556
|
+
createdAt: now,
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
if (readable.length >= 2 && semanticTags.length > 0) {
|
|
560
|
+
candidates.push({
|
|
561
|
+
candidateType: 'edge_adjustment',
|
|
562
|
+
status,
|
|
563
|
+
confidence: 0.64,
|
|
564
|
+
content: {
|
|
565
|
+
projectId: readable[0]?.projectId,
|
|
566
|
+
topicPath,
|
|
567
|
+
strengthenWhenTagsOverlap: semanticTags,
|
|
568
|
+
weakenReasons: ['operational_noise', 'imported_summary_without_raw_transcript', 'superseded_or_conflicted_fact'],
|
|
569
|
+
evidenceEventIds: readable.slice(0, 8).map((event) => event.eventId),
|
|
570
|
+
source: 'deterministic_dream_curator_edge_adjustment',
|
|
571
|
+
governance: 'candidate_only_cpu_governance_required',
|
|
572
|
+
},
|
|
573
|
+
evidence: readable.slice(0, 8).map((event) => this.toEvidence(event)),
|
|
574
|
+
promotionTargetType: 'edge_adjustment',
|
|
575
|
+
createdAt: now,
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
return candidates;
|
|
579
|
+
}
|
|
580
|
+
providerEvidenceFor(record, events) {
|
|
581
|
+
const rawIds = Array.isArray(record.evidenceEventIds) ? record.evidenceEventIds : [];
|
|
582
|
+
const ids = rawIds.map((id) => String(id)).filter(Boolean);
|
|
583
|
+
const selected = ids.includes('all')
|
|
584
|
+
? events
|
|
585
|
+
: events.filter((event) => ids.includes(event.eventId));
|
|
586
|
+
return selected.map((event) => this.toEvidence(event));
|
|
587
|
+
}
|
|
588
|
+
providerDiagnosticCandidate(events, now, projectId, reason, detail) {
|
|
589
|
+
const detailText = truncate(detail instanceof Error ? detail.message : String(detail || ''), 500);
|
|
590
|
+
this.deps.pipelineMetrics?.recordNonFatal(reason, {
|
|
591
|
+
projectId,
|
|
592
|
+
message: detailText,
|
|
593
|
+
details: { component: 'dream_curator', disposition: 'rejected_diagnostic' },
|
|
594
|
+
occurredAt: now,
|
|
595
|
+
});
|
|
596
|
+
const existing = this.deps.candidateStore.listCandidates({
|
|
597
|
+
projectId,
|
|
598
|
+
statuses: ['needs_confirmation', 'rejected'],
|
|
599
|
+
candidateTypes: ['diagnostic_conclusion'],
|
|
600
|
+
limit: 500,
|
|
601
|
+
}).some((candidate) => {
|
|
602
|
+
const content = candidate.content && typeof candidate.content === 'object'
|
|
603
|
+
? candidate.content
|
|
604
|
+
: {};
|
|
605
|
+
return content.source === 'dream_curator_provider_warning'
|
|
606
|
+
&& content.reason === reason
|
|
607
|
+
&& content.detail === detailText;
|
|
608
|
+
});
|
|
609
|
+
if (existing)
|
|
610
|
+
return undefined;
|
|
611
|
+
return {
|
|
612
|
+
candidateType: 'diagnostic_conclusion',
|
|
613
|
+
status: 'rejected',
|
|
614
|
+
confidence: 0.4,
|
|
615
|
+
content: {
|
|
616
|
+
projectId,
|
|
617
|
+
source: 'dream_curator_provider_warning',
|
|
618
|
+
reason,
|
|
619
|
+
detail: detailText,
|
|
620
|
+
governance: 'candidate_only_cpu_governance_required',
|
|
621
|
+
recommendation: 'Check [memory_model] provider configuration and rerun cogmem dream retry followed by cogmem dream tick.',
|
|
622
|
+
evidenceAuthority: 'system_diagnostic_only',
|
|
623
|
+
},
|
|
624
|
+
evidence: [{
|
|
625
|
+
eventId: `system-diagnostic:${hash(`${projectId || 'global'}:${reason}:${detailText}`)}`,
|
|
626
|
+
role: 'system',
|
|
627
|
+
rawEventType: 'system_diagnostic',
|
|
628
|
+
projectId,
|
|
629
|
+
occurredAt: now,
|
|
630
|
+
textExcerpt: detailText,
|
|
631
|
+
sourceAnchor: {
|
|
632
|
+
eventId: `system-diagnostic:${hash(`${projectId || 'global'}:${reason}:${detailText}`)}`,
|
|
633
|
+
role: 'system',
|
|
634
|
+
orderingConfidence: 'high',
|
|
635
|
+
},
|
|
636
|
+
}],
|
|
637
|
+
promotionTargetType: 'diagnostic_conclusion',
|
|
638
|
+
createdAt: now,
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
supersedeProviderWarnings(projectId) {
|
|
642
|
+
const warnings = this.deps.candidateStore.listCandidates({
|
|
643
|
+
projectId,
|
|
644
|
+
statuses: ['needs_confirmation', 'rejected'],
|
|
645
|
+
candidateTypes: ['diagnostic_conclusion'],
|
|
646
|
+
limit: 500,
|
|
647
|
+
});
|
|
648
|
+
for (const candidate of warnings) {
|
|
649
|
+
const content = candidate.content && typeof candidate.content === 'object'
|
|
650
|
+
? candidate.content
|
|
651
|
+
: {};
|
|
652
|
+
if (content.source !== 'dream_curator_provider_warning')
|
|
653
|
+
continue;
|
|
654
|
+
this.deps.candidateStore.updateCandidateStatus(candidate.candidateId, 'superseded', {
|
|
655
|
+
type: 'diagnostic_conclusion',
|
|
656
|
+
id: candidate.candidateId,
|
|
657
|
+
reason: 'provider_recovered',
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
resolveGenerateText(options) {
|
|
662
|
+
if (options.generateText)
|
|
663
|
+
return options.generateText;
|
|
664
|
+
if (!this.deps.modelRegistry || this.deps.modelRegistry.isRuleOnly('memory'))
|
|
665
|
+
return undefined;
|
|
666
|
+
return this.deps.modelRegistry.getTextGenerator('memory');
|
|
667
|
+
}
|
|
668
|
+
resolveProviderConfig(options) {
|
|
669
|
+
if (options.generateText)
|
|
670
|
+
return { provider: 'explicit_generateText', modelName: 'custom' };
|
|
671
|
+
if (!this.deps.modelRegistry)
|
|
672
|
+
return { provider: 'rule_only' };
|
|
673
|
+
const role = this.deps.modelRegistry.getRoleConfig('memory');
|
|
674
|
+
return { provider: role.provider, modelName: role.modelName };
|
|
675
|
+
}
|
|
676
|
+
isDreamableEvent(event) {
|
|
677
|
+
const text = eventText(event);
|
|
678
|
+
if (!text.trim())
|
|
679
|
+
return false;
|
|
680
|
+
if (isOperationalNoiseText(text))
|
|
681
|
+
return false;
|
|
682
|
+
const metadata = event.payload && typeof event.payload === 'object'
|
|
683
|
+
? event.payload.metadata
|
|
684
|
+
: undefined;
|
|
685
|
+
if (metadata && Object.values(metadata).some((value) => isOperationalNoiseText(String(value || '')))) {
|
|
686
|
+
return false;
|
|
687
|
+
}
|
|
688
|
+
return true;
|
|
689
|
+
}
|
|
690
|
+
toEvidence(event) {
|
|
691
|
+
return {
|
|
692
|
+
eventId: event.eventId,
|
|
693
|
+
role: event.role,
|
|
694
|
+
rawEventType: event.rawEventType,
|
|
695
|
+
threadId: event.threadId,
|
|
696
|
+
sessionId: event.sessionId,
|
|
697
|
+
projectId: event.projectId,
|
|
698
|
+
globalSeq: event.globalSeq,
|
|
699
|
+
occurredAt: event.occurredAt,
|
|
700
|
+
textExcerpt: truncate(eventText(event), 280),
|
|
701
|
+
sourceAnchor: {
|
|
702
|
+
eventId: event.eventId,
|
|
703
|
+
threadId: event.threadId,
|
|
704
|
+
sessionId: event.sessionId,
|
|
705
|
+
turnId: event.turnId,
|
|
706
|
+
role: event.role,
|
|
707
|
+
threadSeq: event.threadSeq,
|
|
708
|
+
turnSeq: event.turnSeq,
|
|
709
|
+
eventOrdinal: event.eventOrdinal,
|
|
710
|
+
parentEventId: event.parentEventId,
|
|
711
|
+
prevEventId: event.prevEventId,
|
|
712
|
+
nextEventId: event.nextEventId,
|
|
713
|
+
causalityType: event.causalityType,
|
|
714
|
+
orderingConfidence: event.orderingConfidence,
|
|
715
|
+
},
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
singleSessionId(events) {
|
|
719
|
+
const sessionIds = new Set(events.map((event) => event.sessionId).filter((id) => Boolean(id)));
|
|
720
|
+
return sessionIds.size === 1 ? [...sessionIds][0] : undefined;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
function hasPairedConflictClaims(record) {
|
|
724
|
+
const incoming = String(record.newStatement || record.claim || '').trim();
|
|
725
|
+
const prior = String(record.possiblySupersededStatement || record.priorStatement || '').trim();
|
|
726
|
+
return incoming.length > 0 && prior.length > 0 && incoming !== prior;
|
|
727
|
+
}
|
|
728
|
+
function isExplicitCorrectionCandidate(text) {
|
|
729
|
+
if (!CORRECTION_PATTERN.test(text))
|
|
730
|
+
return false;
|
|
731
|
+
if (LEADING_CORRECTION_PATTERN.test(text))
|
|
732
|
+
return true;
|
|
733
|
+
return !/[??]\s*$/u.test(text);
|
|
734
|
+
}
|
|
735
|
+
function eventText(event) {
|
|
736
|
+
return eventTextForMemory(event);
|
|
737
|
+
}
|
|
738
|
+
function summarizeEvents(events) {
|
|
739
|
+
return events
|
|
740
|
+
.slice(0, 12)
|
|
741
|
+
.map((event) => `${event.role || event.rawEventType || 'event'}: ${truncate(eventText(event), 180)}`)
|
|
742
|
+
.join('\n');
|
|
743
|
+
}
|
|
744
|
+
function preferencePredicate(text) {
|
|
745
|
+
if (/不要|别|never|do not|don't|边界|boundary/iu.test(text))
|
|
746
|
+
return 'constraint';
|
|
747
|
+
if (/长期目标|目标是|goal/iu.test(text))
|
|
748
|
+
return 'goal';
|
|
749
|
+
if (/必须|一定要|本地优先|must|local-first/iu.test(text))
|
|
750
|
+
return 'operating_constraint';
|
|
751
|
+
return 'preference';
|
|
752
|
+
}
|
|
753
|
+
function preferenceCategory(text) {
|
|
754
|
+
if (/不要|别|never|do not|don't|边界|boundary/iu.test(text))
|
|
755
|
+
return 'project_constraint';
|
|
756
|
+
if (/长期目标|目标是|goal/iu.test(text))
|
|
757
|
+
return 'long_term_goal';
|
|
758
|
+
if (/必须|一定要|本地优先|must|local-first/iu.test(text))
|
|
759
|
+
return 'operating_preference';
|
|
760
|
+
return 'user_preference';
|
|
761
|
+
}
|
|
762
|
+
function preferenceTags(text) {
|
|
763
|
+
const tags = ['source:explicit_user_statement'];
|
|
764
|
+
if (/记忆内核|CogMem|cogmem|OpenClaw|Hermes|Obsidian|wiki/iu.test(text))
|
|
765
|
+
tags.push('scope:project');
|
|
766
|
+
if (/本地优先|local-first/iu.test(text))
|
|
767
|
+
tags.push('policy:local_first');
|
|
768
|
+
if (/不要|别|never|do not|don't/iu.test(text))
|
|
769
|
+
tags.push('kind:negative_constraint');
|
|
770
|
+
if (/长期目标|目标是|goal/iu.test(text))
|
|
771
|
+
tags.push('kind:goal');
|
|
772
|
+
return tags;
|
|
773
|
+
}
|
|
774
|
+
function extractTopics(text) {
|
|
775
|
+
const topics = [];
|
|
776
|
+
for (const topic of ['CogMem', 'cogmem', 'OpenClaw', 'Hermes', 'Obsidian', 'wiki', '记忆内核', '记忆黑盒', '上下文噪声', 'source locator', 'raw ledger', 'local-first']) {
|
|
777
|
+
if (text.toLowerCase().includes(topic.toLowerCase()))
|
|
778
|
+
topics.push(topic);
|
|
779
|
+
}
|
|
780
|
+
return [...new Set(topics)];
|
|
781
|
+
}
|
|
782
|
+
function inferTopicPath(text, topics) {
|
|
783
|
+
if (/记忆黑盒|黑盒|上下文噪声|source locator|raw ledger|原话|sourceContext/iu.test(text)) {
|
|
784
|
+
return 'memory/auditability';
|
|
785
|
+
}
|
|
786
|
+
if (/OpenClaw|插件|plugin|hook|before_prompt_build|agent_end/iu.test(text)) {
|
|
787
|
+
return 'integration/openclaw';
|
|
788
|
+
}
|
|
789
|
+
if (/Dream|Curator|整理|策展|候选|治理/iu.test(text)) {
|
|
790
|
+
return 'memory/curation';
|
|
791
|
+
}
|
|
792
|
+
if (/Obsidian|wiki|知识库/iu.test(text)) {
|
|
793
|
+
return 'architecture/boundary';
|
|
794
|
+
}
|
|
795
|
+
if (topics.includes('CogMem') || topics.includes('记忆内核'))
|
|
796
|
+
return 'memory/kernel';
|
|
797
|
+
return 'memory/session';
|
|
798
|
+
}
|
|
799
|
+
function inferSemanticTags(text, topics) {
|
|
800
|
+
const tags = new Set();
|
|
801
|
+
for (const topic of topics)
|
|
802
|
+
tags.add(`topic:${topic}`);
|
|
803
|
+
if (/记忆黑盒|黑盒/iu.test(text))
|
|
804
|
+
tags.add('concept:memory_black_box');
|
|
805
|
+
if (/上下文噪声|噪声/iu.test(text))
|
|
806
|
+
tags.add('concept:context_noise');
|
|
807
|
+
if (/原话|怎么说|exact quote|verbatim/iu.test(text))
|
|
808
|
+
tags.add('need:exact_quote');
|
|
809
|
+
if (/sourceContext|source locator|sourceLocator|raw ledger|下钻/iu.test(text))
|
|
810
|
+
tags.add('need:source_drilldown');
|
|
811
|
+
if (/上一个会话|上个会话|previous session|last session/iu.test(text))
|
|
812
|
+
tags.add('need:previous_session');
|
|
813
|
+
if (/不要|禁止|边界|不能|do not|never|must not/iu.test(text))
|
|
814
|
+
tags.add('kind:boundary');
|
|
815
|
+
if (/失败|问题|原因|root cause|diagnostic|诊断/iu.test(text))
|
|
816
|
+
tags.add('kind:diagnostic');
|
|
817
|
+
return [...tags];
|
|
818
|
+
}
|
|
819
|
+
function memoryIndexImportance(text, event) {
|
|
820
|
+
if (/请以后|长期目标|必须|不要|禁止|边界|偏好|重要|always|never|must|preference|goal/iu.test(text)) {
|
|
821
|
+
return {
|
|
822
|
+
shouldEmbed: true,
|
|
823
|
+
storeAs: 'compiled_memory_candidate',
|
|
824
|
+
reason: 'durable_user_preference_goal_or_boundary',
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
if (/记忆黑盒|上下文噪声|source locator|raw ledger|原话|诊断|root cause|失败教训/iu.test(text)) {
|
|
828
|
+
return {
|
|
829
|
+
shouldEmbed: true,
|
|
830
|
+
storeAs: 'topic_summary_or_diagnostic_candidate',
|
|
831
|
+
reason: 'reusable_project_memory_or_diagnostic_context',
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
if (event.rawEventType === 'tool_result' || event.rawEventType === 'task_event') {
|
|
835
|
+
return {
|
|
836
|
+
shouldEmbed: false,
|
|
837
|
+
storeAs: 'raw_ledger_only_until_governed',
|
|
838
|
+
reason: 'tool_or_task_observation_requires_governance_before_embedding',
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
return {
|
|
842
|
+
shouldEmbed: false,
|
|
843
|
+
storeAs: 'raw_ledger_only',
|
|
844
|
+
reason: 'low_signal_event_preserve_raw_without_hot_vector',
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
function isUserOwnedDurableProviderBucket(bucket) {
|
|
848
|
+
return [
|
|
849
|
+
'userPreferenceCandidates',
|
|
850
|
+
'longTermGoalCandidates',
|
|
851
|
+
'boundaryCandidates',
|
|
852
|
+
'failureLessonCandidates',
|
|
853
|
+
].includes(bucket);
|
|
854
|
+
}
|
|
855
|
+
function minDefined(values) {
|
|
856
|
+
const defined = values.filter((value) => Number.isFinite(value));
|
|
857
|
+
return defined.length ? Math.min(...defined) : undefined;
|
|
858
|
+
}
|
|
859
|
+
function maxDefined(values) {
|
|
860
|
+
const defined = values.filter((value) => Number.isFinite(value));
|
|
861
|
+
return defined.length ? Math.max(...defined) : undefined;
|
|
862
|
+
}
|
|
863
|
+
function truncate(value, maxLength) {
|
|
864
|
+
return value.length <= maxLength ? value : `${value.slice(0, maxLength)}...`;
|
|
865
|
+
}
|
|
866
|
+
function objectRecord(value) {
|
|
867
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
868
|
+
? value
|
|
869
|
+
: { value };
|
|
870
|
+
}
|
|
871
|
+
function hash(value) {
|
|
872
|
+
return createHash('sha256').update(value).digest('hex');
|
|
873
|
+
}
|
|
874
|
+
function parseJsonObjectFromModel(raw) {
|
|
875
|
+
const text = String(raw || '').trim();
|
|
876
|
+
if (!text)
|
|
877
|
+
return null;
|
|
878
|
+
const fenced = text.match(/```(?:json)?\s*([\s\S]*?)```/i)?.[1]?.trim();
|
|
879
|
+
const candidate = fenced || text;
|
|
880
|
+
try {
|
|
881
|
+
const parsed = JSON.parse(candidate);
|
|
882
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
883
|
+
? parsed
|
|
884
|
+
: null;
|
|
885
|
+
}
|
|
886
|
+
catch {
|
|
887
|
+
const start = candidate.indexOf('{');
|
|
888
|
+
const end = candidate.lastIndexOf('}');
|
|
889
|
+
if (start >= 0 && end > start) {
|
|
890
|
+
try {
|
|
891
|
+
const parsed = JSON.parse(candidate.slice(start, end + 1));
|
|
892
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
893
|
+
? parsed
|
|
894
|
+
: null;
|
|
895
|
+
}
|
|
896
|
+
catch {
|
|
897
|
+
return null;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
return null;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
function clampConfidence(value, fallback) {
|
|
904
|
+
const numeric = Number(value);
|
|
905
|
+
if (!Number.isFinite(numeric))
|
|
906
|
+
return fallback;
|
|
907
|
+
return Math.max(0.05, Math.min(0.99, numeric));
|
|
908
|
+
}
|