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,820 @@
|
|
|
1
|
+
import { extractApprovedArchiveProject, extractDeviceAliasCandidates, extractDeviceCandidate, extractExplicitNamedEntityCandidate, extractLatestIssueReference, extractNegativePreferenceCue, extractPreference, extractProjectAliasCandidates, extractProjectCandidate, extractRelativeReferences, hasIssueSignal, INTERACTION_EVENT_PREFIX, inferReferenceType, inferIssueValue, isLatestReference, isPreviousReference, isOwnershipSignal, isPurchaseSignal, normalizeLexiconText } from '../lexicon/coreMemoryLexicon.js';
|
|
2
|
+
export class FactCompiler {
|
|
3
|
+
factStore;
|
|
4
|
+
entityStore;
|
|
5
|
+
constructor(factStore, entityStore) {
|
|
6
|
+
this.factStore = factStore;
|
|
7
|
+
this.entityStore = entityStore;
|
|
8
|
+
}
|
|
9
|
+
compile(input) {
|
|
10
|
+
const sourceText = input.unit?.semanticText || input.neuron.content;
|
|
11
|
+
const workingText = normalizeLexiconText(sourceText);
|
|
12
|
+
const createdAt = input.neuron.metadata.createdAt;
|
|
13
|
+
const projectId = input.neuron.metadata.projectId;
|
|
14
|
+
const unitId = input.unit?.unitId;
|
|
15
|
+
const entityIds = [];
|
|
16
|
+
const factInputs = [];
|
|
17
|
+
const eventInputs = [];
|
|
18
|
+
const tags = input.neuron.metadata.tags || [];
|
|
19
|
+
const isImportedSummary = tags.includes('reliability:imported_summary')
|
|
20
|
+
|| tags.includes('provenance:imported_summary')
|
|
21
|
+
|| tags.includes('source_class:memory_index')
|
|
22
|
+
|| tags.includes('memory_layer:summary_seed');
|
|
23
|
+
const isSummarySupport = isImportedSummary
|
|
24
|
+
|| (tags.includes('source_class:daily_memory') && tags.includes('reliability:self_summary'));
|
|
25
|
+
const isInteractionEventSemantic = [
|
|
26
|
+
INTERACTION_EVENT_PREFIX.approved,
|
|
27
|
+
INTERACTION_EVENT_PREFIX.rejected,
|
|
28
|
+
INTERACTION_EVENT_PREFIX.entitySelection
|
|
29
|
+
].some((prefix) => sourceText.startsWith(`${prefix}:`));
|
|
30
|
+
const deviceMatch = extractDeviceCandidate(workingText);
|
|
31
|
+
const semanticDevice = input.semanticCompilation?.entities.find((entity) => entity.type === 'device')?.text;
|
|
32
|
+
const purchaseSignal = isPurchaseSignal(workingText)
|
|
33
|
+
|| /(?:我)?买了\s+[A-Za-z]/i.test(workingText);
|
|
34
|
+
const ownershipSignal = isOwnershipSignal(workingText)
|
|
35
|
+
|| (input.semanticCompilation?.ownershipSignals.length || 0) > 0;
|
|
36
|
+
const explicitNamedDevice = (!deviceMatch && !semanticDevice && (ownershipSignal || purchaseSignal))
|
|
37
|
+
? extractExplicitNamedEntityCandidate(workingText)
|
|
38
|
+
: null;
|
|
39
|
+
let primaryDeviceEntityId;
|
|
40
|
+
if (!isInteractionEventSemantic && (ownershipSignal || purchaseSignal)) {
|
|
41
|
+
const name = this.normalizeName(deviceMatch || semanticDevice || explicitNamedDevice || 'device');
|
|
42
|
+
const entity = this.entityStore.upsertEntity({
|
|
43
|
+
canonicalName: name,
|
|
44
|
+
type: 'device',
|
|
45
|
+
aliases: Array.from(new Set([
|
|
46
|
+
deviceMatch,
|
|
47
|
+
semanticDevice,
|
|
48
|
+
explicitNamedDevice,
|
|
49
|
+
...extractDeviceAliasCandidates(workingText),
|
|
50
|
+
name
|
|
51
|
+
].filter((value) => Boolean(value)))),
|
|
52
|
+
createdFrom: input.neuron.id,
|
|
53
|
+
metadata: {
|
|
54
|
+
projectId,
|
|
55
|
+
rawMention: sourceText,
|
|
56
|
+
answerDisplayName: name,
|
|
57
|
+
ens1Layer: 'canonical_entity_record'
|
|
58
|
+
},
|
|
59
|
+
createdAt,
|
|
60
|
+
instanceMode: purchaseSignal ? 'new_instance' : 'auto'
|
|
61
|
+
});
|
|
62
|
+
entityIds.push(entity.entityId);
|
|
63
|
+
primaryDeviceEntityId = entity.entityId;
|
|
64
|
+
this.entityStore.recordMention({
|
|
65
|
+
entityId: entity.entityId,
|
|
66
|
+
neuronId: input.neuron.id,
|
|
67
|
+
projectId,
|
|
68
|
+
mentionType: 'declared',
|
|
69
|
+
createdAt
|
|
70
|
+
});
|
|
71
|
+
if (ownershipSignal || purchaseSignal || (input.semanticCompilation?.ownershipSignals.length || 0) > 0) {
|
|
72
|
+
factInputs.push({
|
|
73
|
+
neuronId: input.neuron.id,
|
|
74
|
+
unitId,
|
|
75
|
+
subject: 'user',
|
|
76
|
+
predicateFamily: 'owns',
|
|
77
|
+
predicateValue: 'has',
|
|
78
|
+
object: entity.canonicalName,
|
|
79
|
+
entityId: entity.entityId,
|
|
80
|
+
validFrom: createdAt,
|
|
81
|
+
certaintyLevel: 'certain',
|
|
82
|
+
confidence: 0.9,
|
|
83
|
+
...(isSummarySupport ? {
|
|
84
|
+
confidence: 0.62,
|
|
85
|
+
certaintyLevel: 'probable'
|
|
86
|
+
} : {}),
|
|
87
|
+
status: 'provisional',
|
|
88
|
+
sourceText,
|
|
89
|
+
metadata: {
|
|
90
|
+
fact_origin: isSummarySupport ? 'imported_summary_support_fact' : 'original_compiler_fact',
|
|
91
|
+
...(isSummarySupport ? {
|
|
92
|
+
provenance_tier: 'support',
|
|
93
|
+
imported_summary_support: true
|
|
94
|
+
} : {})
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (purchaseSignal) {
|
|
99
|
+
factInputs.push({
|
|
100
|
+
neuronId: input.neuron.id,
|
|
101
|
+
unitId,
|
|
102
|
+
subject: 'user',
|
|
103
|
+
predicateFamily: 'purchased',
|
|
104
|
+
predicateValue: 'bought',
|
|
105
|
+
object: entity.canonicalName,
|
|
106
|
+
entityId: entity.entityId,
|
|
107
|
+
validFrom: createdAt,
|
|
108
|
+
certaintyLevel: 'certain',
|
|
109
|
+
confidence: 0.92,
|
|
110
|
+
status: 'verified',
|
|
111
|
+
sourceText,
|
|
112
|
+
metadata: {
|
|
113
|
+
fact_origin: 'original_compiler_fact'
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
const previousDeviceReference = input.semanticCompilation?.relativeReferences.find((reference) => isPreviousReference(reference)) || '前一个';
|
|
117
|
+
const previousDevice = this.entityStore.resolveReference(previousDeviceReference, 'device', { projectId });
|
|
118
|
+
if (previousDevice && previousDevice.entityId !== entity.entityId) {
|
|
119
|
+
this.entityStore.addRelation({
|
|
120
|
+
sourceEntityId: previousDevice.entityId,
|
|
121
|
+
targetEntityId: entity.entityId,
|
|
122
|
+
relationType: 'replaced_by',
|
|
123
|
+
sourceNeuronId: input.neuron.id,
|
|
124
|
+
createdAt
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (!isInteractionEventSemantic && input.semanticCompilation?.topics.some((topic) => topic.topic === 'connectivity_issue') && primaryDeviceEntityId) {
|
|
130
|
+
this.entityStore.addAttribute({
|
|
131
|
+
entityId: primaryDeviceEntityId,
|
|
132
|
+
attributeKey: 'issue_family',
|
|
133
|
+
attributeValue: 'connectivity_issue',
|
|
134
|
+
sourceNeuronId: input.neuron.id,
|
|
135
|
+
createdAt
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (!isInteractionEventSemantic && !primaryDeviceEntityId && input.semanticCompilation?.ownershipSignals.length) {
|
|
139
|
+
const semanticEntity = input.semanticCompilation.entities.find((entity) => entity.type === 'device');
|
|
140
|
+
if (semanticEntity) {
|
|
141
|
+
const entity = this.entityStore.upsertEntity({
|
|
142
|
+
canonicalName: this.normalizeName(semanticEntity.text),
|
|
143
|
+
type: 'device',
|
|
144
|
+
aliases: Array.from(new Set([semanticEntity.text, ...extractDeviceAliasCandidates(workingText)])),
|
|
145
|
+
createdFrom: input.neuron.id,
|
|
146
|
+
metadata: {
|
|
147
|
+
projectId,
|
|
148
|
+
rawMention: sourceText,
|
|
149
|
+
answerDisplayName: this.normalizeName(semanticEntity.text),
|
|
150
|
+
ens1Layer: 'canonical_entity_record'
|
|
151
|
+
},
|
|
152
|
+
createdAt
|
|
153
|
+
});
|
|
154
|
+
entityIds.push(entity.entityId);
|
|
155
|
+
primaryDeviceEntityId = entity.entityId;
|
|
156
|
+
this.entityStore.recordMention({
|
|
157
|
+
entityId: entity.entityId,
|
|
158
|
+
neuronId: input.neuron.id,
|
|
159
|
+
projectId,
|
|
160
|
+
mentionType: 'declared',
|
|
161
|
+
createdAt
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const issueMatches = !isInteractionEventSemantic
|
|
166
|
+
? this.extractIssueMatches(workingText, input.semanticCompilation?.issueHints || [])
|
|
167
|
+
: [];
|
|
168
|
+
const selfCorrectionArtifact = !isInteractionEventSemantic
|
|
169
|
+
? this.buildSelfCorrectionArtifact({
|
|
170
|
+
neuron: input.neuron,
|
|
171
|
+
unitId,
|
|
172
|
+
sourceText,
|
|
173
|
+
workingText,
|
|
174
|
+
projectId,
|
|
175
|
+
semanticCompilation: input.semanticCompilation
|
|
176
|
+
})
|
|
177
|
+
: null;
|
|
178
|
+
if (issueMatches.length > 0) {
|
|
179
|
+
const resolvedDevice = primaryDeviceEntityId
|
|
180
|
+
? this.entityStore.findByEntityId(primaryDeviceEntityId)
|
|
181
|
+
: this.resolveImplicitEntity(workingText, 'device', projectId);
|
|
182
|
+
for (const issueMatch of issueMatches) {
|
|
183
|
+
const issueMetadata = this.buildIssueMetadata(issueMatch.issue, issueMatch.issue, sourceText, {
|
|
184
|
+
issueFamily: issueMatch.issueFamily,
|
|
185
|
+
projectId,
|
|
186
|
+
...this.buildContinuityMetadata({
|
|
187
|
+
issue: issueMatch.issue,
|
|
188
|
+
sourceText,
|
|
189
|
+
projectId,
|
|
190
|
+
createdAt,
|
|
191
|
+
entity: resolvedDevice || undefined
|
|
192
|
+
}),
|
|
193
|
+
...this.buildWriteTimeBindingMetadata({
|
|
194
|
+
sourceText: workingText,
|
|
195
|
+
type: 'device',
|
|
196
|
+
entity: resolvedDevice || undefined,
|
|
197
|
+
projectId
|
|
198
|
+
})
|
|
199
|
+
});
|
|
200
|
+
factInputs.push({
|
|
201
|
+
neuronId: input.neuron.id,
|
|
202
|
+
unitId,
|
|
203
|
+
subject: 'device',
|
|
204
|
+
predicateFamily: 'has_issue',
|
|
205
|
+
predicateValue: this.normalizeIssueValue(issueMatch.issue),
|
|
206
|
+
object: resolvedDevice?.canonicalName || this.normalizeName(issueMatch.reference),
|
|
207
|
+
entityId: resolvedDevice?.entityId,
|
|
208
|
+
validFrom: createdAt,
|
|
209
|
+
certaintyLevel: 'certain',
|
|
210
|
+
confidence: 0.88,
|
|
211
|
+
...(isSummarySupport ? {
|
|
212
|
+
confidence: 0.58,
|
|
213
|
+
certaintyLevel: 'possible'
|
|
214
|
+
} : {}),
|
|
215
|
+
status: 'provisional',
|
|
216
|
+
sourceText,
|
|
217
|
+
metadata: {
|
|
218
|
+
...issueMetadata,
|
|
219
|
+
fact_origin: isSummarySupport ? 'imported_summary_support_fact' : 'original_compiler_fact',
|
|
220
|
+
...(isSummarySupport ? {
|
|
221
|
+
provenance_tier: 'support',
|
|
222
|
+
imported_summary_support: true,
|
|
223
|
+
episodic_lane: 'support_only'
|
|
224
|
+
} : {})
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
if (resolvedDevice) {
|
|
229
|
+
entityIds.push(resolvedDevice.entityId);
|
|
230
|
+
this.entityStore.recordMention({
|
|
231
|
+
entityId: resolvedDevice.entityId,
|
|
232
|
+
neuronId: input.neuron.id,
|
|
233
|
+
projectId,
|
|
234
|
+
mentionType: 'attributed',
|
|
235
|
+
createdAt
|
|
236
|
+
});
|
|
237
|
+
this.entityStore.addAttribute({
|
|
238
|
+
entityId: resolvedDevice.entityId,
|
|
239
|
+
attributeKey: 'issue',
|
|
240
|
+
attributeValue: issueMatches
|
|
241
|
+
.map((issueMatch) => `${this.normalizeName(issueMatch.reference)}:${this.normalizeIssueValue(issueMatch.issue)}`)
|
|
242
|
+
.join('|'),
|
|
243
|
+
sourceNeuronId: input.neuron.id,
|
|
244
|
+
createdAt
|
|
245
|
+
});
|
|
246
|
+
const pendingReference = this.extractPendingEntityReference(workingText, input.semanticCompilation?.relativeReferences || []);
|
|
247
|
+
if (pendingReference && /之前那个|前一个|上一个/.test(pendingReference)) {
|
|
248
|
+
this.entityStore.registerPendingResolution({
|
|
249
|
+
referenceText: pendingReference,
|
|
250
|
+
entityType: 'device',
|
|
251
|
+
contextNeuronId: input.neuron.id,
|
|
252
|
+
createdAt
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
const pendingReference = this.extractPendingEntityReference(workingText, input.semanticCompilation?.relativeReferences || []);
|
|
258
|
+
if (pendingReference) {
|
|
259
|
+
this.entityStore.registerPendingResolution({
|
|
260
|
+
referenceText: pendingReference,
|
|
261
|
+
entityType: 'device',
|
|
262
|
+
contextNeuronId: input.neuron.id,
|
|
263
|
+
createdAt
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else if (input.semanticCompilation?.issueHints.length && primaryDeviceEntityId) {
|
|
269
|
+
const resolvedDevice = this.entityStore.findByEntityId(primaryDeviceEntityId);
|
|
270
|
+
for (const issueHint of input.semanticCompilation.issueHints.slice(0, 2)) {
|
|
271
|
+
const issueMetadata = this.buildIssueMetadata(issueHint, issueHint, sourceText);
|
|
272
|
+
factInputs.push({
|
|
273
|
+
neuronId: input.neuron.id,
|
|
274
|
+
unitId,
|
|
275
|
+
subject: 'device',
|
|
276
|
+
predicateFamily: 'has_issue',
|
|
277
|
+
predicateValue: this.normalizeName(issueHint),
|
|
278
|
+
object: resolvedDevice?.canonicalName || 'device',
|
|
279
|
+
entityId: resolvedDevice?.entityId,
|
|
280
|
+
validFrom: createdAt,
|
|
281
|
+
certaintyLevel: 'probable',
|
|
282
|
+
confidence: 0.78,
|
|
283
|
+
...(isSummarySupport ? {
|
|
284
|
+
confidence: 0.52,
|
|
285
|
+
certaintyLevel: 'possible'
|
|
286
|
+
} : {}),
|
|
287
|
+
status: 'provisional',
|
|
288
|
+
sourceText,
|
|
289
|
+
metadata: {
|
|
290
|
+
...issueMetadata,
|
|
291
|
+
fact_origin: isSummarySupport ? 'imported_summary_support_fact' : 'original_compiler_fact',
|
|
292
|
+
...(isSummarySupport ? {
|
|
293
|
+
provenance_tier: 'support',
|
|
294
|
+
imported_summary_support: true,
|
|
295
|
+
episodic_lane: 'support_only'
|
|
296
|
+
} : {})
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (selfCorrectionArtifact) {
|
|
302
|
+
factInputs.push(selfCorrectionArtifact);
|
|
303
|
+
}
|
|
304
|
+
const projectCandidate = !isInteractionEventSemantic ? extractProjectCandidate(workingText) : undefined;
|
|
305
|
+
const projectMatch = projectCandidate ? [projectCandidate, projectCandidate] : null;
|
|
306
|
+
if (projectMatch) {
|
|
307
|
+
const projectName = this.normalizeName(projectMatch[1]);
|
|
308
|
+
const projectAliases = Array.from(new Set([
|
|
309
|
+
projectMatch[1],
|
|
310
|
+
...extractProjectAliasCandidates(workingText)
|
|
311
|
+
].filter(Boolean)));
|
|
312
|
+
const entity = this.entityStore.upsertEntity({
|
|
313
|
+
canonicalName: projectName,
|
|
314
|
+
type: 'project',
|
|
315
|
+
aliases: projectAliases,
|
|
316
|
+
createdFrom: input.neuron.id,
|
|
317
|
+
metadata: {
|
|
318
|
+
projectId: input.neuron.metadata.projectId,
|
|
319
|
+
projectLocalInternalSlug: input.neuron.metadata.projectId,
|
|
320
|
+
rawMention: sourceText,
|
|
321
|
+
answerDisplayName: projectName,
|
|
322
|
+
ens1ProjectLocalNaming: {
|
|
323
|
+
internalSlug: input.neuron.metadata.projectId,
|
|
324
|
+
canonicalProjectName: projectName,
|
|
325
|
+
answerSurfaceProjectName: projectName
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
createdAt
|
|
329
|
+
});
|
|
330
|
+
entityIds.push(entity.entityId);
|
|
331
|
+
this.entityStore.recordMention({
|
|
332
|
+
entityId: entity.entityId,
|
|
333
|
+
neuronId: input.neuron.id,
|
|
334
|
+
projectId: input.neuron.metadata.projectId,
|
|
335
|
+
mentionType: 'declared',
|
|
336
|
+
createdAt
|
|
337
|
+
});
|
|
338
|
+
factInputs.push({
|
|
339
|
+
neuronId: input.neuron.id,
|
|
340
|
+
unitId,
|
|
341
|
+
subject: 'user',
|
|
342
|
+
predicateFamily: 'worked_on',
|
|
343
|
+
predicateValue: 'worked_on',
|
|
344
|
+
object: projectName,
|
|
345
|
+
entityId: entity.entityId,
|
|
346
|
+
validFrom: createdAt,
|
|
347
|
+
certaintyLevel: 'certain',
|
|
348
|
+
confidence: 0.86,
|
|
349
|
+
...(isSummarySupport ? {
|
|
350
|
+
confidence: 0.6,
|
|
351
|
+
certaintyLevel: 'probable'
|
|
352
|
+
} : {}),
|
|
353
|
+
status: 'provisional',
|
|
354
|
+
sourceText,
|
|
355
|
+
metadata: {
|
|
356
|
+
fact_origin: isSummarySupport ? 'imported_summary_support_fact' : 'original_compiler_fact',
|
|
357
|
+
...(isSummarySupport ? {
|
|
358
|
+
provenance_tier: 'support',
|
|
359
|
+
imported_summary_support: true
|
|
360
|
+
} : {})
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
else if (input.semanticCompilation?.projectLinks.length) {
|
|
365
|
+
for (const projectLink of input.semanticCompilation.projectLinks.slice(0, 2)) {
|
|
366
|
+
if (this.isRelativeProjectSurface(projectLink))
|
|
367
|
+
continue;
|
|
368
|
+
const projectAliases = Array.from(new Set([
|
|
369
|
+
projectLink,
|
|
370
|
+
...extractProjectAliasCandidates(workingText)
|
|
371
|
+
].filter(Boolean)));
|
|
372
|
+
const entity = this.entityStore.upsertEntity({
|
|
373
|
+
canonicalName: this.normalizeName(projectLink),
|
|
374
|
+
type: 'project',
|
|
375
|
+
aliases: projectAliases,
|
|
376
|
+
createdFrom: input.neuron.id,
|
|
377
|
+
metadata: {
|
|
378
|
+
projectId,
|
|
379
|
+
projectLocalInternalSlug: projectId,
|
|
380
|
+
rawMention: sourceText,
|
|
381
|
+
answerDisplayName: this.normalizeName(projectLink),
|
|
382
|
+
ens1ProjectLocalNaming: {
|
|
383
|
+
internalSlug: projectId,
|
|
384
|
+
canonicalProjectName: this.normalizeName(projectLink),
|
|
385
|
+
answerSurfaceProjectName: this.normalizeName(projectLink)
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
createdAt
|
|
389
|
+
});
|
|
390
|
+
entityIds.push(entity.entityId);
|
|
391
|
+
this.entityStore.recordMention({
|
|
392
|
+
entityId: entity.entityId,
|
|
393
|
+
neuronId: input.neuron.id,
|
|
394
|
+
projectId,
|
|
395
|
+
mentionType: 'declared',
|
|
396
|
+
createdAt
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
const projectReference = !isInteractionEventSemantic
|
|
401
|
+
? extractRelativeReferences(workingText).find((reference) => /项目|project/i.test(reference))
|
|
402
|
+
: undefined;
|
|
403
|
+
if (projectReference) {
|
|
404
|
+
const entity = this.resolveImplicitEntity(projectReference, 'project', projectId);
|
|
405
|
+
if (entity) {
|
|
406
|
+
entityIds.push(entity.entityId);
|
|
407
|
+
this.entityStore.recordMention({
|
|
408
|
+
entityId: entity.entityId,
|
|
409
|
+
neuronId: input.neuron.id,
|
|
410
|
+
projectId,
|
|
411
|
+
mentionType: 'referenced',
|
|
412
|
+
createdAt
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
this.entityStore.registerPendingResolution({
|
|
416
|
+
referenceText: projectReference,
|
|
417
|
+
entityType: 'project',
|
|
418
|
+
contextNeuronId: input.neuron.id,
|
|
419
|
+
createdAt
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
const latestPreference = !isInteractionEventSemantic
|
|
423
|
+
? (extractPreference(workingText) || extractNegativePreferenceCue(workingText))
|
|
424
|
+
: null;
|
|
425
|
+
if (latestPreference?.kind === 'like') {
|
|
426
|
+
factInputs.push({
|
|
427
|
+
neuronId: input.neuron.id,
|
|
428
|
+
unitId,
|
|
429
|
+
subject: 'user',
|
|
430
|
+
predicateFamily: 'likes',
|
|
431
|
+
predicateValue: 'like',
|
|
432
|
+
object: this.normalizeName(latestPreference.target),
|
|
433
|
+
validFrom: createdAt,
|
|
434
|
+
certaintyLevel: 'certain',
|
|
435
|
+
confidence: 0.84,
|
|
436
|
+
status: 'provisional',
|
|
437
|
+
sourceText,
|
|
438
|
+
metadata: {
|
|
439
|
+
fact_origin: 'original_compiler_fact'
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
if (latestPreference?.kind === 'dislike') {
|
|
444
|
+
factInputs.push({
|
|
445
|
+
neuronId: input.neuron.id,
|
|
446
|
+
unitId,
|
|
447
|
+
subject: 'user',
|
|
448
|
+
predicateFamily: 'dislikes',
|
|
449
|
+
predicateValue: 'dislike',
|
|
450
|
+
object: this.normalizeName(latestPreference.target),
|
|
451
|
+
validFrom: createdAt,
|
|
452
|
+
certaintyLevel: 'certain',
|
|
453
|
+
confidence: 0.84,
|
|
454
|
+
status: 'provisional',
|
|
455
|
+
sourceText,
|
|
456
|
+
metadata: {
|
|
457
|
+
fact_origin: 'original_compiler_fact'
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
if (sourceText.startsWith(`${INTERACTION_EVENT_PREFIX.approved}:`)) {
|
|
462
|
+
const target = sourceText.replace(new RegExp(`^${INTERACTION_EVENT_PREFIX.approved}:\\s*`, 'i'), '');
|
|
463
|
+
const archiveProject = extractApprovedArchiveProject(target);
|
|
464
|
+
eventInputs.push({
|
|
465
|
+
neuronId: input.neuron.id,
|
|
466
|
+
unitId,
|
|
467
|
+
eventType: 'approved',
|
|
468
|
+
actor: 'user',
|
|
469
|
+
target,
|
|
470
|
+
payload: {
|
|
471
|
+
semanticText: sourceText,
|
|
472
|
+
action: archiveProject ? 'archive' : 'approve',
|
|
473
|
+
project: archiveProject || undefined
|
|
474
|
+
},
|
|
475
|
+
validFrom: createdAt,
|
|
476
|
+
confidence: 0.93,
|
|
477
|
+
status: 'verified'
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
if (sourceText.startsWith(`${INTERACTION_EVENT_PREFIX.rejected}:`)) {
|
|
481
|
+
const target = sourceText.replace(new RegExp(`^${INTERACTION_EVENT_PREFIX.rejected}:\\s*`, 'i'), '');
|
|
482
|
+
eventInputs.push({
|
|
483
|
+
neuronId: input.neuron.id,
|
|
484
|
+
unitId,
|
|
485
|
+
eventType: 'rejected',
|
|
486
|
+
actor: 'user',
|
|
487
|
+
target,
|
|
488
|
+
payload: {
|
|
489
|
+
semanticText: sourceText,
|
|
490
|
+
action: 'reject'
|
|
491
|
+
},
|
|
492
|
+
validFrom: createdAt,
|
|
493
|
+
confidence: 0.93,
|
|
494
|
+
status: 'verified'
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
const facts = this.factStore.insertFacts(factInputs);
|
|
498
|
+
const events = this.factStore.insertEvents(eventInputs);
|
|
499
|
+
return { facts, events, entityIds: Array.from(new Set(entityIds)) };
|
|
500
|
+
}
|
|
501
|
+
normalizeName(value) {
|
|
502
|
+
return value.trim().replace(/\s+/g, ' ');
|
|
503
|
+
}
|
|
504
|
+
extractIssueMatches(text, issueHints) {
|
|
505
|
+
const matches = new Map();
|
|
506
|
+
const normalizedHints = issueHints.filter(Boolean);
|
|
507
|
+
for (const issueHint of normalizedHints) {
|
|
508
|
+
const issue = this.extractIssuePhrase(issueHint);
|
|
509
|
+
if (!issue)
|
|
510
|
+
continue;
|
|
511
|
+
const reference = extractDeviceCandidate(issueHint) || extractRelativeReferences(issueHint)[0] || 'device';
|
|
512
|
+
matches.set(`${reference}|${this.normalizeIssueValue(issue)}`, {
|
|
513
|
+
reference,
|
|
514
|
+
issue,
|
|
515
|
+
issueFamily: this.inferIssueFamily(issue)
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
if (matches.size === 0) {
|
|
519
|
+
const latest = extractLatestIssueReference(text);
|
|
520
|
+
if (latest) {
|
|
521
|
+
matches.set(`${latest.reference}|${this.normalizeIssueValue(latest.issue)}`, {
|
|
522
|
+
...latest,
|
|
523
|
+
issueFamily: this.inferIssueFamily(latest.issue)
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return Array.from(matches.values());
|
|
528
|
+
}
|
|
529
|
+
normalizeIssueValue(value) {
|
|
530
|
+
return inferIssueValue(value) || this.normalizeName(value);
|
|
531
|
+
}
|
|
532
|
+
buildIssueMetadata(issue, sourcePhrase, sourceText, extra = {}) {
|
|
533
|
+
const normalizedIssueValue = this.normalizeIssueValue(issue);
|
|
534
|
+
return {
|
|
535
|
+
normalizedIssueValue,
|
|
536
|
+
issueOriginalWording: issue,
|
|
537
|
+
issueSourcePhrase: sourcePhrase,
|
|
538
|
+
...(extra.issueFamily ? { issueFamily: extra.issueFamily } : { issueFamily: this.inferIssueFamily(issue) }),
|
|
539
|
+
...extra,
|
|
540
|
+
sourceTextSnapshot: sourceText
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
buildContinuityMetadata(input) {
|
|
544
|
+
const continuityFamilies = new Set();
|
|
545
|
+
const normalizedIssueValue = this.normalizeIssueValue(input.issue);
|
|
546
|
+
const recentEntityFacts = input.entity
|
|
547
|
+
? this.factStore.listFactsByEntityIds([input.entity.entityId], {
|
|
548
|
+
predicateFamilies: ['has_issue'],
|
|
549
|
+
limit: 16
|
|
550
|
+
}).filter((fact) => fact.validFrom < input.createdAt)
|
|
551
|
+
: [];
|
|
552
|
+
const matchingIssueHistory = recentEntityFacts.filter((fact) => this.normalizeIssueValue(String(fact.metadata?.normalizedIssueValue || fact.predicateValue || '')) === normalizedIssueValue);
|
|
553
|
+
const sameProjectEntityFacts = recentEntityFacts.filter((fact) => fact.metadata?.projectId === input.projectId);
|
|
554
|
+
const siblingIssues = Array.from(new Set(sameProjectEntityFacts
|
|
555
|
+
.map((fact) => this.normalizeIssueValue(String(fact.metadata?.normalizedIssueValue || fact.predicateValue || '')))
|
|
556
|
+
.filter((value) => Boolean(value) && value !== normalizedIssueValue)));
|
|
557
|
+
const projectSurfaceName = input.projectId
|
|
558
|
+
? this.resolveContinuityProjectSurfaceName(input.sourceText, input.projectId, input.createdAt)
|
|
559
|
+
: undefined;
|
|
560
|
+
const followUpCue = /(follow(?:ing)? up|还是|依旧|仍然|又|still|again)/i.test(input.sourceText);
|
|
561
|
+
const handoffCue = /(handoff|handover|交接|接手|下一轮|next session)/i.test(input.sourceText);
|
|
562
|
+
if (followUpCue || matchingIssueHistory.length > 0) {
|
|
563
|
+
continuityFamilies.add('repeated_follow_up_continuity');
|
|
564
|
+
}
|
|
565
|
+
if (handoffCue) {
|
|
566
|
+
continuityFamilies.add('verified_session_handoff_continuity');
|
|
567
|
+
}
|
|
568
|
+
if (input.projectId && input.entity && siblingIssues.length > 0) {
|
|
569
|
+
continuityFamilies.add('stable_same_project_sibling_continuity');
|
|
570
|
+
}
|
|
571
|
+
if (input.projectId && input.entity) {
|
|
572
|
+
continuityFamilies.add('narrow_device_project_continuity');
|
|
573
|
+
}
|
|
574
|
+
const crossDayAnchor = matchingIssueHistory.find((fact) => input.createdAt - fact.validFrom >= 24 * 60 * 60 * 1000);
|
|
575
|
+
if (crossDayAnchor) {
|
|
576
|
+
continuityFamilies.add('repeated_same_entity_cross_day_continuity');
|
|
577
|
+
}
|
|
578
|
+
return {
|
|
579
|
+
continuityFamilies: Array.from(continuityFamilies),
|
|
580
|
+
continuityAnswerEligible: continuityFamilies.size > 0,
|
|
581
|
+
continuityRepeatCount: matchingIssueHistory.length + 1,
|
|
582
|
+
continuitySiblingIssueCount: siblingIssues.length,
|
|
583
|
+
continuitySiblingIssues: siblingIssues,
|
|
584
|
+
continuityCrossDayRepeat: Boolean(crossDayAnchor),
|
|
585
|
+
continuityCrossDayGapDays: crossDayAnchor
|
|
586
|
+
? Math.max(1, Math.round((input.createdAt - crossDayAnchor.validFrom) / (24 * 60 * 60 * 1000)))
|
|
587
|
+
: undefined,
|
|
588
|
+
continuityHandoffOpen: handoffCue,
|
|
589
|
+
continuityProjectScope: input.projectId,
|
|
590
|
+
continuityProjectSurfaceName: projectSurfaceName,
|
|
591
|
+
continuityResolvedEntityName: input.entity?.canonicalName,
|
|
592
|
+
continuityAnswerSurfaceEntityName: input.entity?.canonicalName,
|
|
593
|
+
ens1RawMention: input.sourceText,
|
|
594
|
+
ens1CanonicalEntityName: input.entity?.canonicalName,
|
|
595
|
+
ens1AnswerSurfaceDisplayName: input.entity?.canonicalName,
|
|
596
|
+
ens1ProjectLocalInternalSlug: input.projectId,
|
|
597
|
+
ens1ProjectCanonicalName: projectSurfaceName,
|
|
598
|
+
ens1ProjectAnswerSurfaceName: projectSurfaceName,
|
|
599
|
+
ens1IdentityFields: ['entityId', 'ens1CanonicalEntityName', 'ens1ProjectCanonicalName'],
|
|
600
|
+
ens1DisplayFields: ['ens1AnswerSurfaceDisplayName', 'ens1ProjectAnswerSurfaceName']
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
buildWriteTimeBindingMetadata(input) {
|
|
604
|
+
const relativeReference = extractRelativeReferences(input.sourceText)[0];
|
|
605
|
+
if (!relativeReference || !input.entity)
|
|
606
|
+
return {};
|
|
607
|
+
const candidates = this.entityStore.listReferenceCandidatesWithRelativeSupport(relativeReference, input.type, {
|
|
608
|
+
projectId: input.projectId
|
|
609
|
+
});
|
|
610
|
+
const top = candidates[0];
|
|
611
|
+
if (!top || top.entity.entityId !== input.entity.entityId)
|
|
612
|
+
return {};
|
|
613
|
+
return {
|
|
614
|
+
writeTimeRelativeBindingApplied: true,
|
|
615
|
+
writeTimeRelativeBindingReference: relativeReference,
|
|
616
|
+
writeTimeRelativeBindingScore: top.score,
|
|
617
|
+
writeTimeRelativeBindingEntityId: top.entity.entityId,
|
|
618
|
+
writeTimeRelativeBindingEntityName: top.entity.canonicalName,
|
|
619
|
+
writeTimeRelativeBindingCanonicalSurfaceName: top.entity.canonicalName,
|
|
620
|
+
writeTimeRelativeBindingCanonicalIdentityName: top.entity.canonicalName,
|
|
621
|
+
writeTimeRelativeBindingDisplayName: top.entity.canonicalName,
|
|
622
|
+
ens1RelativeReferenceSurface: relativeReference,
|
|
623
|
+
ens1RelativeReferenceLandingLayer: 'canonical_entity_record',
|
|
624
|
+
ens1RelativeReferenceLandingStatus: 'resolved_narrow_safe',
|
|
625
|
+
ens1RelativeReferenceLandingEntityId: top.entity.entityId,
|
|
626
|
+
ens1RelativeReferenceLandingCanonicalName: top.entity.canonicalName
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
resolveContinuityProjectSurfaceName(sourceText, projectId, createdAt) {
|
|
630
|
+
const explicit = extractProjectCandidate(sourceText);
|
|
631
|
+
if (explicit)
|
|
632
|
+
return this.normalizeName(explicit);
|
|
633
|
+
const timeline = this.entityStore.getEntityTimeline({
|
|
634
|
+
type: 'project',
|
|
635
|
+
projectId,
|
|
636
|
+
limit: 6
|
|
637
|
+
});
|
|
638
|
+
const matched = timeline.find((item) => item.createdAt <= createdAt);
|
|
639
|
+
return matched?.canonicalName;
|
|
640
|
+
}
|
|
641
|
+
extractIssuePhrase(segment) {
|
|
642
|
+
const normalized = this.normalizeName(segment);
|
|
643
|
+
if (/配对(?:也)?很慢/.test(normalized))
|
|
644
|
+
return '配对慢';
|
|
645
|
+
if (/电流声/.test(normalized))
|
|
646
|
+
return '电流声';
|
|
647
|
+
const qualifier = normalized.includes('左耳') ? '左耳' : normalized.includes('右耳') ? '右耳' : '';
|
|
648
|
+
const inferred = inferIssueValue(normalized);
|
|
649
|
+
if (!inferred)
|
|
650
|
+
return null;
|
|
651
|
+
return qualifier && !inferred.startsWith(qualifier) ? `${qualifier}${inferred}` : inferred;
|
|
652
|
+
}
|
|
653
|
+
inferIssueFamily(issue) {
|
|
654
|
+
if (/断连/.test(issue))
|
|
655
|
+
return 'connectivity_issue';
|
|
656
|
+
if (/(杂音|电流声)/.test(issue))
|
|
657
|
+
return 'sound_issue';
|
|
658
|
+
if (/(卡顿|配对慢)/.test(issue))
|
|
659
|
+
return 'performance_issue';
|
|
660
|
+
return 'generic_issue';
|
|
661
|
+
}
|
|
662
|
+
buildSelfCorrectionArtifact(input) {
|
|
663
|
+
if (!this.isSelfCorrectionSurface(input.workingText))
|
|
664
|
+
return null;
|
|
665
|
+
const correctionTo = this.extractCorrectionSide(input.workingText);
|
|
666
|
+
if (!correctionTo)
|
|
667
|
+
return null;
|
|
668
|
+
const correctionFrom = this.extractNegatedCorrectionSide(input.workingText, correctionTo);
|
|
669
|
+
const resolvedDevice = this.resolveImplicitEntity('它', 'device', input.projectId)
|
|
670
|
+
|| this.entityStore.findLatestByType('device');
|
|
671
|
+
const recentIssue = resolvedDevice
|
|
672
|
+
? this.factStore.listFactsByEntityIds([resolvedDevice.entityId], {
|
|
673
|
+
predicateFamilies: ['has_issue'],
|
|
674
|
+
limit: 8
|
|
675
|
+
}).find((fact) => fact.validFrom <= input.neuron.metadata.createdAt)
|
|
676
|
+
: this.factStore.listFactsByTimeRange(0, input.neuron.metadata.createdAt + 1, {
|
|
677
|
+
limit: 12
|
|
678
|
+
}).find((fact) => fact.predicateFamily === 'has_issue' && this.factMatchesCorrectionSide(fact, correctionTo))
|
|
679
|
+
|| this.factStore.listFactsByTimeRange(0, input.neuron.metadata.createdAt + 1, {
|
|
680
|
+
limit: 12
|
|
681
|
+
}).find((fact) => fact.predicateFamily === 'has_issue');
|
|
682
|
+
const issueStem = recentIssue
|
|
683
|
+
? (inferIssueValue(`${recentIssue.metadata?.issueOriginalWording || recentIssue.predicateValue || recentIssue.sourceText}`) || '异常')
|
|
684
|
+
: '异常';
|
|
685
|
+
const correctionIssue = `${correctionTo}${issueStem}`;
|
|
686
|
+
return {
|
|
687
|
+
neuronId: input.neuron.id,
|
|
688
|
+
unitId: input.unitId,
|
|
689
|
+
subject: 'device',
|
|
690
|
+
predicateFamily: 'issue_correction',
|
|
691
|
+
predicateValue: correctionTo,
|
|
692
|
+
object: resolvedDevice?.canonicalName || 'device',
|
|
693
|
+
entityId: resolvedDevice?.entityId,
|
|
694
|
+
validFrom: input.neuron.metadata.createdAt,
|
|
695
|
+
certaintyLevel: 'probable',
|
|
696
|
+
confidence: recentIssue ? 0.82 : 0.74,
|
|
697
|
+
status: 'provisional',
|
|
698
|
+
sourceText: input.sourceText,
|
|
699
|
+
metadata: this.buildIssueMetadata(correctionIssue, input.sourceText, input.sourceText, {
|
|
700
|
+
issueFamily: this.inferIssueFamily(correctionIssue),
|
|
701
|
+
correctionArtifact: true,
|
|
702
|
+
correctionKind: 'self_correction',
|
|
703
|
+
correctionStage: 'write_time',
|
|
704
|
+
correctionTo,
|
|
705
|
+
correctionFrom,
|
|
706
|
+
correctionBasisFactId: recentIssue?.factId,
|
|
707
|
+
correctedIssueValue: correctionIssue
|
|
708
|
+
})
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
isSelfCorrectionSurface(text) {
|
|
712
|
+
const hasEarSurface = /(左耳|右耳)/.test(text) || /\b(left ear|right ear)\b/i.test(text);
|
|
713
|
+
if (!hasEarSurface)
|
|
714
|
+
return false;
|
|
715
|
+
return /(不对|不是|更正|改口)/.test(text)
|
|
716
|
+
|| /\b(no|actually|correction|not)\b/i.test(text);
|
|
717
|
+
}
|
|
718
|
+
extractCorrectionSide(text) {
|
|
719
|
+
if (/右耳/.test(text))
|
|
720
|
+
return '右耳';
|
|
721
|
+
if (/左耳/.test(text))
|
|
722
|
+
return '左耳';
|
|
723
|
+
if (/right ear/i.test(text))
|
|
724
|
+
return '右耳';
|
|
725
|
+
if (/left ear/i.test(text))
|
|
726
|
+
return '左耳';
|
|
727
|
+
return null;
|
|
728
|
+
}
|
|
729
|
+
extractNegatedCorrectionSide(text, correctionTo) {
|
|
730
|
+
if (/不是左耳|not left ear/i.test(text) && correctionTo !== '左耳')
|
|
731
|
+
return '左耳';
|
|
732
|
+
if (/不是右耳|not right ear/i.test(text) && correctionTo !== '右耳')
|
|
733
|
+
return '右耳';
|
|
734
|
+
return undefined;
|
|
735
|
+
}
|
|
736
|
+
factMatchesCorrectionSide(fact, correctionTo) {
|
|
737
|
+
const haystack = `${fact.predicateValue || ''} ${fact.metadata?.issueOriginalWording || ''}`;
|
|
738
|
+
return haystack.includes(correctionTo);
|
|
739
|
+
}
|
|
740
|
+
extractPendingEntityReference(sourceText, relativeReferences) {
|
|
741
|
+
const normalizedReferences = relativeReferences.length > 0 ? relativeReferences : extractRelativeReferences(sourceText);
|
|
742
|
+
const explicit = normalizedReferences.find(Boolean);
|
|
743
|
+
if (explicit)
|
|
744
|
+
return explicit;
|
|
745
|
+
return null;
|
|
746
|
+
}
|
|
747
|
+
isRelativeProjectSurface(text) {
|
|
748
|
+
const normalized = normalizeLexiconText(text).trim();
|
|
749
|
+
return /^(这个|那个|前一个|上一个|新的|新|旧的|旧).{0,4}项目$/i.test(normalized)
|
|
750
|
+
|| /^(this|that|the previous|previous|the new|new|old)\s+project$/i.test(normalized);
|
|
751
|
+
}
|
|
752
|
+
resolveImplicitEntity(sourceText, type, projectId) {
|
|
753
|
+
const relativeReferences = extractRelativeReferences(sourceText);
|
|
754
|
+
if (relativeReferences.length > 0) {
|
|
755
|
+
const matched = this.pickSpecificRelativeReference(relativeReferences, type)
|
|
756
|
+
|| (type === 'project' ? '这个项目' : '它');
|
|
757
|
+
const hasTypedRelativeSurface = inferReferenceType(matched, matched) === type;
|
|
758
|
+
const hasOrderedInstanceSignal = isLatestReference(matched) || isPreviousReference(matched);
|
|
759
|
+
if (this.isWeakRelativeReferenceSurface(matched, type) && !hasTypedRelativeSurface && !hasOrderedInstanceSignal) {
|
|
760
|
+
return null;
|
|
761
|
+
}
|
|
762
|
+
const safelyResolved = this.resolveRelativeEntitySafely(matched, type, projectId);
|
|
763
|
+
if (safelyResolved)
|
|
764
|
+
return safelyResolved;
|
|
765
|
+
if (this.isWeakRelativeReferenceSurface(matched, type) && !hasOrderedInstanceSignal) {
|
|
766
|
+
return null;
|
|
767
|
+
}
|
|
768
|
+
if (type === 'device' && relativeReferences.some((reference) => isPreviousReference(reference))) {
|
|
769
|
+
return null;
|
|
770
|
+
}
|
|
771
|
+
return this.entityStore.resolveReference(matched, type, { projectId });
|
|
772
|
+
}
|
|
773
|
+
const direct = this.entityStore.resolveReference(sourceText, type, {
|
|
774
|
+
projectId
|
|
775
|
+
});
|
|
776
|
+
if (direct)
|
|
777
|
+
return direct;
|
|
778
|
+
if (type === 'device' && hasIssueSignal(sourceText)) {
|
|
779
|
+
return this.entityStore.resolveReference('它', 'device', { projectId });
|
|
780
|
+
}
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
783
|
+
resolveRelativeEntitySafely(reference, type, projectId) {
|
|
784
|
+
const candidates = this.entityStore.listReferenceCandidatesWithRelativeSupport(reference, type, {
|
|
785
|
+
projectId
|
|
786
|
+
});
|
|
787
|
+
const best = candidates[0];
|
|
788
|
+
const runnerUp = candidates[1];
|
|
789
|
+
if (!best)
|
|
790
|
+
return null;
|
|
791
|
+
const minScore = isPreviousReference(reference) ? 0.68 : 0.7;
|
|
792
|
+
const margin = runnerUp ? best.score - runnerUp.score : best.score;
|
|
793
|
+
if (best.score < minScore || margin < 0.22) {
|
|
794
|
+
return null;
|
|
795
|
+
}
|
|
796
|
+
return {
|
|
797
|
+
entityId: best.entity.entityId,
|
|
798
|
+
canonicalName: best.entity.canonicalName
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
isWeakRelativeReferenceSurface(reference, type) {
|
|
802
|
+
const normalized = normalizeLexiconText(reference).trim().toLowerCase();
|
|
803
|
+
if (type === 'device') {
|
|
804
|
+
return /^(?:之前那个|前一个|上一个|新的那个|那个|这个|the previous one|previous one|the new one|new one|that one|this one)$/i.test(normalized);
|
|
805
|
+
}
|
|
806
|
+
if (type === 'project') {
|
|
807
|
+
return /^(?:那个项目|这个项目|前一个项目|上一个项目|新的项目|the previous project|previous project|the new project|new project|that project|this project)$/i.test(normalized);
|
|
808
|
+
}
|
|
809
|
+
return false;
|
|
810
|
+
}
|
|
811
|
+
pickSpecificRelativeReference(references, type) {
|
|
812
|
+
const typed = references
|
|
813
|
+
.filter((reference) => inferReferenceType(reference, reference) === type)
|
|
814
|
+
.sort((a, b) => b.length - a.length);
|
|
815
|
+
if (typed.length > 0)
|
|
816
|
+
return typed[0] || null;
|
|
817
|
+
const sorted = [...references].sort((a, b) => b.length - a.length);
|
|
818
|
+
return sorted[0] || null;
|
|
819
|
+
}
|
|
820
|
+
}
|