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,20 @@
|
|
|
1
|
+
export type AgentRecallIntent = 'memory_recall' | 'previous_session_summary' | 'forensic_quote';
|
|
2
|
+
export interface AgentRecallQueryCompileInput {
|
|
3
|
+
query: string;
|
|
4
|
+
intent?: AgentRecallIntent;
|
|
5
|
+
anchorText?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AgentRecallQueryPlan {
|
|
8
|
+
originalQuery: string;
|
|
9
|
+
intent: AgentRecallIntent;
|
|
10
|
+
primarySearchText: string;
|
|
11
|
+
searchTexts: string[];
|
|
12
|
+
keywords: string[];
|
|
13
|
+
semanticCuePhrases: string[];
|
|
14
|
+
temporalHints: string[];
|
|
15
|
+
anchorUsed: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function compileAgentRecallQuery(input: AgentRecallQueryCompileInput): AgentRecallQueryPlan;
|
|
18
|
+
export declare function inferAgentRecallIntent(query: string): AgentRecallIntent;
|
|
19
|
+
export declare function extractRecallKeywords(text: string): string[];
|
|
20
|
+
//# sourceMappingURL=AgentRecallQueryCompiler.d.ts.map
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
const PROTECTED_PHRASES = [
|
|
2
|
+
'CogMem Memory Context',
|
|
3
|
+
'Memory Context',
|
|
4
|
+
'OpenClaw',
|
|
5
|
+
'Hermes',
|
|
6
|
+
'cogmem',
|
|
7
|
+
'Obsidian',
|
|
8
|
+
'记忆内核',
|
|
9
|
+
'记忆黑盒',
|
|
10
|
+
'黑盒',
|
|
11
|
+
'记忆',
|
|
12
|
+
'因果链',
|
|
13
|
+
'原话',
|
|
14
|
+
'上下文',
|
|
15
|
+
'上下文噪声',
|
|
16
|
+
'偏好',
|
|
17
|
+
'项目',
|
|
18
|
+
'约束',
|
|
19
|
+
'边界',
|
|
20
|
+
'库存',
|
|
21
|
+
'配置',
|
|
22
|
+
'安装',
|
|
23
|
+
'更新',
|
|
24
|
+
'重启',
|
|
25
|
+
'报错',
|
|
26
|
+
'错误',
|
|
27
|
+
'工具',
|
|
28
|
+
];
|
|
29
|
+
const QUERY_FILLERS = [
|
|
30
|
+
'我现在不是问你泛泛解释',
|
|
31
|
+
'不是问你泛泛解释',
|
|
32
|
+
'泛泛解释',
|
|
33
|
+
'我不是要你',
|
|
34
|
+
'我是问',
|
|
35
|
+
'我想知道',
|
|
36
|
+
'你还记不记得',
|
|
37
|
+
'还记不记得',
|
|
38
|
+
'你还记得',
|
|
39
|
+
'还记得',
|
|
40
|
+
'你记得吗',
|
|
41
|
+
'记得吗',
|
|
42
|
+
'我们之前讨论过关于',
|
|
43
|
+
'我们之前讨论过',
|
|
44
|
+
'之前讨论过',
|
|
45
|
+
'当时我问你的',
|
|
46
|
+
'当时的',
|
|
47
|
+
'这个问题时',
|
|
48
|
+
'这个问题',
|
|
49
|
+
'的问题',
|
|
50
|
+
'问题',
|
|
51
|
+
'是什么',
|
|
52
|
+
'什么',
|
|
53
|
+
'the',
|
|
54
|
+
'a',
|
|
55
|
+
'an',
|
|
56
|
+
'please',
|
|
57
|
+
];
|
|
58
|
+
const QUOTE_TERMS = new Set(['原话', 'exact', 'quote', 'verbatim']);
|
|
59
|
+
export function compileAgentRecallQuery(input) {
|
|
60
|
+
const originalQuery = normalizeWhitespace(input.query);
|
|
61
|
+
const intent = input.intent ?? inferAgentRecallIntent(originalQuery);
|
|
62
|
+
const anchorText = normalizeWhitespace(input.anchorText || '');
|
|
63
|
+
const queryKeywords = extractRecallKeywords(originalQuery);
|
|
64
|
+
const anchorKeywords = extractRecallKeywords(anchorText);
|
|
65
|
+
const keywordSource = anchorKeywords.length > 0 && isVagueForensicFollowup(originalQuery)
|
|
66
|
+
? anchorKeywords
|
|
67
|
+
: mergeKeywords(queryKeywords, anchorKeywords);
|
|
68
|
+
const keywords = intent === 'forensic_quote'
|
|
69
|
+
? keywordSource.filter((keyword) => !QUOTE_TERMS.has(keyword.toLowerCase()))
|
|
70
|
+
: keywordSource;
|
|
71
|
+
const residual = stripFillers(originalQuery);
|
|
72
|
+
const anchorResidual = stripFillers(anchorText);
|
|
73
|
+
const semanticCuePhrases = buildSemanticCuePhrases(keywords, originalQuery, anchorText);
|
|
74
|
+
const temporalHints = extractTemporalHints(originalQuery);
|
|
75
|
+
const searchTexts = uniqueNonEmpty([
|
|
76
|
+
joinKeywords(keywords),
|
|
77
|
+
joinKeywords(queryKeywords.filter((keyword) => !QUOTE_TERMS.has(keyword.toLowerCase()))),
|
|
78
|
+
joinKeywords(anchorKeywords.filter((keyword) => !QUOTE_TERMS.has(keyword.toLowerCase()))),
|
|
79
|
+
...semanticCuePhrases,
|
|
80
|
+
residual && keywords.length === 0 ? residual : '',
|
|
81
|
+
anchorResidual && keywords.length === 0 ? anchorResidual : '',
|
|
82
|
+
]).filter((candidate) => !containsFiller(candidate));
|
|
83
|
+
return {
|
|
84
|
+
originalQuery,
|
|
85
|
+
intent,
|
|
86
|
+
primarySearchText: searchTexts[0] || residual || originalQuery,
|
|
87
|
+
searchTexts: searchTexts.length > 0 ? searchTexts : [originalQuery],
|
|
88
|
+
keywords,
|
|
89
|
+
semanticCuePhrases,
|
|
90
|
+
temporalHints,
|
|
91
|
+
anchorUsed: anchorKeywords.length > 0,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function inferAgentRecallIntent(query) {
|
|
95
|
+
const text = query.toLowerCase();
|
|
96
|
+
if (/(上一个|上个|上一|上次).{0,12}(会话|session)|previous session|last session/.test(text)) {
|
|
97
|
+
return 'previous_session_summary';
|
|
98
|
+
}
|
|
99
|
+
if (/原话|怎么说的|完整对话|上一句|下一句|exact quote|verbatim/.test(text)) {
|
|
100
|
+
return 'forensic_quote';
|
|
101
|
+
}
|
|
102
|
+
return 'memory_recall';
|
|
103
|
+
}
|
|
104
|
+
export function extractRecallKeywords(text) {
|
|
105
|
+
const normalized = normalizeWhitespace(text);
|
|
106
|
+
if (!normalized)
|
|
107
|
+
return [];
|
|
108
|
+
const found = [];
|
|
109
|
+
const lower = normalized.toLowerCase();
|
|
110
|
+
for (const phrase of PROTECTED_PHRASES) {
|
|
111
|
+
if (lower.includes(phrase.toLowerCase())) {
|
|
112
|
+
if (phrase === '记忆黑盒') {
|
|
113
|
+
found.push('记忆', '黑盒');
|
|
114
|
+
}
|
|
115
|
+
else if (phrase === '记忆内核') {
|
|
116
|
+
found.push('记忆');
|
|
117
|
+
}
|
|
118
|
+
else if (phrase === 'cogmem' && lower.includes('cogmem memory context')) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
else if (phrase === 'Memory Context' && lower.includes('cogmem memory context')) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
else if (phrase !== '上下文' && phrase !== '问题') {
|
|
125
|
+
found.push(phrase);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
for (const token of normalized.split(/[^\p{L}\p{N}_-]+/u)) {
|
|
130
|
+
const cleaned = token.trim();
|
|
131
|
+
if (!cleaned || cleaned.length < 3)
|
|
132
|
+
continue;
|
|
133
|
+
if (/^[\u4e00-\u9fff]+$/u.test(cleaned))
|
|
134
|
+
continue;
|
|
135
|
+
if (lower.includes('cogmem memory context') && /^(cogmem|memory|context)$/i.test(cleaned))
|
|
136
|
+
continue;
|
|
137
|
+
if (QUERY_FILLERS.some((filler) => filler.toLowerCase() === cleaned.toLowerCase()))
|
|
138
|
+
continue;
|
|
139
|
+
found.push(cleaned);
|
|
140
|
+
}
|
|
141
|
+
const existingKeywords = mergeKeywords(found);
|
|
142
|
+
found.push(...extractCjkCueTerms(normalized).filter((term) => !existingKeywords.some((keyword) => (term.includes(keyword) || keyword.includes(term)))));
|
|
143
|
+
return mergeKeywords(found);
|
|
144
|
+
}
|
|
145
|
+
function isVagueForensicFollowup(query) {
|
|
146
|
+
const withoutFillers = stripFillers(query);
|
|
147
|
+
const keywords = extractRecallKeywords(withoutFillers).filter((keyword) => !QUOTE_TERMS.has(keyword.toLowerCase()));
|
|
148
|
+
return /原话|exact quote|verbatim/.test(query.toLowerCase()) && keywords.length === 0;
|
|
149
|
+
}
|
|
150
|
+
function stripFillers(value) {
|
|
151
|
+
let output = normalizeWhitespace(value);
|
|
152
|
+
for (const filler of QUERY_FILLERS) {
|
|
153
|
+
output = output.replace(new RegExp(escapeRegExp(filler), 'giu'), ' ');
|
|
154
|
+
}
|
|
155
|
+
return normalizeWhitespace(output.replace(/[,。?!、;:,.?!;:]/g, ' '));
|
|
156
|
+
}
|
|
157
|
+
function containsFiller(value) {
|
|
158
|
+
return QUERY_FILLERS.some((filler) => value.toLowerCase().includes(filler.toLowerCase()));
|
|
159
|
+
}
|
|
160
|
+
function joinKeywords(keywords) {
|
|
161
|
+
return mergeKeywords(keywords).join(' ');
|
|
162
|
+
}
|
|
163
|
+
function buildSemanticCuePhrases(keywords, query, anchorText) {
|
|
164
|
+
const merged = mergeKeywords(keywords);
|
|
165
|
+
const text = `${query}\n${anchorText}`;
|
|
166
|
+
const out = [];
|
|
167
|
+
const hasMemory = merged.includes('记忆') || /memory|CogMem|记忆/u.test(text);
|
|
168
|
+
const hasBlackBox = merged.includes('黑盒') || /黑盒|black\s*box/iu.test(text);
|
|
169
|
+
if (hasMemory && hasBlackBox) {
|
|
170
|
+
out.push('记忆 黑盒');
|
|
171
|
+
out.push('存档 黑盒');
|
|
172
|
+
out.push('对话 存档 黑盒');
|
|
173
|
+
out.push('上下文 黑盒');
|
|
174
|
+
out.push('黑盒');
|
|
175
|
+
}
|
|
176
|
+
else if (hasBlackBox) {
|
|
177
|
+
out.push('黑盒');
|
|
178
|
+
out.push('存档 黑盒');
|
|
179
|
+
}
|
|
180
|
+
if (/原话|exact quote|verbatim/iu.test(text) && hasBlackBox) {
|
|
181
|
+
out.push('黑盒 原话');
|
|
182
|
+
}
|
|
183
|
+
if (/CogMem Memory Context/iu.test(text)) {
|
|
184
|
+
out.push('CogMem Memory Context');
|
|
185
|
+
out.push('Memory Context');
|
|
186
|
+
}
|
|
187
|
+
if (merged.includes('库存') || /库存|inventory|stock/iu.test(text)) {
|
|
188
|
+
out.push('库存管理');
|
|
189
|
+
out.push('在库');
|
|
190
|
+
out.push('产品コード');
|
|
191
|
+
out.push('数量');
|
|
192
|
+
}
|
|
193
|
+
return uniqueNonEmpty(out);
|
|
194
|
+
}
|
|
195
|
+
function extractTemporalHints(query) {
|
|
196
|
+
const hints = [];
|
|
197
|
+
if (/之前|以前|过去|几个月前|半年前|上个月|前几天|昨天|上次|上个|还记得|previous|before|last/i.test(query)) {
|
|
198
|
+
hints.push('past');
|
|
199
|
+
}
|
|
200
|
+
if (/昨天|yesterday/i.test(query))
|
|
201
|
+
hints.push('yesterday');
|
|
202
|
+
if (/上一个|上个|上次|previous|last/i.test(query))
|
|
203
|
+
hints.push('previous');
|
|
204
|
+
return uniqueNonEmpty(hints);
|
|
205
|
+
}
|
|
206
|
+
function mergeKeywords(...groups) {
|
|
207
|
+
const out = [];
|
|
208
|
+
const seen = new Set();
|
|
209
|
+
for (const keyword of groups.flat()) {
|
|
210
|
+
const normalized = normalizeWhitespace(keyword);
|
|
211
|
+
if (!normalized)
|
|
212
|
+
continue;
|
|
213
|
+
const key = normalized.toLowerCase();
|
|
214
|
+
if (seen.has(key))
|
|
215
|
+
continue;
|
|
216
|
+
if (normalized === '记忆内核' && seen.has('记忆'))
|
|
217
|
+
continue;
|
|
218
|
+
seen.add(key);
|
|
219
|
+
out.push(normalized);
|
|
220
|
+
}
|
|
221
|
+
return out;
|
|
222
|
+
}
|
|
223
|
+
const CJK_QUERY_STOP_PHRASES = [
|
|
224
|
+
...QUERY_FILLERS,
|
|
225
|
+
'我们',
|
|
226
|
+
'你们',
|
|
227
|
+
'你',
|
|
228
|
+
'我',
|
|
229
|
+
'是否',
|
|
230
|
+
'是不是',
|
|
231
|
+
'有没有',
|
|
232
|
+
'哪些',
|
|
233
|
+
'哪个',
|
|
234
|
+
'什么',
|
|
235
|
+
'多少',
|
|
236
|
+
'记录过',
|
|
237
|
+
'聊过',
|
|
238
|
+
'讨论过',
|
|
239
|
+
'之前',
|
|
240
|
+
'以前',
|
|
241
|
+
'关于',
|
|
242
|
+
'和',
|
|
243
|
+
'这个',
|
|
244
|
+
'那个',
|
|
245
|
+
'问题',
|
|
246
|
+
'的吗',
|
|
247
|
+
'吗',
|
|
248
|
+
'呢',
|
|
249
|
+
'的',
|
|
250
|
+
'了',
|
|
251
|
+
'过',
|
|
252
|
+
];
|
|
253
|
+
function extractCjkCueTerms(text) {
|
|
254
|
+
const candidates = [];
|
|
255
|
+
for (const match of text.matchAll(/[\u3040-\u30ff\u3400-\u9fff]{2,}/gu)) {
|
|
256
|
+
let chunk = match[0];
|
|
257
|
+
for (const filler of CJK_QUERY_STOP_PHRASES) {
|
|
258
|
+
chunk = chunk.replace(new RegExp(escapeRegExp(filler), 'giu'), ' ');
|
|
259
|
+
}
|
|
260
|
+
for (const part of chunk.split(/\s+/)) {
|
|
261
|
+
const trimmed = part.trim();
|
|
262
|
+
if (trimmed.length >= 2 && trimmed.length <= 12)
|
|
263
|
+
candidates.push(trimmed);
|
|
264
|
+
if (trimmed.length > 12) {
|
|
265
|
+
for (let index = 0; index <= trimmed.length - 2 && candidates.length < 12; index += 2) {
|
|
266
|
+
candidates.push(trimmed.slice(index, Math.min(index + 4, trimmed.length)));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return candidates;
|
|
272
|
+
}
|
|
273
|
+
function uniqueNonEmpty(values) {
|
|
274
|
+
const out = [];
|
|
275
|
+
const seen = new Set();
|
|
276
|
+
for (const value of values.map(normalizeWhitespace)) {
|
|
277
|
+
if (!value || seen.has(value.toLowerCase()))
|
|
278
|
+
continue;
|
|
279
|
+
seen.add(value.toLowerCase());
|
|
280
|
+
out.push(value);
|
|
281
|
+
}
|
|
282
|
+
return out;
|
|
283
|
+
}
|
|
284
|
+
function normalizeWhitespace(value) {
|
|
285
|
+
return String(value || '').replace(/\s+/g, ' ').trim();
|
|
286
|
+
}
|
|
287
|
+
function escapeRegExp(value) {
|
|
288
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
289
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const COGMEM_RECALL_BLOCK_RE: RegExp;
|
|
2
|
+
export interface StripCogmemRecallBlocksResult {
|
|
3
|
+
text: string;
|
|
4
|
+
stripped: boolean;
|
|
5
|
+
strippedChars: number;
|
|
6
|
+
blockCount: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function stripCogmemRecallBlocks(text: string): StripCogmemRecallBlocksResult;
|
|
9
|
+
//# sourceMappingURL=ContextHygiene.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const COGMEM_RECALL_BLOCK_RE = /<(COGMEM_RECALL_CONTEXT|COGMEM_MEMORY_ATLAS|COGMEM_TURN_BRIDGE|COGMEM_SESSION_STATE|COGMEM_STRATEGY_CONTEXT)\b[\s\S]*?<\/\1>/g;
|
|
2
|
+
export function stripCogmemRecallBlocks(text) {
|
|
3
|
+
const input = String(text || '');
|
|
4
|
+
let strippedChars = 0;
|
|
5
|
+
let blockCount = 0;
|
|
6
|
+
const output = input
|
|
7
|
+
.replace(COGMEM_RECALL_BLOCK_RE, (match) => {
|
|
8
|
+
strippedChars += match.length;
|
|
9
|
+
blockCount += 1;
|
|
10
|
+
return '';
|
|
11
|
+
})
|
|
12
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
13
|
+
.trim();
|
|
14
|
+
return {
|
|
15
|
+
text: output,
|
|
16
|
+
stripped: blockCount > 0,
|
|
17
|
+
strippedChars,
|
|
18
|
+
blockCount,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AgentRecallItem, AgentRecallSourceAnchor } from './AgentMemoryBackend.js';
|
|
2
|
+
export interface MemoryUsageReceiptSourceAnchor {
|
|
3
|
+
memoryId?: string;
|
|
4
|
+
eventId?: string;
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
role?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface MemoryUsageReceipt {
|
|
9
|
+
sessionId: string;
|
|
10
|
+
turnId: string;
|
|
11
|
+
createdAt: number;
|
|
12
|
+
userQueryDigest: string;
|
|
13
|
+
assistantAnswerDigest: string;
|
|
14
|
+
usedMemoryIds: string[];
|
|
15
|
+
sourceAnchors: MemoryUsageReceiptSourceAnchor[];
|
|
16
|
+
usedThemes: string[];
|
|
17
|
+
workingConclusion?: string;
|
|
18
|
+
ttlTurns: number;
|
|
19
|
+
compileAllowed: false;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateMemoryUsageReceiptInput {
|
|
22
|
+
sessionId: string;
|
|
23
|
+
turnId?: string;
|
|
24
|
+
createdAt?: number;
|
|
25
|
+
userText: string;
|
|
26
|
+
assistantText: string;
|
|
27
|
+
recallItems?: Array<Pick<AgentRecallItem, 'id' | 'text' | 'tags'> & {
|
|
28
|
+
sourceAnchor?: AgentRecallSourceAnchor;
|
|
29
|
+
}>;
|
|
30
|
+
ttlTurns?: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function createMemoryUsageReceipt(input: CreateMemoryUsageReceiptInput): MemoryUsageReceipt;
|
|
33
|
+
export declare function formatMemoryUsageBridge(receipt: MemoryUsageReceipt, maxChars?: number): string;
|
|
34
|
+
export declare function shouldInjectMemoryUsageBridge(query: string, receipt: MemoryUsageReceipt): boolean;
|
|
35
|
+
//# sourceMappingURL=MemoryUsageReceipt.d.ts.map
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
export function createMemoryUsageReceipt(input) {
|
|
3
|
+
const createdAt = input.createdAt ?? Date.now();
|
|
4
|
+
const turnId = input.turnId || `${input.sessionId}:${createdAt}`;
|
|
5
|
+
const recallItems = Array.isArray(input.recallItems) ? input.recallItems : [];
|
|
6
|
+
const usedMemoryIds = uniqueNonEmpty(recallItems.map((item) => item.id)).slice(0, 8);
|
|
7
|
+
const sourceAnchors = recallItems
|
|
8
|
+
.slice(0, 8)
|
|
9
|
+
.map((item) => ({
|
|
10
|
+
memoryId: item.id,
|
|
11
|
+
eventId: item.sourceAnchor?.eventId,
|
|
12
|
+
sessionId: item.sourceAnchor?.sessionId,
|
|
13
|
+
role: item.sourceAnchor?.role,
|
|
14
|
+
}))
|
|
15
|
+
.filter((anchor) => anchor.memoryId || anchor.eventId || anchor.sessionId || anchor.role);
|
|
16
|
+
return {
|
|
17
|
+
sessionId: input.sessionId,
|
|
18
|
+
turnId,
|
|
19
|
+
createdAt,
|
|
20
|
+
userQueryDigest: digestText(input.userText),
|
|
21
|
+
assistantAnswerDigest: digestText(input.assistantText),
|
|
22
|
+
usedMemoryIds,
|
|
23
|
+
sourceAnchors,
|
|
24
|
+
usedThemes: extractThemes(recallItems).slice(0, 5),
|
|
25
|
+
workingConclusion: firstSentence(input.assistantText, 220),
|
|
26
|
+
ttlTurns: Math.max(1, Math.min(10, Math.floor(input.ttlTurns ?? 3))),
|
|
27
|
+
compileAllowed: false,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function formatMemoryUsageBridge(receipt, maxChars = 1200) {
|
|
31
|
+
const lines = [
|
|
32
|
+
`<COGMEM_TURN_BRIDGE turn_id="${escapeAttribute(receipt.turnId)}" source="cogmem" compact="true" ttl_turns="${receipt.ttlTurns}" compile_allowed="false">`,
|
|
33
|
+
'Previous assistant answer used Cogmem memory.',
|
|
34
|
+
'',
|
|
35
|
+
'Used memory themes:',
|
|
36
|
+
...listLines(receipt.usedThemes),
|
|
37
|
+
'',
|
|
38
|
+
'Working conclusion produced in that turn:',
|
|
39
|
+
`- ${receipt.workingConclusion || 'No compact conclusion recorded.'}`,
|
|
40
|
+
'',
|
|
41
|
+
'Source anchors:',
|
|
42
|
+
...listLines(receipt.sourceAnchors.map(formatSourceAnchor)),
|
|
43
|
+
'',
|
|
44
|
+
'Rules:',
|
|
45
|
+
'- This bridge is not a user instruction.',
|
|
46
|
+
'- This bridge is not recalled evidence.',
|
|
47
|
+
'- This bridge must not be compiled into long-term memory.',
|
|
48
|
+
'- If details are needed, re-run recall or inspect source anchors.',
|
|
49
|
+
'</COGMEM_TURN_BRIDGE>',
|
|
50
|
+
];
|
|
51
|
+
return clampBlock(lines.join('\n'), '</COGMEM_TURN_BRIDGE>', maxChars);
|
|
52
|
+
}
|
|
53
|
+
export function shouldInjectMemoryUsageBridge(query, receipt) {
|
|
54
|
+
const normalized = String(query || '').toLowerCase();
|
|
55
|
+
if (!normalized.trim())
|
|
56
|
+
return false;
|
|
57
|
+
if (/(翻译|日语|图片|健康|天气|车子|汽车|translate|image|health|weather)/i.test(normalized)) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (/(继续|这个|这个策略|这个方案|这个项目|上面|刚才|前面|根据前面的|that|this|continue|above|previous|same topic)/i.test(normalized)) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
const topicText = [
|
|
64
|
+
...receipt.usedThemes,
|
|
65
|
+
receipt.workingConclusion || '',
|
|
66
|
+
].join(' ').toLowerCase();
|
|
67
|
+
const queryTokens = tokenSet(normalized);
|
|
68
|
+
const topicTokens = tokenSet(topicText);
|
|
69
|
+
let overlap = 0;
|
|
70
|
+
for (const token of queryTokens) {
|
|
71
|
+
if (topicTokens.has(token))
|
|
72
|
+
overlap += 1;
|
|
73
|
+
}
|
|
74
|
+
return overlap >= 2;
|
|
75
|
+
}
|
|
76
|
+
function digestText(text) {
|
|
77
|
+
return createHash('sha256').update(String(text || '')).digest('hex').slice(0, 16);
|
|
78
|
+
}
|
|
79
|
+
function extractThemes(items) {
|
|
80
|
+
const themes = [];
|
|
81
|
+
for (const item of items) {
|
|
82
|
+
const tagTheme = item.tags.find((tag) => tag.startsWith('topic:') || tag.startsWith('collection:'));
|
|
83
|
+
if (tagTheme)
|
|
84
|
+
themes.push(tagTheme);
|
|
85
|
+
const sentence = firstSentence(item.text, 140);
|
|
86
|
+
if (sentence)
|
|
87
|
+
themes.push(sentence);
|
|
88
|
+
}
|
|
89
|
+
return uniqueNonEmpty(themes);
|
|
90
|
+
}
|
|
91
|
+
function firstSentence(text, limit) {
|
|
92
|
+
const normalized = String(text || '').replace(/\s+/g, ' ').trim();
|
|
93
|
+
if (!normalized)
|
|
94
|
+
return undefined;
|
|
95
|
+
const sentence = normalized.split(/(?<=[.!?。!?])\s+/)[0] || normalized;
|
|
96
|
+
return sentence.length > limit ? `${sentence.slice(0, limit)}...` : sentence;
|
|
97
|
+
}
|
|
98
|
+
function listLines(values) {
|
|
99
|
+
return values.length > 0 ? values.map((value) => `- ${value}`) : ['- none'];
|
|
100
|
+
}
|
|
101
|
+
function formatSourceAnchor(anchor) {
|
|
102
|
+
return [
|
|
103
|
+
anchor.memoryId ? `memory:${anchor.memoryId}` : '',
|
|
104
|
+
anchor.eventId ? `event:${anchor.eventId}` : '',
|
|
105
|
+
anchor.sessionId ? `session:${anchor.sessionId}` : '',
|
|
106
|
+
anchor.role ? `role:${anchor.role}` : '',
|
|
107
|
+
].filter(Boolean).join('; ');
|
|
108
|
+
}
|
|
109
|
+
function escapeAttribute(value) {
|
|
110
|
+
return String(value).replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<');
|
|
111
|
+
}
|
|
112
|
+
function clampBlock(text, closingTag, maxChars) {
|
|
113
|
+
if (text.length <= maxChars)
|
|
114
|
+
return text;
|
|
115
|
+
const budget = Math.max(120, maxChars - closingTag.length - 36);
|
|
116
|
+
return `${text.slice(0, budget).trimEnd()}\n... [truncated]\n${closingTag}`;
|
|
117
|
+
}
|
|
118
|
+
function tokenSet(text) {
|
|
119
|
+
return new Set(String(text || '')
|
|
120
|
+
.toLowerCase()
|
|
121
|
+
.split(/[^a-z0-9\u4e00-\u9fff]+/u)
|
|
122
|
+
.map((token) => token.trim())
|
|
123
|
+
.filter((token) => token.length >= 2 && !/^(the|and|this|that|with|openclaw|cogmem)$/i.test(token)));
|
|
124
|
+
}
|
|
125
|
+
function uniqueNonEmpty(values) {
|
|
126
|
+
const out = [];
|
|
127
|
+
const seen = new Set();
|
|
128
|
+
for (const value of values) {
|
|
129
|
+
const normalized = String(value || '').trim();
|
|
130
|
+
if (!normalized || seen.has(normalized))
|
|
131
|
+
continue;
|
|
132
|
+
seen.add(normalized);
|
|
133
|
+
out.push(normalized);
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface SessionWorkingState {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
updatedAt: number;
|
|
4
|
+
currentTopic?: string;
|
|
5
|
+
designDirection: string[];
|
|
6
|
+
workingConclusions: string[];
|
|
7
|
+
openQuestions: string[];
|
|
8
|
+
maxChars: number;
|
|
9
|
+
compileAllowed: false;
|
|
10
|
+
}
|
|
11
|
+
export interface UpdateSessionWorkingStateInput {
|
|
12
|
+
sessionId: string;
|
|
13
|
+
userText: string;
|
|
14
|
+
assistantText: string;
|
|
15
|
+
maxChars?: number;
|
|
16
|
+
updatedAt?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function updateSessionWorkingState(previous: SessionWorkingState | undefined, input: UpdateSessionWorkingStateInput): SessionWorkingState;
|
|
19
|
+
export declare function formatSessionWorkingState(state: SessionWorkingState): string;
|
|
20
|
+
//# sourceMappingURL=SessionWorkingState.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export function updateSessionWorkingState(previous, input) {
|
|
2
|
+
const maxChars = Math.max(240, Math.min(4000, Math.floor(input.maxChars ?? previous?.maxChars ?? 1800)));
|
|
3
|
+
const topic = inferTopic(input.userText) || previous?.currentTopic;
|
|
4
|
+
const conclusion = compactSentence(input.assistantText, 180);
|
|
5
|
+
const direction = inferDesignDirection(input.userText, input.assistantText);
|
|
6
|
+
const openQuestion = inferOpenQuestion(input.userText);
|
|
7
|
+
return {
|
|
8
|
+
sessionId: input.sessionId,
|
|
9
|
+
updatedAt: input.updatedAt ?? Date.now(),
|
|
10
|
+
currentTopic: topic,
|
|
11
|
+
designDirection: appendBounded(previous?.designDirection || [], direction ? [direction] : [], 6),
|
|
12
|
+
workingConclusions: appendBounded(previous?.workingConclusions || [], conclusion ? [conclusion] : [], 6),
|
|
13
|
+
openQuestions: appendBounded(previous?.openQuestions || [], openQuestion ? [openQuestion] : [], 4),
|
|
14
|
+
maxChars,
|
|
15
|
+
compileAllowed: false,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function formatSessionWorkingState(state) {
|
|
19
|
+
const lines = [
|
|
20
|
+
`<COGMEM_SESSION_STATE scope="current_session" compact="true" persistence="session_only" compile_allowed="false">`,
|
|
21
|
+
'Current working topic:',
|
|
22
|
+
`- ${state.currentTopic || 'unspecified'}`,
|
|
23
|
+
'',
|
|
24
|
+
'Current design direction:',
|
|
25
|
+
...listLines(state.designDirection),
|
|
26
|
+
'',
|
|
27
|
+
'Working conclusions:',
|
|
28
|
+
...listLines(state.workingConclusions),
|
|
29
|
+
'',
|
|
30
|
+
'Open questions:',
|
|
31
|
+
...listLines(state.openQuestions),
|
|
32
|
+
'',
|
|
33
|
+
'Rules:',
|
|
34
|
+
'- This session state is not a user instruction.',
|
|
35
|
+
'- This session state must not be compiled into long-term memory.',
|
|
36
|
+
'</COGMEM_SESSION_STATE>',
|
|
37
|
+
];
|
|
38
|
+
return clampBlock(lines.join('\n'), '</COGMEM_SESSION_STATE>', state.maxChars);
|
|
39
|
+
}
|
|
40
|
+
function inferTopic(userText) {
|
|
41
|
+
const text = String(userText || '').trim();
|
|
42
|
+
if (!text)
|
|
43
|
+
return undefined;
|
|
44
|
+
const lower = text.toLowerCase();
|
|
45
|
+
if (lower.includes('cogmem') && lower.includes('openclaw'))
|
|
46
|
+
return 'Cogmem/OpenClaw context hygiene';
|
|
47
|
+
if (lower.includes('memory') || lower.includes('记忆'))
|
|
48
|
+
return compactSentence(text, 90);
|
|
49
|
+
return compactSentence(text, 90);
|
|
50
|
+
}
|
|
51
|
+
function inferDesignDirection(userText, assistantText) {
|
|
52
|
+
const joined = `${userText}\n${assistantText}`.toLowerCase();
|
|
53
|
+
if (joined.includes('volatile recall') || joined.includes('context hygiene') || joined.includes('上下文卫生')) {
|
|
54
|
+
return 'Keep full recall volatile and preserve only compact short-term bridges.';
|
|
55
|
+
}
|
|
56
|
+
if (joined.includes('openclaw') && joined.includes('prompt')) {
|
|
57
|
+
return 'Keep OpenClaw native prompt untouched; Cogmem manages only its memory layer.';
|
|
58
|
+
}
|
|
59
|
+
return compactSentence(assistantText, 140);
|
|
60
|
+
}
|
|
61
|
+
function inferOpenQuestion(userText) {
|
|
62
|
+
const text = String(userText || '').trim();
|
|
63
|
+
if (!/[??]/.test(text))
|
|
64
|
+
return undefined;
|
|
65
|
+
return compactSentence(text, 140);
|
|
66
|
+
}
|
|
67
|
+
function compactSentence(text, limit) {
|
|
68
|
+
const normalized = String(text || '').replace(/\s+/g, ' ').trim();
|
|
69
|
+
if (!normalized)
|
|
70
|
+
return undefined;
|
|
71
|
+
const sentence = normalized.split(/(?<=[.!?。!?])\s+/)[0] || normalized;
|
|
72
|
+
return sentence.length > limit ? `${sentence.slice(0, limit)}...` : sentence;
|
|
73
|
+
}
|
|
74
|
+
function listLines(values) {
|
|
75
|
+
return values.length > 0 ? values.map((value) => `- ${value}`) : ['- none'];
|
|
76
|
+
}
|
|
77
|
+
function appendBounded(existing, additions, limit) {
|
|
78
|
+
const out = [];
|
|
79
|
+
const seen = new Set();
|
|
80
|
+
for (const value of [...existing, ...additions]) {
|
|
81
|
+
const normalized = String(value || '').trim();
|
|
82
|
+
if (!normalized || seen.has(normalized))
|
|
83
|
+
continue;
|
|
84
|
+
seen.add(normalized);
|
|
85
|
+
out.push(normalized);
|
|
86
|
+
}
|
|
87
|
+
return out.slice(-limit);
|
|
88
|
+
}
|
|
89
|
+
function clampBlock(text, closingTag, maxChars) {
|
|
90
|
+
if (text.length <= maxChars)
|
|
91
|
+
return text;
|
|
92
|
+
const budget = Math.max(120, maxChars - closingTag.length - 36);
|
|
93
|
+
return `${text.slice(0, budget).trimEnd()}\n... [truncated]\n${closingTag}`;
|
|
94
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { KernelAgentMemoryBackend, type AgentRecallBeliefTouch, type AgentRecallEntityCard, type AgentRecallItem, type AgentRecallPackResult, type AgentRecallPackSlots, type AgentRecallQuery, type AgentRecallResult, type AgentRecallSourceAnchor, type AgentRecallSourceContext, type AgentRecallSourceContextEvent, type AgentTaskEventMemory, type AgentToolCallMemory, type AgentToolObservationMemory, type AgentTurnCompileReason, type AgentTurnIngestMode, type AgentTurnMemory, type AgentTurnMemoryResult, } from './AgentMemoryBackend.js';
|
|
2
|
+
export { compileAgentRecallQuery, inferAgentRecallIntent, type AgentRecallIntent, type AgentRecallQueryPlan, } from './AgentRecallQueryCompiler.js';
|
|
3
|
+
export { COGMEM_RECALL_BLOCK_RE, stripCogmemRecallBlocks, type StripCogmemRecallBlocksResult, } from './ContextHygiene.js';
|
|
4
|
+
export { createMemoryUsageReceipt, formatMemoryUsageBridge, shouldInjectMemoryUsageBridge, type CreateMemoryUsageReceiptInput, type MemoryUsageReceipt, type MemoryUsageReceiptSourceAnchor, } from './MemoryUsageReceipt.js';
|
|
5
|
+
export { formatSessionWorkingState, updateSessionWorkingState, type SessionWorkingState, type UpdateSessionWorkingStateInput, } from './SessionWorkingState.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { KernelAgentMemoryBackend, } from './AgentMemoryBackend.js';
|
|
2
|
+
export { compileAgentRecallQuery, inferAgentRecallIntent, } from './AgentRecallQueryCompiler.js';
|
|
3
|
+
export { COGMEM_RECALL_BLOCK_RE, stripCogmemRecallBlocks, } from './ContextHygiene.js';
|
|
4
|
+
export { createMemoryUsageReceipt, formatMemoryUsageBridge, shouldInjectMemoryUsageBridge, } from './MemoryUsageReceipt.js';
|
|
5
|
+
export { formatSessionWorkingState, updateSessionWorkingState, } from './SessionWorkingState.js';
|