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,125 @@
|
|
|
1
|
+
import { logger } from '../utils/Logger.js';
|
|
2
|
+
/**
|
|
3
|
+
* 基于 memory_events 的最小向量投影器。
|
|
4
|
+
* 目标:
|
|
5
|
+
* - 启动时优先 replay 增量事件
|
|
6
|
+
* - 只有在 checkpoint 不可信时才 full rebuild
|
|
7
|
+
*/
|
|
8
|
+
export class VectorProjector {
|
|
9
|
+
eventStore;
|
|
10
|
+
memoryGraph;
|
|
11
|
+
vectorStore;
|
|
12
|
+
projectionName;
|
|
13
|
+
constructor(eventStore, memoryGraph, vectorStore, projectionName = 'hnsw_main') {
|
|
14
|
+
this.eventStore = eventStore;
|
|
15
|
+
this.memoryGraph = memoryGraph;
|
|
16
|
+
this.vectorStore = vectorStore;
|
|
17
|
+
this.projectionName = projectionName;
|
|
18
|
+
}
|
|
19
|
+
async bootstrap() {
|
|
20
|
+
const checkpoint = this.eventStore.getProjectionCheckpoint(this.projectionName);
|
|
21
|
+
const pendingEvents = this.eventStore.getEventsAfter(checkpoint?.lastEventTime);
|
|
22
|
+
if (!checkpoint) {
|
|
23
|
+
await this.fullRebuild('initial_build');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (checkpoint.status !== 'ready') {
|
|
27
|
+
await this.fullRebuild(`checkpoint_${checkpoint.status}`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (pendingEvents.length === 0) {
|
|
31
|
+
logger.info(`Vector projection ready: count=${checkpoint.lastFullCount}`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
await this.replay(pendingEvents, checkpoint.lastRebuildAt);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
logger.warn('Vector replay failed, falling back to full rebuild', error);
|
|
39
|
+
await this.fullRebuild('replay_failed');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async fullRebuild(reason) {
|
|
43
|
+
logger.warn(`Rebuilding vector projection from SQLite: reason=${reason}`);
|
|
44
|
+
this.eventStore.upsertProjectionCheckpoint({
|
|
45
|
+
projectionName: this.projectionName,
|
|
46
|
+
status: 'building',
|
|
47
|
+
lastFullCount: 0,
|
|
48
|
+
metadata: { reason }
|
|
49
|
+
});
|
|
50
|
+
this.vectorStore.clear();
|
|
51
|
+
const pageSize = 2000;
|
|
52
|
+
let total = 0;
|
|
53
|
+
let pageNo = 0;
|
|
54
|
+
await this.memoryGraph.forEachNeuronVectorPage(pageSize, async (rows) => {
|
|
55
|
+
pageNo += 1;
|
|
56
|
+
for (const row of rows) {
|
|
57
|
+
if (row.vector.length === 0)
|
|
58
|
+
continue;
|
|
59
|
+
this.vectorStore.addVector(row.id, row.vector);
|
|
60
|
+
total += 1;
|
|
61
|
+
}
|
|
62
|
+
if (pageNo % 10 === 0) {
|
|
63
|
+
logger.info(`Vector rebuild progress: pages=${pageNo}, indexed=${total}`);
|
|
64
|
+
}
|
|
65
|
+
await Promise.resolve();
|
|
66
|
+
}, { includeStatuses: ['active', 'cold'], onlyNotDeleted: true });
|
|
67
|
+
const latestEvent = this.eventStore.getLatestEvent();
|
|
68
|
+
this.eventStore.upsertProjectionCheckpoint({
|
|
69
|
+
projectionName: this.projectionName,
|
|
70
|
+
lastEventId: latestEvent?.eventId,
|
|
71
|
+
lastEventTime: latestEvent?.occurredAt,
|
|
72
|
+
lastRebuildAt: Date.now(),
|
|
73
|
+
lastFullCount: this.vectorStore.getCurrentCount(),
|
|
74
|
+
status: 'ready',
|
|
75
|
+
metadata: {
|
|
76
|
+
reason,
|
|
77
|
+
mode: 'full_rebuild'
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async replay(events, previousRebuildAt) {
|
|
82
|
+
if (events.length === 0)
|
|
83
|
+
return;
|
|
84
|
+
logger.info(`Replaying vector projection events: count=${events.length}`);
|
|
85
|
+
for (const event of events) {
|
|
86
|
+
this.applyEvent(event);
|
|
87
|
+
await Promise.resolve();
|
|
88
|
+
}
|
|
89
|
+
const lastEvent = events[events.length - 1];
|
|
90
|
+
this.eventStore.upsertProjectionCheckpoint({
|
|
91
|
+
projectionName: this.projectionName,
|
|
92
|
+
lastEventId: lastEvent?.eventId,
|
|
93
|
+
lastEventTime: lastEvent?.occurredAt,
|
|
94
|
+
lastRebuildAt: previousRebuildAt,
|
|
95
|
+
lastFullCount: this.vectorStore.getCurrentCount(),
|
|
96
|
+
status: 'ready',
|
|
97
|
+
metadata: {
|
|
98
|
+
mode: 'incremental_replay',
|
|
99
|
+
replayedEventCount: events.length
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
applyEvent(event) {
|
|
104
|
+
switch (event.eventType) {
|
|
105
|
+
case 'INGESTED':
|
|
106
|
+
case 'RESTORED': {
|
|
107
|
+
const neuron = this.memoryGraph.getNeuron(event.streamId);
|
|
108
|
+
if (!neuron)
|
|
109
|
+
return;
|
|
110
|
+
if (neuron.metadata.status === 'archived')
|
|
111
|
+
return;
|
|
112
|
+
if (!neuron.coordinates.V || neuron.coordinates.V.length === 0)
|
|
113
|
+
return;
|
|
114
|
+
this.vectorStore.addVector(neuron.id, neuron.coordinates.V);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
case 'ARCHIVED': {
|
|
118
|
+
this.vectorStore.removePoint(event.streamId);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
default:
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { IVectorStore, VectorSearchResult, VectorStoreStats } from './IVectorStore.js';
|
|
2
|
+
export declare class VectorStore implements IVectorStore {
|
|
3
|
+
private index;
|
|
4
|
+
private dimension;
|
|
5
|
+
private maxElements;
|
|
6
|
+
private efConstruction;
|
|
7
|
+
private efSearch;
|
|
8
|
+
private neuronIdMap;
|
|
9
|
+
private idIndexMap;
|
|
10
|
+
private tombstones;
|
|
11
|
+
private fallbackVectors;
|
|
12
|
+
private nextLabel;
|
|
13
|
+
constructor(dimension?: number, maxElements?: number, efConstruction?: number, efSearch?: number);
|
|
14
|
+
addVector(neuronId: string, vector: number[]): void;
|
|
15
|
+
addVectors(vectors: Array<{
|
|
16
|
+
id: string;
|
|
17
|
+
vector: number[];
|
|
18
|
+
}>): void;
|
|
19
|
+
removePoint(neuronId: string): void;
|
|
20
|
+
search(queryVector: number[], k?: number): VectorSearchResult[];
|
|
21
|
+
private cosineSimilarity;
|
|
22
|
+
size(): number;
|
|
23
|
+
getCurrentCount(): number;
|
|
24
|
+
saveIndex(filePath: string): Promise<void>;
|
|
25
|
+
loadIndex(filePath: string): Promise<void>;
|
|
26
|
+
getStats(): VectorStoreStats;
|
|
27
|
+
clear(): void;
|
|
28
|
+
checkIntegrity(): boolean;
|
|
29
|
+
rebuildIndex(neurons: Array<{
|
|
30
|
+
id: string;
|
|
31
|
+
vector: number[];
|
|
32
|
+
}>): Promise<void>;
|
|
33
|
+
private ensureCapacity;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=VectorStore.d.ts.map
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// ============================================
|
|
2
|
+
// 向量存储 - hnswlib-node 实现
|
|
3
|
+
// ============================================
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { config } from '../utils/Config.js';
|
|
6
|
+
import { logger } from '../utils/Logger.js';
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
let HierarchicalNSWClass = null;
|
|
9
|
+
try {
|
|
10
|
+
({ HierarchicalNSW: HierarchicalNSWClass } = require('hnswlib-node'));
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
HierarchicalNSWClass = null;
|
|
14
|
+
}
|
|
15
|
+
export class VectorStore {
|
|
16
|
+
index;
|
|
17
|
+
dimension;
|
|
18
|
+
maxElements;
|
|
19
|
+
efConstruction;
|
|
20
|
+
efSearch;
|
|
21
|
+
neuronIdMap = new Map();
|
|
22
|
+
idIndexMap = new Map();
|
|
23
|
+
tombstones = new Set();
|
|
24
|
+
fallbackVectors = new Map();
|
|
25
|
+
nextLabel = 0;
|
|
26
|
+
constructor(dimension = config.vector.dimension, maxElements = config.vector.maxElements, efConstruction = config.vector.efConstruction, efSearch = config.vector.efSearch) {
|
|
27
|
+
this.dimension = dimension;
|
|
28
|
+
this.maxElements = maxElements;
|
|
29
|
+
this.efConstruction = efConstruction;
|
|
30
|
+
this.efSearch = efSearch;
|
|
31
|
+
if (HierarchicalNSWClass) {
|
|
32
|
+
this.index = new HierarchicalNSWClass('cosine', dimension);
|
|
33
|
+
this.index.initIndex(maxElements, 16, efConstruction);
|
|
34
|
+
this.index.setEf(efSearch);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
logger?.warn?.('hnswlib-node not available, VectorStore falling back to exact search');
|
|
38
|
+
this.index = null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
addVector(neuronId, vector) {
|
|
42
|
+
if (vector.length !== this.dimension) {
|
|
43
|
+
throw new Error(`Vector dimension mismatch: expected ${this.dimension}, got ${vector.length}`);
|
|
44
|
+
}
|
|
45
|
+
if (this.idIndexMap.has(neuronId)) {
|
|
46
|
+
this.removePoint(neuronId);
|
|
47
|
+
}
|
|
48
|
+
this.ensureCapacity(this.nextLabel + 1);
|
|
49
|
+
const label = this.nextLabel++;
|
|
50
|
+
if (this.index) {
|
|
51
|
+
this.index.addPoint(vector, label);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.fallbackVectors.set(neuronId, [...vector]);
|
|
55
|
+
}
|
|
56
|
+
this.neuronIdMap.set(label, neuronId);
|
|
57
|
+
this.idIndexMap.set(neuronId, label);
|
|
58
|
+
this.tombstones.delete(neuronId);
|
|
59
|
+
}
|
|
60
|
+
addVectors(vectors) {
|
|
61
|
+
for (const item of vectors)
|
|
62
|
+
this.addVector(item.id, item.vector);
|
|
63
|
+
}
|
|
64
|
+
removePoint(neuronId) {
|
|
65
|
+
const label = this.idIndexMap.get(neuronId);
|
|
66
|
+
if (label === undefined)
|
|
67
|
+
return;
|
|
68
|
+
if (this.index) {
|
|
69
|
+
try {
|
|
70
|
+
this.index.markDelete(label);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
logger.warn(`Failed to mark vector deleted for ${neuronId}:`, error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
this.idIndexMap.delete(neuronId);
|
|
77
|
+
this.neuronIdMap.delete(label);
|
|
78
|
+
this.tombstones.add(neuronId);
|
|
79
|
+
this.fallbackVectors.delete(neuronId);
|
|
80
|
+
}
|
|
81
|
+
search(queryVector, k = config.vector.topK) {
|
|
82
|
+
if (queryVector.length !== this.dimension) {
|
|
83
|
+
throw new Error(`Query vector dimension mismatch: expected ${this.dimension}, got ${queryVector.length}`);
|
|
84
|
+
}
|
|
85
|
+
if (this.idIndexMap.size === 0)
|
|
86
|
+
return [];
|
|
87
|
+
if (this.index) {
|
|
88
|
+
const rawK = Math.max(k * 3, k);
|
|
89
|
+
const result = this.index.searchKnn(queryVector, Math.min(rawK, this.nextLabel));
|
|
90
|
+
const ranked = [];
|
|
91
|
+
for (let i = 0; i < result.neighbors.length; i++) {
|
|
92
|
+
const label = result.neighbors[i];
|
|
93
|
+
const neuronId = this.neuronIdMap.get(label);
|
|
94
|
+
if (!neuronId || this.tombstones.has(neuronId))
|
|
95
|
+
continue;
|
|
96
|
+
ranked.push({
|
|
97
|
+
id: neuronId,
|
|
98
|
+
score: 1 - result.distances[i]
|
|
99
|
+
});
|
|
100
|
+
if (ranked.length >= k)
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
return ranked;
|
|
104
|
+
}
|
|
105
|
+
return Array.from(this.fallbackVectors.entries())
|
|
106
|
+
.filter(([id]) => !this.tombstones.has(id))
|
|
107
|
+
.map(([id, vector]) => ({
|
|
108
|
+
id,
|
|
109
|
+
score: this.cosineSimilarity(queryVector, vector)
|
|
110
|
+
}))
|
|
111
|
+
.sort((a, b) => b.score - a.score)
|
|
112
|
+
.slice(0, k);
|
|
113
|
+
}
|
|
114
|
+
cosineSimilarity(a, b) {
|
|
115
|
+
let dot = 0;
|
|
116
|
+
let normA = 0;
|
|
117
|
+
let normB = 0;
|
|
118
|
+
for (let i = 0; i < this.dimension; i++) {
|
|
119
|
+
const av = a[i] || 0;
|
|
120
|
+
const bv = b[i] || 0;
|
|
121
|
+
dot += av * bv;
|
|
122
|
+
normA += av * av;
|
|
123
|
+
normB += bv * bv;
|
|
124
|
+
}
|
|
125
|
+
if (normA === 0 || normB === 0)
|
|
126
|
+
return 0;
|
|
127
|
+
return dot / (Math.sqrt(normA) * Math.sqrt(normB));
|
|
128
|
+
}
|
|
129
|
+
size() {
|
|
130
|
+
return this.idIndexMap.size;
|
|
131
|
+
}
|
|
132
|
+
getCurrentCount() {
|
|
133
|
+
return this.size();
|
|
134
|
+
}
|
|
135
|
+
async saveIndex(filePath) {
|
|
136
|
+
if (!this.index)
|
|
137
|
+
return;
|
|
138
|
+
await this.index.writeIndex(filePath);
|
|
139
|
+
}
|
|
140
|
+
async loadIndex(filePath) {
|
|
141
|
+
if (!this.index)
|
|
142
|
+
return;
|
|
143
|
+
await this.index.readIndex(filePath);
|
|
144
|
+
this.index.setEf(this.efSearch);
|
|
145
|
+
}
|
|
146
|
+
getStats() {
|
|
147
|
+
return {
|
|
148
|
+
backend: 'hnswlib',
|
|
149
|
+
size: this.size(),
|
|
150
|
+
dimension: this.dimension,
|
|
151
|
+
maxElements: this.maxElements,
|
|
152
|
+
efConstruction: this.efConstruction,
|
|
153
|
+
efSearch: this.efSearch,
|
|
154
|
+
tombstones: this.tombstones.size
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
clear() {
|
|
158
|
+
if (HierarchicalNSWClass) {
|
|
159
|
+
this.index = new HierarchicalNSWClass('cosine', this.dimension);
|
|
160
|
+
this.index.initIndex(this.maxElements, 16, this.efConstruction);
|
|
161
|
+
this.index.setEf(this.efSearch);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
this.index = null;
|
|
165
|
+
}
|
|
166
|
+
this.neuronIdMap.clear();
|
|
167
|
+
this.idIndexMap.clear();
|
|
168
|
+
this.tombstones.clear();
|
|
169
|
+
this.fallbackVectors.clear();
|
|
170
|
+
this.nextLabel = 0;
|
|
171
|
+
}
|
|
172
|
+
checkIntegrity() {
|
|
173
|
+
try {
|
|
174
|
+
if (this.idIndexMap.size === 0)
|
|
175
|
+
return true;
|
|
176
|
+
const dummyVector = new Array(this.dimension).fill(0);
|
|
177
|
+
this.search(dummyVector, 1);
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
logger.error('Vector store integrity check failed:', error);
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async rebuildIndex(neurons) {
|
|
186
|
+
this.clear();
|
|
187
|
+
this.addVectors(neurons);
|
|
188
|
+
}
|
|
189
|
+
ensureCapacity(requiredTotal) {
|
|
190
|
+
if (!this.index)
|
|
191
|
+
return;
|
|
192
|
+
if (requiredTotal <= this.maxElements)
|
|
193
|
+
return;
|
|
194
|
+
let nextCapacity = this.maxElements;
|
|
195
|
+
while (nextCapacity < requiredTotal) {
|
|
196
|
+
nextCapacity = Math.max(nextCapacity * 2, requiredTotal);
|
|
197
|
+
}
|
|
198
|
+
this.index.resizeIndex(nextCapacity);
|
|
199
|
+
this.maxElements = nextCapacity;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ContextIntent, ContextLayer } from '../context/ContextCortex.js';
|
|
2
|
+
export type StrategyTemplateId = 'no-memory' | 'continuity-only' | 'source-first' | 'temporal-first' | 'user-belief-first' | 'project-state' | 'graph-source' | 'balanced-memory';
|
|
3
|
+
export type RetrievalLane = 'graph' | 'compiled' | 'raw_source';
|
|
4
|
+
export type StrategySourcePolicy = 'not_needed' | 'fallback' | 'on_dispute' | 'required';
|
|
5
|
+
export type StrategyReplanReason = 'intent_changed' | 'project_changed' | 'source_requirement_unmet' | 'evidence_conflict' | 'budget_unsatisfied';
|
|
6
|
+
export interface StrategyRetrievalPolicy {
|
|
7
|
+
allowedLanes: RetrievalLane[];
|
|
8
|
+
preferredLanes: RetrievalLane[];
|
|
9
|
+
requiredLane?: RetrievalLane;
|
|
10
|
+
}
|
|
11
|
+
export interface StrategyCapsule {
|
|
12
|
+
version: 'strategy_capsule.v1';
|
|
13
|
+
capsuleId: string;
|
|
14
|
+
templateId: StrategyTemplateId;
|
|
15
|
+
intent: ContextIntent;
|
|
16
|
+
objective: string;
|
|
17
|
+
projectId?: string;
|
|
18
|
+
primaryLayers: ContextLayer[];
|
|
19
|
+
secondaryLayers: ContextLayer[];
|
|
20
|
+
excludedLayers: ContextLayer[];
|
|
21
|
+
retrievalPolicy: StrategyRetrievalPolicy;
|
|
22
|
+
sourcePolicy: StrategySourcePolicy;
|
|
23
|
+
maxMemoryRatio: number;
|
|
24
|
+
maxItems: number;
|
|
25
|
+
instructionAuthority: 'none';
|
|
26
|
+
persistAllowed: false;
|
|
27
|
+
generatedBy: 'deterministic';
|
|
28
|
+
fixedWithinTurn: true;
|
|
29
|
+
revision: number;
|
|
30
|
+
maxReplans: 1;
|
|
31
|
+
replanReason?: StrategyReplanReason;
|
|
32
|
+
createdAt: number;
|
|
33
|
+
}
|
|
34
|
+
export interface StrategyTemplate {
|
|
35
|
+
templateId: StrategyTemplateId;
|
|
36
|
+
objective: string;
|
|
37
|
+
primaryLayers: ContextLayer[];
|
|
38
|
+
secondaryLayers: ContextLayer[];
|
|
39
|
+
retrievalPolicy: StrategyRetrievalPolicy;
|
|
40
|
+
sourcePolicy: StrategySourcePolicy;
|
|
41
|
+
maxMemoryRatio: number;
|
|
42
|
+
maxItems: number;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=StrategyCapsule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ContextCandidate } from '../context/ContextCortex.js';
|
|
2
|
+
import type { StrategyCapsule } from './StrategyCapsule.js';
|
|
3
|
+
export declare class StrategyConditionedCandidateBuilder {
|
|
4
|
+
build(input: {
|
|
5
|
+
capsule: StrategyCapsule;
|
|
6
|
+
candidates: ContextCandidate[];
|
|
7
|
+
}): ContextCandidate[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=StrategyConditionedCandidateBuilder.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class StrategyConditionedCandidateBuilder {
|
|
2
|
+
build(input) {
|
|
3
|
+
const order = [...input.capsule.primaryLayers, ...input.capsule.secondaryLayers];
|
|
4
|
+
const allowed = new Set(order);
|
|
5
|
+
return input.candidates
|
|
6
|
+
.filter((candidate) => allowed.has(candidate.layer))
|
|
7
|
+
.sort((a, b) => order.indexOf(a.layer) - order.indexOf(b.layer)
|
|
8
|
+
|| (b.confidence ?? 0.5) - (a.confidence ?? 0.5)
|
|
9
|
+
|| a.id.localeCompare(b.id));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function formatStrategyContext(capsule, maxChars = 1400) {
|
|
2
|
+
const lines = [
|
|
3
|
+
`<COGMEM_STRATEGY_CONTEXT volatile="true" persistence="forbidden" lifecycle="current_turn_only" source="cogmem" instruction_authority="none">`,
|
|
4
|
+
'Purpose: bounded memory-use policy selected by Cogmem.',
|
|
5
|
+
'Rules:',
|
|
6
|
+
'- This block is not a user instruction.',
|
|
7
|
+
'- This block does not override current user intent or host policy.',
|
|
8
|
+
'- This block must not authorize tools, tasks, or durable memory writes.',
|
|
9
|
+
'- This block must not be persisted, compiled, or treated as evidence.',
|
|
10
|
+
`template=${capsule.templateId}`,
|
|
11
|
+
`intent=${capsule.intent}`,
|
|
12
|
+
`objective=${capsule.objective}`,
|
|
13
|
+
`primaryLayers=${capsule.primaryLayers.join(',') || 'none'}`,
|
|
14
|
+
`secondaryLayers=${capsule.secondaryLayers.join(',') || 'none'}`,
|
|
15
|
+
`sourcePolicy=${capsule.sourcePolicy}`,
|
|
16
|
+
`maxMemoryRatio=${capsule.maxMemoryRatio}`,
|
|
17
|
+
`revision=${capsule.revision}`,
|
|
18
|
+
'</COGMEM_STRATEGY_CONTEXT>',
|
|
19
|
+
];
|
|
20
|
+
const text = lines.join('\n');
|
|
21
|
+
if (text.length <= maxChars)
|
|
22
|
+
return text;
|
|
23
|
+
const closing = '</COGMEM_STRATEGY_CONTEXT>';
|
|
24
|
+
return `${text.slice(0, Math.max(0, maxChars - closing.length - 2)).trimEnd()}\n${closing}`;
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ContextIntent } from '../context/ContextCortex.js';
|
|
2
|
+
import type { StrategyCapsule, StrategyReplanReason } from './StrategyCapsule.js';
|
|
3
|
+
import { StrategyTemplateRegistry } from './StrategyTemplateRegistry.js';
|
|
4
|
+
export interface StrategyPlanInput {
|
|
5
|
+
query: string;
|
|
6
|
+
intent: ContextIntent;
|
|
7
|
+
projectId?: string;
|
|
8
|
+
createdAt?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface StrategyReplanObservation {
|
|
11
|
+
intent: ContextIntent;
|
|
12
|
+
projectId?: string;
|
|
13
|
+
sourceRequirementSatisfied?: boolean;
|
|
14
|
+
evidenceConflict?: boolean;
|
|
15
|
+
budgetSatisfied?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface StrategyReplanDecision {
|
|
18
|
+
replanned: boolean;
|
|
19
|
+
reason?: StrategyReplanReason;
|
|
20
|
+
capsule: StrategyCapsule;
|
|
21
|
+
}
|
|
22
|
+
export declare class StrategyCortex {
|
|
23
|
+
private readonly registry;
|
|
24
|
+
constructor(registry?: StrategyTemplateRegistry);
|
|
25
|
+
plan(input: StrategyPlanInput): StrategyCapsule;
|
|
26
|
+
replan(current: StrategyCapsule, observation: StrategyReplanObservation): StrategyReplanDecision;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=StrategyCortex.d.ts.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { StrategyTemplateRegistry } from './StrategyTemplateRegistry.js';
|
|
3
|
+
export class StrategyCortex {
|
|
4
|
+
registry;
|
|
5
|
+
constructor(registry = new StrategyTemplateRegistry()) {
|
|
6
|
+
this.registry = registry;
|
|
7
|
+
}
|
|
8
|
+
plan(input) {
|
|
9
|
+
const template = this.registry.forIntent(input.intent);
|
|
10
|
+
return {
|
|
11
|
+
version: 'strategy_capsule.v1',
|
|
12
|
+
capsuleId: `strategy-${randomUUID()}`,
|
|
13
|
+
templateId: template.templateId,
|
|
14
|
+
intent: input.intent,
|
|
15
|
+
objective: template.objective,
|
|
16
|
+
projectId: normalizeProjectId(input.projectId),
|
|
17
|
+
primaryLayers: template.primaryLayers,
|
|
18
|
+
secondaryLayers: template.secondaryLayers,
|
|
19
|
+
excludedLayers: this.registry.excludedLayers(template),
|
|
20
|
+
retrievalPolicy: template.retrievalPolicy,
|
|
21
|
+
sourcePolicy: template.sourcePolicy,
|
|
22
|
+
maxMemoryRatio: template.maxMemoryRatio,
|
|
23
|
+
maxItems: template.maxItems,
|
|
24
|
+
instructionAuthority: 'none',
|
|
25
|
+
persistAllowed: false,
|
|
26
|
+
generatedBy: 'deterministic',
|
|
27
|
+
fixedWithinTurn: true,
|
|
28
|
+
revision: 1,
|
|
29
|
+
maxReplans: 1,
|
|
30
|
+
createdAt: input.createdAt ?? Date.now(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
replan(current, observation) {
|
|
34
|
+
const reason = replanReason(current, observation);
|
|
35
|
+
if (!reason || current.revision > current.maxReplans)
|
|
36
|
+
return { replanned: false, capsule: current };
|
|
37
|
+
const next = this.plan({
|
|
38
|
+
query: '',
|
|
39
|
+
intent: observation.intent,
|
|
40
|
+
projectId: observation.projectId,
|
|
41
|
+
createdAt: current.createdAt,
|
|
42
|
+
});
|
|
43
|
+
next.capsuleId = current.capsuleId;
|
|
44
|
+
next.revision = current.revision + 1;
|
|
45
|
+
next.replanReason = reason;
|
|
46
|
+
if (reason === 'source_requirement_unmet') {
|
|
47
|
+
next.retrievalPolicy = {
|
|
48
|
+
allowedLanes: ['raw_source', 'graph'],
|
|
49
|
+
preferredLanes: ['raw_source', 'graph'],
|
|
50
|
+
requiredLane: 'raw_source',
|
|
51
|
+
};
|
|
52
|
+
next.primaryLayers = ['raw_source', 'graph'];
|
|
53
|
+
next.secondaryLayers = [];
|
|
54
|
+
next.excludedLayers = this.registry.excludedLayers({
|
|
55
|
+
...this.registry.get('source-first'), primaryLayers: next.primaryLayers, secondaryLayers: [],
|
|
56
|
+
});
|
|
57
|
+
next.maxMemoryRatio = 0.3;
|
|
58
|
+
}
|
|
59
|
+
return { replanned: true, reason, capsule: next };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function replanReason(current, observation) {
|
|
63
|
+
if (observation.intent !== current.intent)
|
|
64
|
+
return 'intent_changed';
|
|
65
|
+
if (normalizeProjectId(observation.projectId) !== current.projectId)
|
|
66
|
+
return 'project_changed';
|
|
67
|
+
if (current.sourcePolicy === 'required' && observation.sourceRequirementSatisfied === false)
|
|
68
|
+
return 'source_requirement_unmet';
|
|
69
|
+
if (observation.evidenceConflict)
|
|
70
|
+
return 'evidence_conflict';
|
|
71
|
+
if (observation.budgetSatisfied === false)
|
|
72
|
+
return 'budget_unsatisfied';
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
function normalizeProjectId(value) {
|
|
76
|
+
const normalized = value?.trim();
|
|
77
|
+
return normalized || undefined;
|
|
78
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ContextIntent, ContextLayer } from '../context/ContextCortex.js';
|
|
2
|
+
import type { StrategyTemplate, StrategyTemplateId } from './StrategyCapsule.js';
|
|
3
|
+
export declare class StrategyTemplateRegistry {
|
|
4
|
+
forIntent(intent: ContextIntent): StrategyTemplate;
|
|
5
|
+
get(templateId: StrategyTemplateId): StrategyTemplate;
|
|
6
|
+
excludedLayers(template: StrategyTemplate): ContextLayer[];
|
|
7
|
+
list(): StrategyTemplate[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=StrategyTemplateRegistry.d.ts.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const ALL_LAYERS = [
|
|
2
|
+
'session_state', 'turn_bridge', 'belief', 'temporal', 'graph', 'raw_source', 'vector',
|
|
3
|
+
];
|
|
4
|
+
const TEMPLATES = {
|
|
5
|
+
'no-memory': {
|
|
6
|
+
templateId: 'no-memory', objective: 'avoid_unnecessary_memory', primaryLayers: [], secondaryLayers: [],
|
|
7
|
+
retrievalPolicy: { allowedLanes: [], preferredLanes: [] }, sourcePolicy: 'not_needed', maxMemoryRatio: 0, maxItems: 0,
|
|
8
|
+
},
|
|
9
|
+
'continuity-only': {
|
|
10
|
+
templateId: 'continuity-only', objective: 'preserve_local_turn_continuity',
|
|
11
|
+
primaryLayers: ['session_state', 'turn_bridge'], secondaryLayers: [],
|
|
12
|
+
retrievalPolicy: { allowedLanes: [], preferredLanes: [] }, sourcePolicy: 'not_needed', maxMemoryRatio: 0.1, maxItems: 2,
|
|
13
|
+
},
|
|
14
|
+
'source-first': {
|
|
15
|
+
templateId: 'source-first', objective: 'recover_exact_source_evidence',
|
|
16
|
+
primaryLayers: ['raw_source', 'graph'], secondaryLayers: ['belief'],
|
|
17
|
+
retrievalPolicy: {
|
|
18
|
+
allowedLanes: ['raw_source', 'graph', 'compiled'], preferredLanes: ['raw_source', 'graph', 'compiled'], requiredLane: 'raw_source',
|
|
19
|
+
},
|
|
20
|
+
sourcePolicy: 'required', maxMemoryRatio: 0.25, maxItems: 3,
|
|
21
|
+
},
|
|
22
|
+
'temporal-first': {
|
|
23
|
+
templateId: 'temporal-first', objective: 'reconstruct_current_and_prior_decisions',
|
|
24
|
+
primaryLayers: ['temporal', 'belief'], secondaryLayers: ['raw_source', 'graph'],
|
|
25
|
+
retrievalPolicy: { allowedLanes: ['graph', 'compiled', 'raw_source'], preferredLanes: ['compiled', 'graph', 'raw_source'] },
|
|
26
|
+
sourcePolicy: 'on_dispute', maxMemoryRatio: 0.25, maxItems: 4,
|
|
27
|
+
},
|
|
28
|
+
'user-belief-first': {
|
|
29
|
+
templateId: 'user-belief-first', objective: 'recover_user_owned_memory_with_explicit_evidence',
|
|
30
|
+
primaryLayers: ['belief', 'raw_source'], secondaryLayers: ['graph'],
|
|
31
|
+
retrievalPolicy: { allowedLanes: ['compiled', 'graph', 'raw_source'], preferredLanes: ['compiled', 'raw_source', 'graph'] },
|
|
32
|
+
sourcePolicy: 'on_dispute', maxMemoryRatio: 0.2, maxItems: 3,
|
|
33
|
+
},
|
|
34
|
+
'project-state': {
|
|
35
|
+
templateId: 'project-state', objective: 'recover_current_project_state',
|
|
36
|
+
primaryLayers: ['belief', 'temporal'], secondaryLayers: ['graph', 'raw_source'],
|
|
37
|
+
retrievalPolicy: { allowedLanes: ['graph', 'compiled', 'raw_source'], preferredLanes: ['compiled', 'graph', 'raw_source'] },
|
|
38
|
+
sourcePolicy: 'on_dispute', maxMemoryRatio: 0.25, maxItems: 4,
|
|
39
|
+
},
|
|
40
|
+
'graph-source': {
|
|
41
|
+
templateId: 'graph-source', objective: 'trace_failure_to_connected_source_evidence',
|
|
42
|
+
primaryLayers: ['graph', 'raw_source'], secondaryLayers: ['belief', 'temporal'],
|
|
43
|
+
retrievalPolicy: { allowedLanes: ['graph', 'raw_source', 'compiled'], preferredLanes: ['graph', 'raw_source', 'compiled'] },
|
|
44
|
+
sourcePolicy: 'on_dispute', maxMemoryRatio: 0.25, maxItems: 4,
|
|
45
|
+
},
|
|
46
|
+
'balanced-memory': {
|
|
47
|
+
templateId: 'balanced-memory', objective: 'recover_governed_relevant_memory',
|
|
48
|
+
primaryLayers: ['belief', 'graph', 'temporal'], secondaryLayers: ['raw_source', 'vector'],
|
|
49
|
+
retrievalPolicy: { allowedLanes: ['graph', 'compiled', 'raw_source'], preferredLanes: ['graph', 'compiled', 'raw_source'] },
|
|
50
|
+
sourcePolicy: 'fallback', maxMemoryRatio: 0.25, maxItems: 4,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
const INTENT_TEMPLATE = {
|
|
54
|
+
greeting: 'no-memory',
|
|
55
|
+
short_followup: 'continuity-only',
|
|
56
|
+
exact_quote: 'source-first',
|
|
57
|
+
decision_history: 'temporal-first',
|
|
58
|
+
preference_lookup: 'user-belief-first',
|
|
59
|
+
project_status: 'project-state',
|
|
60
|
+
debugging: 'graph-source',
|
|
61
|
+
general_memory: 'balanced-memory',
|
|
62
|
+
};
|
|
63
|
+
export class StrategyTemplateRegistry {
|
|
64
|
+
forIntent(intent) {
|
|
65
|
+
return this.get(INTENT_TEMPLATE[intent]);
|
|
66
|
+
}
|
|
67
|
+
get(templateId) {
|
|
68
|
+
const template = TEMPLATES[templateId];
|
|
69
|
+
return structuredClone(template);
|
|
70
|
+
}
|
|
71
|
+
excludedLayers(template) {
|
|
72
|
+
const allowed = new Set([...template.primaryLayers, ...template.secondaryLayers]);
|
|
73
|
+
return ALL_LAYERS.filter((layer) => !allowed.has(layer));
|
|
74
|
+
}
|
|
75
|
+
list() {
|
|
76
|
+
return Object.keys(TEMPLATES).map((id) => this.get(id));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './StrategyCapsule.js';
|
|
2
|
+
export * from './StrategyTemplateRegistry.js';
|
|
3
|
+
export * from './StrategyCortex.js';
|
|
4
|
+
export * from './StrategyConditionedCandidateBuilder.js';
|
|
5
|
+
export * from './StrategyContextFormatter.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|