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,567 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
const NORMALIZED_SOURCE_FAMILY = 'normalized_conversation_markdown';
|
|
4
|
+
const NORMALIZATION_CONTRACT_VERSION = 'v1';
|
|
5
|
+
const DEFAULT_ONBOARDING_PATH = 'export/preprocess -> normalize -> batch:preflight -> batch:consolidate --strict -> recall';
|
|
6
|
+
export function parseNormalizerArgs(argv, usage) {
|
|
7
|
+
const args = argv[0] === '--' ? argv.slice(1) : argv;
|
|
8
|
+
const result = {
|
|
9
|
+
title: 'Normalized Conversation Export',
|
|
10
|
+
format: undefined
|
|
11
|
+
};
|
|
12
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
13
|
+
const token = args[index];
|
|
14
|
+
if (token === '--input')
|
|
15
|
+
result.input = args[index + 1];
|
|
16
|
+
if (token === '--output')
|
|
17
|
+
result.output = args[index + 1];
|
|
18
|
+
if (token === '--title')
|
|
19
|
+
result.title = args[index + 1];
|
|
20
|
+
if (token === '--format') {
|
|
21
|
+
const format = args[index + 1];
|
|
22
|
+
if (format === 'csv' || format === 'tsv')
|
|
23
|
+
result.format = format;
|
|
24
|
+
}
|
|
25
|
+
if (token.startsWith('--'))
|
|
26
|
+
index += 1;
|
|
27
|
+
}
|
|
28
|
+
if (!result.input || !result.output) {
|
|
29
|
+
throw new Error(usage);
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
export function normalizeRole(input) {
|
|
34
|
+
const lowered = (input || '').trim().toLowerCase();
|
|
35
|
+
if (['assistant', 'agent', 'ai', 'bot', 'model'].includes(lowered))
|
|
36
|
+
return 'agent';
|
|
37
|
+
if (['system', 'sys'].includes(lowered))
|
|
38
|
+
return 'system';
|
|
39
|
+
if (['narrator', 'note', 'notes', 'memo'].includes(lowered))
|
|
40
|
+
return 'narrator';
|
|
41
|
+
return 'user';
|
|
42
|
+
}
|
|
43
|
+
export function pickMessageText(item) {
|
|
44
|
+
const direct = coerceText(item.content) || coerceText(item.text) || coerceText(item.message);
|
|
45
|
+
return direct.trim();
|
|
46
|
+
}
|
|
47
|
+
export function pickTimestamp(item, fallback) {
|
|
48
|
+
const raw = coerceText(item.occurredAt)
|
|
49
|
+
|| coerceText(item.occurred_at)
|
|
50
|
+
|| coerceText(item.timestamp)
|
|
51
|
+
|| coerceText(item.created_at)
|
|
52
|
+
|| coerceText(item.createdAt)
|
|
53
|
+
|| coerceText(item.sentAt)
|
|
54
|
+
|| coerceText(item.sent_at)
|
|
55
|
+
|| coerceText(item.time)
|
|
56
|
+
|| coerceText(item.InsertTime)
|
|
57
|
+
|| coerceText(item.insertTime)
|
|
58
|
+
|| coerceText(item.insert_time);
|
|
59
|
+
const date = raw ? parseTimestampDate(raw, fallback) : new Date(fallback);
|
|
60
|
+
const usable = Number.isNaN(date.getTime()) ? new Date(fallback) : date;
|
|
61
|
+
return usable.toISOString();
|
|
62
|
+
}
|
|
63
|
+
export function writeNormalizedConversationMarkdown(outputPath, title, family, messages, markers = []) {
|
|
64
|
+
assertNormalizedMessages(messages, family);
|
|
65
|
+
const uniqueMarkers = dedupeMarkers(markers);
|
|
66
|
+
const content = [
|
|
67
|
+
`# ${title}`,
|
|
68
|
+
'',
|
|
69
|
+
'<!-- cogmem-normalized: true -->',
|
|
70
|
+
`<!-- cogmem-normalization-contract: ${NORMALIZATION_CONTRACT_VERSION} -->`,
|
|
71
|
+
`<!-- cogmem-normalized-source-family: ${NORMALIZED_SOURCE_FAMILY} -->`,
|
|
72
|
+
`<!-- cogmem-original-input-family: ${family} -->`,
|
|
73
|
+
`<!-- cogmem-normalized-from: ${family} -->`,
|
|
74
|
+
`<!-- cogmem-normalized-title: ${escapeMarkerValue(title)} -->`,
|
|
75
|
+
`<!-- cogmem-onboarding-path: ${DEFAULT_ONBOARDING_PATH} -->`,
|
|
76
|
+
...uniqueMarkers.map((marker) => `<!-- ${marker.key}: ${escapeMarkerValue(marker.value)} -->`),
|
|
77
|
+
'',
|
|
78
|
+
...messages.flatMap((message) => [
|
|
79
|
+
message.source ? `<!-- cogmem-source-ref: ${escapeMarkerValue(JSON.stringify(message.source))} -->` : undefined,
|
|
80
|
+
`- [${message.timestamp}] ${message.role}: ${message.text}`,
|
|
81
|
+
].filter((line) => Boolean(line)))
|
|
82
|
+
].join('\n');
|
|
83
|
+
mkdirSync(dirname(outputPath), { recursive: true });
|
|
84
|
+
writeFileSync(outputPath, content);
|
|
85
|
+
}
|
|
86
|
+
export function normalizeJsonlRecords(inputPath) {
|
|
87
|
+
const input = readFileSync(inputPath, 'utf8').replace(/\r\n/g, '\n');
|
|
88
|
+
let sourceOffset = 0;
|
|
89
|
+
return input.split('\n').flatMap((line, lineIndex) => {
|
|
90
|
+
if (!line.trim())
|
|
91
|
+
return [];
|
|
92
|
+
const parsed = asLooseRecord(JSON.parse(line));
|
|
93
|
+
const messages = Array.isArray(parsed.messages)
|
|
94
|
+
? parsed.messages.map((item) => asLooseRecord(item))
|
|
95
|
+
: [];
|
|
96
|
+
if (messages.length > 0) {
|
|
97
|
+
return messages.flatMap((message, messageIndex) => {
|
|
98
|
+
sourceOffset += 1;
|
|
99
|
+
return normalizeLooseRecordWithParent(message, parsed, sourceOffset - 1, {
|
|
100
|
+
sourceOffset,
|
|
101
|
+
lineStart: lineIndex + 1,
|
|
102
|
+
lineEnd: lineIndex + 1,
|
|
103
|
+
orderingConfidence: 'high',
|
|
104
|
+
}, messageIndex);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
sourceOffset += 1;
|
|
108
|
+
return normalizeLooseRecord(parsed, sourceOffset - 1, {
|
|
109
|
+
sourceOffset,
|
|
110
|
+
lineStart: lineIndex + 1,
|
|
111
|
+
lineEnd: lineIndex + 1,
|
|
112
|
+
orderingConfidence: 'high',
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export function normalizeJsonArrayRecords(inputPath) {
|
|
117
|
+
const parsed = JSON.parse(readFileSync(inputPath, 'utf8'));
|
|
118
|
+
if (!Array.isArray(parsed)) {
|
|
119
|
+
throw new Error('Expected a top-level JSON array.');
|
|
120
|
+
}
|
|
121
|
+
return parsed.flatMap((item, index) => normalizeLooseRecord(asLooseRecord(item), index, {
|
|
122
|
+
sourceOffset: index + 1,
|
|
123
|
+
orderingConfidence: 'high',
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
export function normalizeDelimitedRecords(inputPath, format) {
|
|
127
|
+
const input = readFileSync(inputPath, 'utf8').replace(/\r\n/g, '\n');
|
|
128
|
+
const delimiter = resolveDelimiter(inputPath, input, format);
|
|
129
|
+
const family = delimiter === '\t' ? 'tsv_transcript_export' : 'csv_transcript_export';
|
|
130
|
+
const rows = parseDelimited(input, delimiter);
|
|
131
|
+
if (rows.length === 0) {
|
|
132
|
+
throw new Error('Expected a header row plus at least one transcript row.');
|
|
133
|
+
}
|
|
134
|
+
const headers = rows[0].cells.map((cell) => normalizeHeader(cell));
|
|
135
|
+
const messages = rows.slice(1).flatMap((row, index) => {
|
|
136
|
+
const record = {};
|
|
137
|
+
headers.forEach((header, columnIndex) => {
|
|
138
|
+
if (!header)
|
|
139
|
+
return;
|
|
140
|
+
record[header] = row.cells[columnIndex] ?? '';
|
|
141
|
+
});
|
|
142
|
+
return normalizeLooseRecord(record, index, {
|
|
143
|
+
sourceOffset: index + 1,
|
|
144
|
+
lineStart: row.lineStart,
|
|
145
|
+
lineEnd: row.lineEnd,
|
|
146
|
+
orderingConfidence: 'high',
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
return { family, messages };
|
|
150
|
+
}
|
|
151
|
+
export function detectNormalizationFamily(markdown) {
|
|
152
|
+
return parseNormalizationMetadata(markdown).originalInputFamily;
|
|
153
|
+
}
|
|
154
|
+
export function parseNormalizationMetadata(markdown) {
|
|
155
|
+
const legacyFamily = readAnyMarker(markdown, 'cogmem-normalized-from', 'agent-brain-normalized-from');
|
|
156
|
+
const originalInputFamily = readAnyMarker(markdown, 'cogmem-original-input-family', 'agent-brain-original-input-family') || legacyFamily;
|
|
157
|
+
const normalizedSourceFamily = readAnyMarker(markdown, 'cogmem-normalized-source-family', 'agent-brain-normalized-source-family');
|
|
158
|
+
const contractVersion = readAnyMarker(markdown, 'cogmem-normalization-contract', 'agent-brain-normalization-contract');
|
|
159
|
+
const normalizedValue = readAnyMarker(markdown, 'cogmem-normalized', 'agent-brain-normalized');
|
|
160
|
+
const title = readAnyMarker(markdown, 'cogmem-normalized-title', 'agent-brain-normalized-title');
|
|
161
|
+
const onboardingPath = readAnyMarker(markdown, 'cogmem-onboarding-path', 'agent-brain-onboarding-path');
|
|
162
|
+
const family = originalInputFamily;
|
|
163
|
+
if (family !== 'jsonl_transcript_export'
|
|
164
|
+
&& family !== 'json_array_transcript_export'
|
|
165
|
+
&& family !== 'csv_transcript_export'
|
|
166
|
+
&& family !== 'tsv_transcript_export'
|
|
167
|
+
&& family !== 'app_private_mixed_event_export'
|
|
168
|
+
&& family !== 'jsonl_mixed_event_log_export') {
|
|
169
|
+
return {
|
|
170
|
+
isNormalized: normalizedValue === 'true' || Boolean(legacyFamily)
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
isNormalized: normalizedValue === 'true' || Boolean(legacyFamily),
|
|
175
|
+
contractVersion: contractVersion === NORMALIZATION_CONTRACT_VERSION ? NORMALIZATION_CONTRACT_VERSION : undefined,
|
|
176
|
+
normalizedSourceFamily: normalizedSourceFamily === NORMALIZED_SOURCE_FAMILY ? NORMALIZED_SOURCE_FAMILY : undefined,
|
|
177
|
+
originalInputFamily: family,
|
|
178
|
+
title,
|
|
179
|
+
onboardingPath
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
export function createConversationMarkdownNormalizer(options) {
|
|
183
|
+
return (records) => records.flatMap((record, index) => {
|
|
184
|
+
const mapped = options.mapRecord(record, index);
|
|
185
|
+
if (!mapped)
|
|
186
|
+
return [];
|
|
187
|
+
const entries = Array.isArray(mapped) ? mapped : [mapped];
|
|
188
|
+
return entries.filter((entry) => entry.text.trim());
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
export function normalizeAppPrivateMixedEventRecords(inputPath) {
|
|
192
|
+
return normalizeAppPrivateMixedEventExport(inputPath).messages;
|
|
193
|
+
}
|
|
194
|
+
export function normalizeAppPrivateMixedEventExport(inputPath) {
|
|
195
|
+
const parsed = JSON.parse(readFileSync(inputPath, 'utf8'));
|
|
196
|
+
return normalizeEventExportToConversationMarkdown(parsed, createExportBridge({
|
|
197
|
+
inputFamily: 'app_private_mixed_event_export',
|
|
198
|
+
selectRecords: (root) => {
|
|
199
|
+
const events = root.events;
|
|
200
|
+
return Array.isArray(events) ? events.map((item) => asLooseRecord(item)) : [];
|
|
201
|
+
},
|
|
202
|
+
isMessageCandidate: (event) => {
|
|
203
|
+
const eventKind = coerceText(event.kind) || coerceText(event.type) || coerceText(event.eventType);
|
|
204
|
+
return eventKind.toLowerCase() === 'message';
|
|
205
|
+
},
|
|
206
|
+
mapRole: (event) => {
|
|
207
|
+
const actor = asLooseRecord(event.actor);
|
|
208
|
+
return coerceText(actor.role) || coerceText(actor.type) || coerceText(event.role);
|
|
209
|
+
},
|
|
210
|
+
extractText: (event) => {
|
|
211
|
+
const body = asLooseRecord(event.body);
|
|
212
|
+
return (coerceText(body.text)
|
|
213
|
+
|| coerceText(body.content)
|
|
214
|
+
|| coerceText(body.message)
|
|
215
|
+
|| coerceText(event.text)
|
|
216
|
+
|| coerceText(event.message)).trim();
|
|
217
|
+
},
|
|
218
|
+
resolveTimestamp: (event, context) => pickTimestamp({
|
|
219
|
+
timestamp: coerceText(event.occurred_at) || coerceText(event.timestamp),
|
|
220
|
+
created_at: coerceText(event.created_at),
|
|
221
|
+
createdAt: coerceText(event.createdAt),
|
|
222
|
+
time: coerceText(event.time)
|
|
223
|
+
}, Date.now() + context.index * 1000),
|
|
224
|
+
emitMarkers: (event) => {
|
|
225
|
+
const actor = asLooseRecord(event.actor);
|
|
226
|
+
const kind = coerceText(event.kind) || coerceText(event.type) || coerceText(event.eventType);
|
|
227
|
+
return [
|
|
228
|
+
{ key: 'cogmem-bridge-input-family', value: 'app_private_mixed_event_export' },
|
|
229
|
+
{ key: 'cogmem-bridge-event-selector', value: 'kind/type/eventType == message' },
|
|
230
|
+
{ key: 'cogmem-bridge-role-source', value: coerceText(actor.role) ? 'actor.role' : coerceText(actor.type) ? 'actor.type' : 'event.role' },
|
|
231
|
+
{ key: 'cogmem-bridge-text-source', value: pickFirstMarkerValue([
|
|
232
|
+
[coerceText(asLooseRecord(event.body).text), 'body.text'],
|
|
233
|
+
[coerceText(asLooseRecord(event.body).content), 'body.content'],
|
|
234
|
+
[coerceText(asLooseRecord(event.body).message), 'body.message'],
|
|
235
|
+
[coerceText(event.text), 'event.text'],
|
|
236
|
+
[coerceText(event.message), 'event.message']
|
|
237
|
+
]) || 'unknown' },
|
|
238
|
+
{ key: 'cogmem-bridge-timestamp-source', value: pickFirstMarkerValue([
|
|
239
|
+
[coerceText(event.occurred_at), 'occurred_at'],
|
|
240
|
+
[coerceText(event.timestamp), 'timestamp'],
|
|
241
|
+
[coerceText(event.created_at), 'created_at'],
|
|
242
|
+
[coerceText(event.createdAt), 'createdAt'],
|
|
243
|
+
[coerceText(event.time), 'time']
|
|
244
|
+
]) || 'normalization_fallback' }
|
|
245
|
+
];
|
|
246
|
+
}
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
export function normalizeJsonlMixedEventLogRecords(inputPath) {
|
|
250
|
+
return normalizeJsonlMixedEventLogExport(inputPath).messages;
|
|
251
|
+
}
|
|
252
|
+
export function normalizeJsonlMixedEventLogExport(inputPath) {
|
|
253
|
+
const input = readFileSync(inputPath, 'utf8').replace(/\r\n/g, '\n');
|
|
254
|
+
const events = input
|
|
255
|
+
.split('\n')
|
|
256
|
+
.filter((line) => line.trim())
|
|
257
|
+
.map((line) => asLooseRecord(JSON.parse(line)));
|
|
258
|
+
return normalizeEventExportToConversationMarkdown(events, createExportBridge({
|
|
259
|
+
inputFamily: 'jsonl_mixed_event_log_export',
|
|
260
|
+
selectRecords: (root) => root,
|
|
261
|
+
isMessageCandidate: (event) => {
|
|
262
|
+
const eventType = (coerceText(event.type) || coerceText(event.kind)).toLowerCase();
|
|
263
|
+
return (eventType === 'message'
|
|
264
|
+
|| eventType === 'message.created'
|
|
265
|
+
|| eventType === 'message.appended');
|
|
266
|
+
},
|
|
267
|
+
mapRole: (event) => {
|
|
268
|
+
const payload = asLooseRecord(event.payload);
|
|
269
|
+
const actor = asLooseRecord(event.actor);
|
|
270
|
+
return coerceText(payload.role) || coerceText(actor.role) || coerceText(actor.type) || coerceText(event.role);
|
|
271
|
+
},
|
|
272
|
+
extractText: (event) => {
|
|
273
|
+
const payload = asLooseRecord(event.payload);
|
|
274
|
+
return (coerceText(payload.text)
|
|
275
|
+
|| coerceText(payload.content)
|
|
276
|
+
|| coerceText(payload.message)
|
|
277
|
+
|| coerceText(event.message)
|
|
278
|
+
|| coerceText(event.text)).trim();
|
|
279
|
+
},
|
|
280
|
+
resolveTimestamp: (event, context) => {
|
|
281
|
+
const payload = asLooseRecord(event.payload);
|
|
282
|
+
return pickTimestamp({
|
|
283
|
+
timestamp: coerceText(payload.timestamp) || coerceText(event.timestamp),
|
|
284
|
+
created_at: coerceText(event.created_at) || coerceText(payload.created_at),
|
|
285
|
+
createdAt: coerceText(event.createdAt) || coerceText(payload.createdAt),
|
|
286
|
+
time: coerceText(event.time)
|
|
287
|
+
}, Date.now() + context.index * 1000);
|
|
288
|
+
},
|
|
289
|
+
emitMarkers: (event) => {
|
|
290
|
+
const payload = asLooseRecord(event.payload);
|
|
291
|
+
return [
|
|
292
|
+
{ key: 'cogmem-bridge-input-family', value: 'jsonl_mixed_event_log_export' },
|
|
293
|
+
{ key: 'cogmem-bridge-event-selector', value: 'type/kind in message-like events with text payload' },
|
|
294
|
+
{ key: 'cogmem-bridge-role-source', value: pickFirstMarkerValue([
|
|
295
|
+
[coerceText(payload.role), 'payload.role'],
|
|
296
|
+
[coerceText(asLooseRecord(event.actor).role), 'actor.role'],
|
|
297
|
+
[coerceText(asLooseRecord(event.actor).type), 'actor.type'],
|
|
298
|
+
[coerceText(event.role), 'event.role']
|
|
299
|
+
]) || 'user_fallback' },
|
|
300
|
+
{ key: 'cogmem-bridge-text-source', value: pickFirstMarkerValue([
|
|
301
|
+
[coerceText(payload.text), 'payload.text'],
|
|
302
|
+
[coerceText(payload.content), 'payload.content'],
|
|
303
|
+
[coerceText(payload.message), 'payload.message'],
|
|
304
|
+
[coerceText(event.message), 'event.message'],
|
|
305
|
+
[coerceText(event.text), 'event.text']
|
|
306
|
+
]) || 'unknown' },
|
|
307
|
+
{ key: 'cogmem-bridge-timestamp-source', value: pickFirstMarkerValue([
|
|
308
|
+
[coerceText(payload.timestamp), 'payload.timestamp'],
|
|
309
|
+
[coerceText(event.timestamp), 'event.timestamp'],
|
|
310
|
+
[coerceText(event.created_at), 'event.created_at'],
|
|
311
|
+
[coerceText(payload.created_at), 'payload.created_at'],
|
|
312
|
+
[coerceText(event.createdAt), 'event.createdAt'],
|
|
313
|
+
[coerceText(payload.createdAt), 'payload.createdAt'],
|
|
314
|
+
[coerceText(event.time), 'event.time']
|
|
315
|
+
]) || 'normalization_fallback' }
|
|
316
|
+
];
|
|
317
|
+
}
|
|
318
|
+
}));
|
|
319
|
+
}
|
|
320
|
+
export function createExportBridge(recipe) {
|
|
321
|
+
const createContext = (record, index, root, records) => ({
|
|
322
|
+
index,
|
|
323
|
+
record,
|
|
324
|
+
root,
|
|
325
|
+
inputFamily: recipe.inputFamily
|
|
326
|
+
});
|
|
327
|
+
const normalizeRecords = (records, root) => records.flatMap((record, index) => {
|
|
328
|
+
const resolvedRoot = (root ?? records);
|
|
329
|
+
const context = createContext(record, index, resolvedRoot, records);
|
|
330
|
+
if (recipe.isMessageCandidate && !recipe.isMessageCandidate(record, context)) {
|
|
331
|
+
return [];
|
|
332
|
+
}
|
|
333
|
+
const text = (recipe.extractText(record, context) || '').trim();
|
|
334
|
+
if (!text)
|
|
335
|
+
return [];
|
|
336
|
+
return [{
|
|
337
|
+
role: normalizeRole(recipe.mapRole(record, context)),
|
|
338
|
+
text,
|
|
339
|
+
timestamp: recipe.resolveTimestamp(record, context),
|
|
340
|
+
source: {
|
|
341
|
+
sourceOffset: context.index + 1,
|
|
342
|
+
orderingConfidence: 'high',
|
|
343
|
+
},
|
|
344
|
+
}];
|
|
345
|
+
});
|
|
346
|
+
const normalizeRoot = (input) => {
|
|
347
|
+
const records = recipe.selectRecords ? recipe.selectRecords(input) : input;
|
|
348
|
+
return normalizeRecords(records, input);
|
|
349
|
+
};
|
|
350
|
+
const collectMarkers = (records, root) => {
|
|
351
|
+
if (!recipe.emitMarkers)
|
|
352
|
+
return [];
|
|
353
|
+
const resolvedRoot = (root ?? records);
|
|
354
|
+
return dedupeMarkers(records.flatMap((record, index) => {
|
|
355
|
+
const context = createContext(record, index, resolvedRoot, records);
|
|
356
|
+
if (recipe.isMessageCandidate && !recipe.isMessageCandidate(record, context)) {
|
|
357
|
+
return [];
|
|
358
|
+
}
|
|
359
|
+
return recipe.emitMarkers?.(record, context) || [];
|
|
360
|
+
}));
|
|
361
|
+
};
|
|
362
|
+
const collectRootMarkers = (input) => {
|
|
363
|
+
const records = recipe.selectRecords ? recipe.selectRecords(input) : input;
|
|
364
|
+
return collectMarkers(records, input);
|
|
365
|
+
};
|
|
366
|
+
return {
|
|
367
|
+
inputFamily: recipe.inputFamily,
|
|
368
|
+
normalizeRoot,
|
|
369
|
+
normalizeRecords,
|
|
370
|
+
collectMarkers,
|
|
371
|
+
collectRootMarkers
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
export function normalizeEventExportToConversationMarkdown(input, bridge) {
|
|
375
|
+
const messages = bridge.normalizeRoot(input);
|
|
376
|
+
assertBridgeMessages(messages, bridge.inputFamily);
|
|
377
|
+
return {
|
|
378
|
+
family: bridge.inputFamily,
|
|
379
|
+
messages,
|
|
380
|
+
markers: bridge.collectRootMarkers(input)
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function assertBridgeMessages(messages, family) {
|
|
384
|
+
if (messages.length > 0)
|
|
385
|
+
return;
|
|
386
|
+
throw new Error(`Bridge normalization failed for ${family}: no message records were produced. Check selectRecords, isMessageCandidate, extractText, resolveTimestamp, and confirm the export exposes stable text/timestamp fields.`);
|
|
387
|
+
}
|
|
388
|
+
function assertNormalizedMessages(messages, family) {
|
|
389
|
+
if (messages.length === 0) {
|
|
390
|
+
throw new Error(`Normalization failed for ${family}: no conversation messages were produced.`);
|
|
391
|
+
}
|
|
392
|
+
for (const [index, message] of messages.entries()) {
|
|
393
|
+
if (!message.text.trim()) {
|
|
394
|
+
throw new Error(`Normalization failed for ${family}: message ${index} is missing text.`);
|
|
395
|
+
}
|
|
396
|
+
const timestamp = new Date(message.timestamp);
|
|
397
|
+
if (Number.isNaN(timestamp.getTime())) {
|
|
398
|
+
throw new Error(`Normalization failed for ${family}: message ${index} has an invalid timestamp.`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function readAnyMarker(markdown, ...markers) {
|
|
403
|
+
for (const marker of markers) {
|
|
404
|
+
const value = readMarker(markdown, marker);
|
|
405
|
+
if (value)
|
|
406
|
+
return value;
|
|
407
|
+
}
|
|
408
|
+
return undefined;
|
|
409
|
+
}
|
|
410
|
+
function readMarker(markdown, marker) {
|
|
411
|
+
const pattern = new RegExp(`<!--\\s*${marker}:\\s*([^]+?)\\s*-->`, 'i');
|
|
412
|
+
const match = markdown.match(pattern);
|
|
413
|
+
return match?.[1]?.trim();
|
|
414
|
+
}
|
|
415
|
+
function escapeMarkerValue(value) {
|
|
416
|
+
return value.replace(/-->/g, '-->').trim();
|
|
417
|
+
}
|
|
418
|
+
function dedupeMarkers(markers) {
|
|
419
|
+
const seen = new Set();
|
|
420
|
+
const output = [];
|
|
421
|
+
for (const marker of markers) {
|
|
422
|
+
const key = marker.key.trim();
|
|
423
|
+
const value = marker.value.trim();
|
|
424
|
+
if (!key || !value)
|
|
425
|
+
continue;
|
|
426
|
+
const identity = `${key}::${value}`;
|
|
427
|
+
if (seen.has(identity))
|
|
428
|
+
continue;
|
|
429
|
+
seen.add(identity);
|
|
430
|
+
output.push({ key, value });
|
|
431
|
+
}
|
|
432
|
+
return output;
|
|
433
|
+
}
|
|
434
|
+
function normalizeLooseRecord(item, index, source) {
|
|
435
|
+
const text = pickMessageText(item);
|
|
436
|
+
if (!text)
|
|
437
|
+
return [];
|
|
438
|
+
return [{
|
|
439
|
+
role: normalizeRole(coerceText(item.role)),
|
|
440
|
+
text,
|
|
441
|
+
timestamp: pickTimestamp(item, Date.now() + index * 1000),
|
|
442
|
+
source: source ?? {
|
|
443
|
+
sourceOffset: index + 1,
|
|
444
|
+
orderingConfidence: 'high',
|
|
445
|
+
},
|
|
446
|
+
}];
|
|
447
|
+
}
|
|
448
|
+
function normalizeLooseRecordWithParent(item, parent, index, source, messageIndex) {
|
|
449
|
+
const text = pickMessageText(item);
|
|
450
|
+
if (!text)
|
|
451
|
+
return [];
|
|
452
|
+
const parentTimestamp = pickTimestamp(parent, Date.now() + index * 1000 + messageIndex);
|
|
453
|
+
const parentFallback = Date.parse(parentTimestamp);
|
|
454
|
+
const timestamp = pickTimestamp(item, Number.isNaN(parentFallback) ? Date.now() + index * 1000 : parentFallback);
|
|
455
|
+
return [{
|
|
456
|
+
role: normalizeRole(coerceText(item.role) || coerceText(item.sender) || coerceText(item.author)),
|
|
457
|
+
text,
|
|
458
|
+
timestamp,
|
|
459
|
+
source,
|
|
460
|
+
}];
|
|
461
|
+
}
|
|
462
|
+
function coerceText(value) {
|
|
463
|
+
if (typeof value === 'string')
|
|
464
|
+
return value;
|
|
465
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
466
|
+
return String(value);
|
|
467
|
+
if (Array.isArray(value)) {
|
|
468
|
+
return value
|
|
469
|
+
.map((entry) => {
|
|
470
|
+
if (typeof entry === 'string')
|
|
471
|
+
return entry;
|
|
472
|
+
if (entry && typeof entry === 'object' && typeof entry.text === 'string') {
|
|
473
|
+
return entry.text;
|
|
474
|
+
}
|
|
475
|
+
return '';
|
|
476
|
+
})
|
|
477
|
+
.filter(Boolean)
|
|
478
|
+
.join('\n');
|
|
479
|
+
}
|
|
480
|
+
if (value && typeof value === 'object' && typeof value.text === 'string') {
|
|
481
|
+
return value.text;
|
|
482
|
+
}
|
|
483
|
+
return '';
|
|
484
|
+
}
|
|
485
|
+
function parseTimestampDate(raw, fallback) {
|
|
486
|
+
const trimmed = raw.trim();
|
|
487
|
+
if (/^\d+(?:\.\d+)?$/.test(trimmed)) {
|
|
488
|
+
const numeric = Number(trimmed);
|
|
489
|
+
if (Number.isFinite(numeric)) {
|
|
490
|
+
return new Date(numeric < 10_000_000_000 ? numeric * 1000 : numeric);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
const parsed = new Date(trimmed);
|
|
494
|
+
return Number.isNaN(parsed.getTime()) ? new Date(fallback) : parsed;
|
|
495
|
+
}
|
|
496
|
+
function pickFirstMarkerValue(candidates) {
|
|
497
|
+
for (const [value, label] of candidates) {
|
|
498
|
+
if (value.trim())
|
|
499
|
+
return label;
|
|
500
|
+
}
|
|
501
|
+
return undefined;
|
|
502
|
+
}
|
|
503
|
+
function asLooseRecord(value) {
|
|
504
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
505
|
+
return {};
|
|
506
|
+
}
|
|
507
|
+
return value;
|
|
508
|
+
}
|
|
509
|
+
function resolveDelimiter(inputPath, input, format) {
|
|
510
|
+
if (format === 'csv')
|
|
511
|
+
return ',';
|
|
512
|
+
if (format === 'tsv')
|
|
513
|
+
return '\t';
|
|
514
|
+
if (inputPath.toLowerCase().endsWith('.tsv'))
|
|
515
|
+
return '\t';
|
|
516
|
+
const firstLine = input.split('\n').find((line) => line.trim()) || '';
|
|
517
|
+
return firstLine.includes('\t') ? '\t' : ',';
|
|
518
|
+
}
|
|
519
|
+
function normalizeHeader(value) {
|
|
520
|
+
return value.trim().toLowerCase().replace(/\s+/g, '_');
|
|
521
|
+
}
|
|
522
|
+
function parseDelimited(input, delimiter) {
|
|
523
|
+
const rows = [];
|
|
524
|
+
let row = [];
|
|
525
|
+
let cell = '';
|
|
526
|
+
let inQuotes = false;
|
|
527
|
+
let lineNumber = 1;
|
|
528
|
+
let rowStartLine = 1;
|
|
529
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
530
|
+
const char = input[index];
|
|
531
|
+
const next = input[index + 1];
|
|
532
|
+
if (char === '"') {
|
|
533
|
+
if (inQuotes && next === '"') {
|
|
534
|
+
cell += '"';
|
|
535
|
+
index += 1;
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
inQuotes = !inQuotes;
|
|
539
|
+
}
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
if (!inQuotes && char === delimiter) {
|
|
543
|
+
row.push(cell);
|
|
544
|
+
cell = '';
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
if (!inQuotes && char === '\n') {
|
|
548
|
+
row.push(cell);
|
|
549
|
+
if (row.some((value) => value.trim())) {
|
|
550
|
+
rows.push({ cells: row, lineStart: rowStartLine, lineEnd: lineNumber });
|
|
551
|
+
}
|
|
552
|
+
row = [];
|
|
553
|
+
cell = '';
|
|
554
|
+
lineNumber += 1;
|
|
555
|
+
rowStartLine = lineNumber;
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
if (char === '\n')
|
|
559
|
+
lineNumber += 1;
|
|
560
|
+
cell += char;
|
|
561
|
+
}
|
|
562
|
+
row.push(cell);
|
|
563
|
+
if (row.some((value) => value.trim())) {
|
|
564
|
+
rows.push({ cells: row, lineStart: rowStartLine, lineEnd: lineNumber });
|
|
565
|
+
}
|
|
566
|
+
return rows;
|
|
567
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
2
|
+
export interface LoggerOptions {
|
|
3
|
+
level: LogLevel;
|
|
4
|
+
prefix?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class Logger {
|
|
7
|
+
private level;
|
|
8
|
+
private prefix;
|
|
9
|
+
constructor(options: LoggerOptions);
|
|
10
|
+
private shouldLog;
|
|
11
|
+
private formatMessage;
|
|
12
|
+
debug(message: string, ...args: any[]): void;
|
|
13
|
+
info(message: string, ...args: any[]): void;
|
|
14
|
+
warn(message: string, ...args: any[]): void;
|
|
15
|
+
error(message: string, ...args: any[]): void;
|
|
16
|
+
setLevel(level: LogLevel): void;
|
|
17
|
+
getLevel(): LogLevel;
|
|
18
|
+
}
|
|
19
|
+
export declare function getLogger(prefix?: string, level?: LogLevel): Logger;
|
|
20
|
+
export declare function setGlobalLogLevel(level: LogLevel): void;
|
|
21
|
+
export declare const logger: Logger;
|
|
22
|
+
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// ============================================
|
|
2
|
+
// 日志系统 - 统一的日志管理
|
|
3
|
+
// ============================================
|
|
4
|
+
const LEVEL_PRIORITY = {
|
|
5
|
+
debug: 0,
|
|
6
|
+
info: 1,
|
|
7
|
+
warn: 2,
|
|
8
|
+
error: 3
|
|
9
|
+
};
|
|
10
|
+
export class Logger {
|
|
11
|
+
level;
|
|
12
|
+
prefix;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.level = options.level;
|
|
15
|
+
this.prefix = options.prefix || '';
|
|
16
|
+
}
|
|
17
|
+
shouldLog(level) {
|
|
18
|
+
return LEVEL_PRIORITY[level] >= LEVEL_PRIORITY[this.level];
|
|
19
|
+
}
|
|
20
|
+
formatMessage(level, message, ...args) {
|
|
21
|
+
const timestamp = new Date().toISOString();
|
|
22
|
+
const prefix = this.prefix ? `[${this.prefix}] ` : '';
|
|
23
|
+
const levelStr = `[${level.toUpperCase()}]`;
|
|
24
|
+
const formattedMessage = args.length > 0
|
|
25
|
+
? `${message} ${args.map(a => JSON.stringify(a)).join(' ')}`
|
|
26
|
+
: message;
|
|
27
|
+
return `${timestamp} ${levelStr} ${prefix}${formattedMessage}`;
|
|
28
|
+
}
|
|
29
|
+
debug(message, ...args) {
|
|
30
|
+
if (this.shouldLog('debug')) {
|
|
31
|
+
console.debug(this.formatMessage('debug', message, ...args));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
info(message, ...args) {
|
|
35
|
+
if (this.shouldLog('info')) {
|
|
36
|
+
console.info(this.formatMessage('info', message, ...args));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
warn(message, ...args) {
|
|
40
|
+
if (this.shouldLog('warn')) {
|
|
41
|
+
console.warn(this.formatMessage('warn', message, ...args));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
error(message, ...args) {
|
|
45
|
+
if (this.shouldLog('error')) {
|
|
46
|
+
console.error(this.formatMessage('error', message, ...args));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
setLevel(level) {
|
|
50
|
+
this.level = level;
|
|
51
|
+
}
|
|
52
|
+
getLevel() {
|
|
53
|
+
return this.level;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// 全局日志器实例
|
|
57
|
+
let globalLogger = null;
|
|
58
|
+
export function getLogger(prefix, level) {
|
|
59
|
+
if (!globalLogger) {
|
|
60
|
+
globalLogger = new Logger({
|
|
61
|
+
level: level || 'info',
|
|
62
|
+
prefix: 'AgentBrain'
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (prefix) {
|
|
66
|
+
return new Logger({ level: globalLogger.getLevel(), prefix });
|
|
67
|
+
}
|
|
68
|
+
return globalLogger;
|
|
69
|
+
}
|
|
70
|
+
export function setGlobalLogLevel(level) {
|
|
71
|
+
if (!globalLogger) {
|
|
72
|
+
getLogger();
|
|
73
|
+
}
|
|
74
|
+
globalLogger?.setLevel(level);
|
|
75
|
+
}
|
|
76
|
+
// 便捷函数
|
|
77
|
+
export const logger = getLogger();
|