@iworkforces/tracelattice 2.0.3
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/LICENSE +24 -0
- package/README.md +260 -0
- package/dist/CliLifecycle.d.ts +31 -0
- package/dist/CliLifecycle.d.ts.map +1 -0
- package/dist/CliLifecycle.js +90 -0
- package/dist/CliLifecycle.js.map +1 -0
- package/dist/ServerConfig.d.ts +290 -0
- package/dist/ServerConfig.d.ts.map +1 -0
- package/dist/ServerConfig.js +175 -0
- package/dist/ServerConfig.js.map +1 -0
- package/dist/cache/DiscoveryCache.d.ts +269 -0
- package/dist/cache/DiscoveryCache.d.ts.map +1 -0
- package/dist/cache/DiscoveryCache.js +104 -0
- package/dist/cache/DiscoveryCache.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +5177 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/ConfigLoader.d.ts +270 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +186 -0
- package/dist/config/ConfigLoader.js.map +1 -0
- package/dist/context/RequestContext.d.ts +43 -0
- package/dist/context/RequestContext.d.ts.map +1 -0
- package/dist/context/RequestContext.js +14 -0
- package/dist/context/RequestContext.js.map +1 -0
- package/dist/contracts/PersistenceBackend.d.ts +134 -0
- package/dist/contracts/PersistenceBackend.d.ts.map +1 -0
- package/dist/contracts/PersistenceBackend.js +6 -0
- package/dist/contracts/PersistenceBackend.js.map +1 -0
- package/dist/contracts/calibrator.d.ts +97 -0
- package/dist/contracts/calibrator.d.ts.map +1 -0
- package/dist/contracts/calibrator.js +1 -0
- package/dist/contracts/features.d.ts +35 -0
- package/dist/contracts/features.d.ts.map +1 -0
- package/dist/contracts/features.js +12 -0
- package/dist/contracts/features.js.map +1 -0
- package/dist/contracts/ids.d.ts +68 -0
- package/dist/contracts/ids.d.ts.map +1 -0
- package/dist/contracts/ids.js +40 -0
- package/dist/contracts/ids.js.map +1 -0
- package/dist/contracts/interfaces.d.ts +254 -0
- package/dist/contracts/interfaces.d.ts.map +1 -0
- package/dist/contracts/interfaces.js +1 -0
- package/dist/contracts/persistence-work.d.ts +96 -0
- package/dist/contracts/persistence-work.d.ts.map +1 -0
- package/dist/contracts/persistence-work.js +1 -0
- package/dist/contracts/reasoning-types.d.ts +21 -0
- package/dist/contracts/reasoning-types.d.ts.map +1 -0
- package/dist/contracts/reasoning-types.js +1 -0
- package/dist/contracts/strategy.d.ts +107 -0
- package/dist/contracts/strategy.d.ts.map +1 -0
- package/dist/contracts/strategy.js +1 -0
- package/dist/contracts/summary.d.ts +110 -0
- package/dist/contracts/summary.d.ts.map +1 -0
- package/dist/contracts/summary.js +1 -0
- package/dist/contracts/suspension.d.ts +215 -0
- package/dist/contracts/suspension.d.ts.map +1 -0
- package/dist/contracts/suspension.js +1 -0
- package/dist/contracts/transport.d.ts +26 -0
- package/dist/contracts/transport.d.ts.map +1 -0
- package/dist/contracts/transport.js +1 -0
- package/dist/core/CrossReferenceValidator.d.ts +18 -0
- package/dist/core/CrossReferenceValidator.d.ts.map +1 -0
- package/dist/core/CrossReferenceValidator.js +125 -0
- package/dist/core/CrossReferenceValidator.js.map +1 -0
- package/dist/core/HistoryManager.d.ts +215 -0
- package/dist/core/HistoryManager.d.ts.map +1 -0
- package/dist/core/HistoryManager.js +594 -0
- package/dist/core/HistoryManager.js.map +1 -0
- package/dist/core/IHistoryManager.d.ts +163 -0
- package/dist/core/IHistoryManager.d.ts.map +1 -0
- package/dist/core/IHistoryManager.js +1 -0
- package/dist/core/IThoughtFormatter.d.ts +51 -0
- package/dist/core/IThoughtFormatter.d.ts.map +1 -0
- package/dist/core/IThoughtFormatter.js +1 -0
- package/dist/core/InputNormalizer.d.ts +140 -0
- package/dist/core/InputNormalizer.d.ts.map +1 -0
- package/dist/core/InputNormalizer.js +95 -0
- package/dist/core/InputNormalizer.js.map +1 -0
- package/dist/core/PersistenceBuffer.d.ts +204 -0
- package/dist/core/PersistenceBuffer.d.ts.map +1 -0
- package/dist/core/PersistenceBuffer.js +382 -0
- package/dist/core/PersistenceBuffer.js.map +1 -0
- package/dist/core/PersistenceBufferErrors.d.ts +22 -0
- package/dist/core/PersistenceBufferErrors.d.ts.map +1 -0
- package/dist/core/PersistenceBufferErrors.js +30 -0
- package/dist/core/PersistenceBufferErrors.js.map +1 -0
- package/dist/core/PersistenceRestore.d.ts +21 -0
- package/dist/core/PersistenceRestore.d.ts.map +1 -0
- package/dist/core/PersistenceRestore.js +87 -0
- package/dist/core/PersistenceRestore.js.map +1 -0
- package/dist/core/PersistenceWorkQueue.d.ts +155 -0
- package/dist/core/PersistenceWorkQueue.d.ts.map +1 -0
- package/dist/core/PersistenceWorkQueue.js +298 -0
- package/dist/core/PersistenceWorkQueue.js.map +1 -0
- package/dist/core/PersistenceWriter.d.ts +55 -0
- package/dist/core/PersistenceWriter.d.ts.map +1 -0
- package/dist/core/PersistenceWriter.js +112 -0
- package/dist/core/PersistenceWriter.js.map +1 -0
- package/dist/core/SessionErrors.d.ts +37 -0
- package/dist/core/SessionErrors.d.ts.map +1 -0
- package/dist/core/SessionErrors.js +50 -0
- package/dist/core/SessionErrors.js.map +1 -0
- package/dist/core/SessionLifecycleCoordinator.d.ts +74 -0
- package/dist/core/SessionLifecycleCoordinator.d.ts.map +1 -0
- package/dist/core/SessionLifecycleCoordinator.js +222 -0
- package/dist/core/SessionLifecycleCoordinator.js.map +1 -0
- package/dist/core/SessionLock.d.ts +59 -0
- package/dist/core/SessionLock.d.ts.map +1 -0
- package/dist/core/SessionLock.js +39 -0
- package/dist/core/SessionLock.js.map +1 -0
- package/dist/core/SessionManager.d.ts +62 -0
- package/dist/core/SessionManager.d.ts.map +1 -0
- package/dist/core/SessionManager.js +75 -0
- package/dist/core/SessionManager.js.map +1 -0
- package/dist/core/SessionResetCoordinator.d.ts +37 -0
- package/dist/core/SessionResetCoordinator.d.ts.map +1 -0
- package/dist/core/SessionResetCoordinator.js +80 -0
- package/dist/core/SessionResetCoordinator.js.map +1 -0
- package/dist/core/ThoughtEvaluator.d.ts +48 -0
- package/dist/core/ThoughtEvaluator.d.ts.map +1 -0
- package/dist/core/ThoughtEvaluator.js +85 -0
- package/dist/core/ThoughtEvaluator.js.map +1 -0
- package/dist/core/ThoughtFormatter.d.ts +134 -0
- package/dist/core/ThoughtFormatter.d.ts.map +1 -0
- package/dist/core/ThoughtFormatter.js +118 -0
- package/dist/core/ThoughtFormatter.js.map +1 -0
- package/dist/core/ThoughtProcessor.d.ts +259 -0
- package/dist/core/ThoughtProcessor.d.ts.map +1 -0
- package/dist/core/ThoughtProcessor.js +451 -0
- package/dist/core/ThoughtProcessor.js.map +1 -0
- package/dist/core/ThoughtReferenceIndex.d.ts +23 -0
- package/dist/core/ThoughtReferenceIndex.d.ts.map +1 -0
- package/dist/core/ThoughtReferenceIndex.js +66 -0
- package/dist/core/ThoughtReferenceIndex.js.map +1 -0
- package/dist/core/VerificationOutcomeAdmission.d.ts +15 -0
- package/dist/core/VerificationOutcomeAdmission.d.ts.map +1 -0
- package/dist/core/VerificationOutcomeAdmission.js +28 -0
- package/dist/core/VerificationOutcomeAdmission.js.map +1 -0
- package/dist/core/compression/CompressionService.d.ts +76 -0
- package/dist/core/compression/CompressionService.d.ts.map +1 -0
- package/dist/core/compression/CompressionService.js +160 -0
- package/dist/core/compression/CompressionService.js.map +1 -0
- package/dist/core/compression/DehydrationPolicy.d.ts +75 -0
- package/dist/core/compression/DehydrationPolicy.d.ts.map +1 -0
- package/dist/core/compression/DehydrationPolicy.js +45 -0
- package/dist/core/compression/DehydrationPolicy.js.map +1 -0
- package/dist/core/compression/InMemorySummaryStore.d.ts +132 -0
- package/dist/core/compression/InMemorySummaryStore.d.ts.map +1 -0
- package/dist/core/compression/InMemorySummaryStore.js +69 -0
- package/dist/core/compression/InMemorySummaryStore.js.map +1 -0
- package/dist/core/compression/Summary.d.ts +74 -0
- package/dist/core/compression/Summary.d.ts.map +1 -0
- package/dist/core/compression/Summary.js +16 -0
- package/dist/core/compression/Summary.js.map +1 -0
- package/dist/core/evaluator/Aggregator.d.ts +40 -0
- package/dist/core/evaluator/Aggregator.d.ts.map +1 -0
- package/dist/core/evaluator/Aggregator.js +36 -0
- package/dist/core/evaluator/Aggregator.js.map +1 -0
- package/dist/core/evaluator/Calibrator.d.ts +52 -0
- package/dist/core/evaluator/Calibrator.d.ts.map +1 -0
- package/dist/core/evaluator/Calibrator.js +135 -0
- package/dist/core/evaluator/Calibrator.js.map +1 -0
- package/dist/core/evaluator/PatternDetector.d.ts +69 -0
- package/dist/core/evaluator/PatternDetector.d.ts.map +1 -0
- package/dist/core/evaluator/PatternDetector.js +192 -0
- package/dist/core/evaluator/PatternDetector.js.map +1 -0
- package/dist/core/evaluator/SignalComputer.d.ts +116 -0
- package/dist/core/evaluator/SignalComputer.d.ts.map +1 -0
- package/dist/core/evaluator/SignalComputer.js +110 -0
- package/dist/core/evaluator/SignalComputer.js.map +1 -0
- package/dist/core/evaluator/calibration-math.d.ts +39 -0
- package/dist/core/evaluator/calibration-math.d.ts.map +1 -0
- package/dist/core/evaluator/calibration-math.js +42 -0
- package/dist/core/evaluator/calibration-math.js.map +1 -0
- package/dist/core/evaluator/internals.d.ts +36 -0
- package/dist/core/evaluator/internals.d.ts.map +1 -0
- package/dist/core/evaluator/internals.js +43 -0
- package/dist/core/evaluator/internals.js.map +1 -0
- package/dist/core/graph/Edge.d.ts +58 -0
- package/dist/core/graph/Edge.d.ts.map +1 -0
- package/dist/core/graph/Edge.js +1 -0
- package/dist/core/graph/EdgeEmitter.d.ts +68 -0
- package/dist/core/graph/EdgeEmitter.d.ts.map +1 -0
- package/dist/core/graph/EdgeEmitter.js +118 -0
- package/dist/core/graph/EdgeEmitter.js.map +1 -0
- package/dist/core/graph/EdgeStore.d.ts +116 -0
- package/dist/core/graph/EdgeStore.d.ts.map +1 -0
- package/dist/core/graph/EdgeStore.js +107 -0
- package/dist/core/graph/EdgeStore.js.map +1 -0
- package/dist/core/graph/GraphView.d.ts +157 -0
- package/dist/core/graph/GraphView.d.ts.map +1 -0
- package/dist/core/graph/GraphView.js +149 -0
- package/dist/core/graph/GraphView.js.map +1 -0
- package/dist/core/ids.d.ts +33 -0
- package/dist/core/ids.d.ts.map +1 -0
- package/dist/core/ids.js +11 -0
- package/dist/core/ids.js.map +1 -0
- package/dist/core/reasoning/OutcomeRecorder.d.ts +88 -0
- package/dist/core/reasoning/OutcomeRecorder.d.ts.map +1 -0
- package/dist/core/reasoning/OutcomeRecorder.js +51 -0
- package/dist/core/reasoning/OutcomeRecorder.js.map +1 -0
- package/dist/core/reasoning/strategies/SequentialStrategy.d.ts +54 -0
- package/dist/core/reasoning/strategies/SequentialStrategy.d.ts.map +1 -0
- package/dist/core/reasoning/strategies/SequentialStrategy.js +22 -0
- package/dist/core/reasoning/strategies/SequentialStrategy.js.map +1 -0
- package/dist/core/reasoning/strategies/StrategyFactory.d.ts +25 -0
- package/dist/core/reasoning/strategies/StrategyFactory.d.ts.map +1 -0
- package/dist/core/reasoning/strategies/StrategyFactory.js +16 -0
- package/dist/core/reasoning/strategies/StrategyFactory.js.map +1 -0
- package/dist/core/reasoning/strategies/TreeOfThoughtStrategy.d.ts +58 -0
- package/dist/core/reasoning/strategies/TreeOfThoughtStrategy.d.ts.map +1 -0
- package/dist/core/reasoning/strategies/TreeOfThoughtStrategy.js +103 -0
- package/dist/core/reasoning/strategies/TreeOfThoughtStrategy.js.map +1 -0
- package/dist/core/reasoning/strategies/plateau.d.ts +18 -0
- package/dist/core/reasoning/strategies/plateau.d.ts.map +1 -0
- package/dist/core/reasoning/strategies/plateau.js +12 -0
- package/dist/core/reasoning/strategies/plateau.js.map +1 -0
- package/dist/core/reasoning/strategies/totScoring.d.ts +91 -0
- package/dist/core/reasoning/strategies/totScoring.d.ts.map +1 -0
- package/dist/core/reasoning/strategies/totScoring.js +88 -0
- package/dist/core/reasoning/strategies/totScoring.js.map +1 -0
- package/dist/core/reasoning.d.ts +179 -0
- package/dist/core/reasoning.d.ts.map +1 -0
- package/dist/core/reasoning.js +1 -0
- package/dist/core/step.d.ts +50 -0
- package/dist/core/step.d.ts.map +1 -0
- package/dist/core/step.js +1 -0
- package/dist/core/thought.d.ts +113 -0
- package/dist/core/thought.d.ts.map +1 -0
- package/dist/core/thought.js +1 -0
- package/dist/core/tools/InMemorySuspensionStore.d.ts +66 -0
- package/dist/core/tools/InMemorySuspensionStore.d.ts.map +1 -0
- package/dist/core/tools/InMemorySuspensionStore.js +121 -0
- package/dist/core/tools/InMemorySuspensionStore.js.map +1 -0
- package/dist/di/Container.d.ts +253 -0
- package/dist/di/Container.d.ts.map +1 -0
- package/dist/di/Container.js +111 -0
- package/dist/di/Container.js.map +1 -0
- package/dist/di/ServiceRegistry.d.ts +50 -0
- package/dist/di/ServiceRegistry.d.ts.map +1 -0
- package/dist/di/ServiceRegistry.js +1 -0
- package/dist/errors.d.ts +663 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +282 -0
- package/dist/errors.js.map +1 -0
- package/dist/health/HealthChecker.d.ts +73 -0
- package/dist/health/HealthChecker.d.ts.map +1 -0
- package/dist/health/HealthChecker.js +70 -0
- package/dist/health/HealthChecker.js.map +1 -0
- package/dist/lib.d.ts +273 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +409 -0
- package/dist/lib.js.map +1 -0
- package/dist/logger/NullLogger.d.ts +154 -0
- package/dist/logger/NullLogger.d.ts.map +1 -0
- package/dist/logger/NullLogger.js +24 -0
- package/dist/logger/NullLogger.js.map +1 -0
- package/dist/logger/StructuredLogger.d.ts +327 -0
- package/dist/logger/StructuredLogger.d.ts.map +1 -0
- package/dist/logger/StructuredLogger.js +72 -0
- package/dist/logger/StructuredLogger.js.map +1 -0
- package/dist/metrics/metrics.impl.d.ts +252 -0
- package/dist/metrics/metrics.impl.d.ts.map +1 -0
- package/dist/metrics/metrics.impl.js +197 -0
- package/dist/metrics/metrics.impl.js.map +1 -0
- package/dist/persistence/FileLegacyImport.d.ts +2 -0
- package/dist/persistence/FileLegacyImport.d.ts.map +1 -0
- package/dist/persistence/FileLegacyImport.js +183 -0
- package/dist/persistence/FileLegacyImport.js.map +1 -0
- package/dist/persistence/FilePersistence.d.ts +53 -0
- package/dist/persistence/FilePersistence.d.ts.map +1 -0
- package/dist/persistence/FilePersistence.js +312 -0
- package/dist/persistence/FilePersistence.js.map +1 -0
- package/dist/persistence/FileSnapshotTypes.d.ts +29 -0
- package/dist/persistence/FileSnapshotTypes.d.ts.map +1 -0
- package/dist/persistence/FileSnapshotTypes.js +1 -0
- package/dist/persistence/FileSnapshotV2.d.ts +377 -0
- package/dist/persistence/FileSnapshotV2.d.ts.map +1 -0
- package/dist/persistence/FileSnapshotV2.js +124 -0
- package/dist/persistence/FileSnapshotV2.js.map +1 -0
- package/dist/persistence/FileSnapshotValidation.d.ts +15 -0
- package/dist/persistence/FileSnapshotValidation.d.ts.map +1 -0
- package/dist/persistence/FileSnapshotValidation.js +64 -0
- package/dist/persistence/FileSnapshotValidation.js.map +1 -0
- package/dist/persistence/FileWriter.d.ts +30 -0
- package/dist/persistence/FileWriter.d.ts.map +1 -0
- package/dist/persistence/FileWriter.js +155 -0
- package/dist/persistence/FileWriter.js.map +1 -0
- package/dist/persistence/MemoryPersistence.d.ts +45 -0
- package/dist/persistence/MemoryPersistence.d.ts.map +1 -0
- package/dist/persistence/MemoryPersistence.js +180 -0
- package/dist/persistence/MemoryPersistence.js.map +1 -0
- package/dist/persistence/PersistenceCodec.d.ts +7 -0
- package/dist/persistence/PersistenceCodec.d.ts.map +1 -0
- package/dist/persistence/PersistenceCodec.js +97 -0
- package/dist/persistence/PersistenceCodec.js.map +1 -0
- package/dist/persistence/PersistenceErrors.d.ts +23 -0
- package/dist/persistence/PersistenceErrors.d.ts.map +1 -0
- package/dist/persistence/PersistenceErrors.js +26 -0
- package/dist/persistence/PersistenceErrors.js.map +1 -0
- package/dist/persistence/PersistenceFactory.d.ts +21 -0
- package/dist/persistence/PersistenceFactory.d.ts.map +1 -0
- package/dist/persistence/PersistenceFactory.js +28 -0
- package/dist/persistence/PersistenceFactory.js.map +1 -0
- package/dist/persistence/PersistenceScope.d.ts +42 -0
- package/dist/persistence/PersistenceScope.d.ts.map +1 -0
- package/dist/persistence/PersistenceScope.js +93 -0
- package/dist/persistence/PersistenceScope.js.map +1 -0
- package/dist/persistence/SessionScopedPersistence.d.ts +4 -0
- package/dist/persistence/SessionScopedPersistence.d.ts.map +1 -0
- package/dist/persistence/SessionScopedPersistence.js +9 -0
- package/dist/persistence/SessionScopedPersistence.js.map +1 -0
- package/dist/persistence/SqliteDriver.d.ts +22 -0
- package/dist/persistence/SqliteDriver.d.ts.map +1 -0
- package/dist/persistence/SqliteDriver.js +29 -0
- package/dist/persistence/SqliteDriver.js.map +1 -0
- package/dist/persistence/SqliteLegacyImport.d.ts +14 -0
- package/dist/persistence/SqliteLegacyImport.d.ts.map +1 -0
- package/dist/persistence/SqliteLegacyImport.js +136 -0
- package/dist/persistence/SqliteLegacyImport.js.map +1 -0
- package/dist/persistence/SqliteLegacySchema.d.ts +15 -0
- package/dist/persistence/SqliteLegacySchema.d.ts.map +1 -0
- package/dist/persistence/SqliteLegacySchema.js +72 -0
- package/dist/persistence/SqliteLegacySchema.js.map +1 -0
- package/dist/persistence/SqlitePayload.d.ts +11 -0
- package/dist/persistence/SqlitePayload.d.ts.map +1 -0
- package/dist/persistence/SqlitePayload.js +86 -0
- package/dist/persistence/SqlitePayload.js.map +1 -0
- package/dist/persistence/SqlitePersistence.d.ts +49 -0
- package/dist/persistence/SqlitePersistence.d.ts.map +1 -0
- package/dist/persistence/SqlitePersistence.js +248 -0
- package/dist/persistence/SqlitePersistence.js.map +1 -0
- package/dist/persistence/SqliteSchemaV2.d.ts +14 -0
- package/dist/persistence/SqliteSchemaV2.d.ts.map +1 -0
- package/dist/persistence/SqliteSchemaV2.js +129 -0
- package/dist/persistence/SqliteSchemaV2.js.map +1 -0
- package/dist/persistence/SqliteSnapshotWriter.d.ts +17 -0
- package/dist/persistence/SqliteSnapshotWriter.d.ts.map +1 -0
- package/dist/persistence/SqliteSnapshotWriter.js +30 -0
- package/dist/persistence/SqliteSnapshotWriter.js.map +1 -0
- package/dist/pool/ConnectionPool.d.ts +203 -0
- package/dist/pool/ConnectionPool.d.ts.map +1 -0
- package/dist/pool/ConnectionPool.js +303 -0
- package/dist/pool/ConnectionPool.js.map +1 -0
- package/dist/pool/IConnectionPool.d.ts +143 -0
- package/dist/pool/IConnectionPool.d.ts.map +1 -0
- package/dist/pool/IConnectionPool.js +1 -0
- package/dist/pool/PoolErrors.d.ts +11 -0
- package/dist/pool/PoolErrors.d.ts.map +1 -0
- package/dist/pool/PoolErrors.js +16 -0
- package/dist/pool/PoolErrors.js.map +1 -0
- package/dist/registry/BaseRegistry.d.ts +219 -0
- package/dist/registry/BaseRegistry.d.ts.map +1 -0
- package/dist/registry/BaseRegistry.js +215 -0
- package/dist/registry/BaseRegistry.js.map +1 -0
- package/dist/registry/SkillRegistry.d.ts +67 -0
- package/dist/registry/SkillRegistry.d.ts.map +1 -0
- package/dist/registry/SkillRegistry.js +87 -0
- package/dist/registry/SkillRegistry.js.map +1 -0
- package/dist/registry/ToolRegistry.d.ts +70 -0
- package/dist/registry/ToolRegistry.d.ts.map +1 -0
- package/dist/registry/ToolRegistry.js +96 -0
- package/dist/registry/ToolRegistry.js.map +1 -0
- package/dist/sanitize.d.ts +164 -0
- package/dist/sanitize.d.ts.map +1 -0
- package/dist/sanitize.js +100 -0
- package/dist/sanitize.js.map +1 -0
- package/dist/schema.d.ts +562 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +251 -0
- package/dist/schema.js.map +1 -0
- package/dist/transport/BaseTransport.d.ts +166 -0
- package/dist/transport/BaseTransport.d.ts.map +1 -0
- package/dist/transport/BaseTransport.js +199 -0
- package/dist/transport/BaseTransport.js.map +1 -0
- package/dist/transport/HttpHelpers.d.ts +53 -0
- package/dist/transport/HttpHelpers.d.ts.map +1 -0
- package/dist/transport/HttpHelpers.js +44 -0
- package/dist/transport/HttpHelpers.js.map +1 -0
- package/dist/transport/HttpRequestLifecycle.d.ts +37 -0
- package/dist/transport/HttpRequestLifecycle.d.ts.map +1 -0
- package/dist/transport/HttpRequestLifecycle.js +87 -0
- package/dist/transport/HttpRequestLifecycle.js.map +1 -0
- package/dist/transport/HttpTransport.d.ts +140 -0
- package/dist/transport/HttpTransport.d.ts.map +1 -0
- package/dist/transport/HttpTransport.js +245 -0
- package/dist/transport/HttpTransport.js.map +1 -0
- package/dist/transport/SseTransport.d.ts +149 -0
- package/dist/transport/SseTransport.d.ts.map +1 -0
- package/dist/transport/SseTransport.js +470 -0
- package/dist/transport/SseTransport.js.map +1 -0
- package/dist/transport/StreamableHttpTransport.d.ts +225 -0
- package/dist/transport/StreamableHttpTransport.d.ts.map +1 -0
- package/dist/transport/StreamableHttpTransport.js +449 -0
- package/dist/transport/StreamableHttpTransport.js.map +1 -0
- package/dist/types/disposable.d.ts +22 -0
- package/dist/types/disposable.d.ts.map +1 -0
- package/dist/types/disposable.js +1 -0
- package/dist/types/server-config.d.ts +32 -0
- package/dist/types/server-config.d.ts.map +1 -0
- package/dist/types/server-config.js +1 -0
- package/dist/types/skill.d.ts +74 -0
- package/dist/types/skill.d.ts.map +1 -0
- package/dist/types/skill.js +1 -0
- package/dist/types/tool.d.ts +78 -0
- package/dist/types/tool.d.ts.map +1 -0
- package/dist/types/tool.js +1 -0
- package/dist/utils.d.ts +27 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +6 -0
- package/dist/utils.js.map +1 -0
- package/dist/watchers/SkillWatcher.d.ts +25 -0
- package/dist/watchers/SkillWatcher.d.ts.map +1 -0
- package/dist/watchers/SkillWatcher.js +96 -0
- package/dist/watchers/SkillWatcher.js.map +1 -0
- package/dist/watchers/ToolWatcher.d.ts +24 -0
- package/dist/watchers/ToolWatcher.d.ts.map +1 -0
- package/dist/watchers/ToolWatcher.js +92 -0
- package/dist/watchers/ToolWatcher.js.map +1 -0
- package/package.json +106 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for the connection pool managing concurrent user sessions.
|
|
3
|
+
*
|
|
4
|
+
* This module provides the `IConnectionPool` interface which defines the
|
|
5
|
+
* contract for connection pool implementations. This allows for decoupling
|
|
6
|
+
* and testability for multi-user transports.
|
|
7
|
+
*
|
|
8
|
+
* @module IConnectionPool
|
|
9
|
+
*/
|
|
10
|
+
import type { InferInput } from 'valibot';
|
|
11
|
+
import type { SessionId } from '../contracts/ids.js';
|
|
12
|
+
import type { SequentialThinkingSchema } from '../schema.js';
|
|
13
|
+
import type { IDisposable } from '../types/disposable.js';
|
|
14
|
+
export type SessionThoughtInput = InferInput<typeof SequentialThinkingSchema>;
|
|
15
|
+
/**
|
|
16
|
+
* Represents a content block in a process result.
|
|
17
|
+
*/
|
|
18
|
+
export type ContentBlock = {
|
|
19
|
+
type: 'text';
|
|
20
|
+
text: string;
|
|
21
|
+
};
|
|
22
|
+
export interface ProcessResult {
|
|
23
|
+
content: ContentBlock[];
|
|
24
|
+
isError?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface SessionServer {
|
|
27
|
+
processThought(input: SessionThoughtInput): Promise<ProcessResult>;
|
|
28
|
+
stop(): void | Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export interface SessionInfo {
|
|
31
|
+
id: SessionId;
|
|
32
|
+
server: SessionServer;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
lastActivityAt: number;
|
|
35
|
+
isActive: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Result of running callback-scoped work against a pooled session.
|
|
39
|
+
*/
|
|
40
|
+
export type SessionRunResult<T> = {
|
|
41
|
+
readonly status: 'completed';
|
|
42
|
+
readonly value: T;
|
|
43
|
+
} | {
|
|
44
|
+
readonly status: 'inactive';
|
|
45
|
+
} | {
|
|
46
|
+
readonly status: 'missing';
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Statistics describing the current state of the connection pool.
|
|
50
|
+
*/
|
|
51
|
+
export interface ConnectionPoolStats {
|
|
52
|
+
totalSessions: number;
|
|
53
|
+
activeSessions: number;
|
|
54
|
+
maxSessions: number;
|
|
55
|
+
cleanupEnabled: boolean;
|
|
56
|
+
sessionTimeout: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Interface for the connection pool.
|
|
60
|
+
*
|
|
61
|
+
* This interface defines the contract for managing multiple concurrent
|
|
62
|
+
* user sessions, each with its own isolated server instance. Supports
|
|
63
|
+
* dependency injection and mocking for testing purposes.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* class MockPool implements IConnectionPool {
|
|
68
|
+
* async createSession(): Promise<string> { return 'mock'; }
|
|
69
|
+
* // ...
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export interface IConnectionPool extends IDisposable {
|
|
74
|
+
/**
|
|
75
|
+
* Create a new session.
|
|
76
|
+
*
|
|
77
|
+
* @returns The new session ID
|
|
78
|
+
* @throws PoolTerminatedError if the pool has been terminated
|
|
79
|
+
* @throws MaxSessionsReachedError if the maximum number of sessions is reached
|
|
80
|
+
*/
|
|
81
|
+
createSession(): Promise<SessionId>;
|
|
82
|
+
/**
|
|
83
|
+
* Process a thought in the specified session.
|
|
84
|
+
*
|
|
85
|
+
* @param sessionId - The session ID
|
|
86
|
+
* @param input - The thought data to process
|
|
87
|
+
* @returns The processing result
|
|
88
|
+
* @throws SessionNotFoundError if the session does not exist
|
|
89
|
+
*/
|
|
90
|
+
process(sessionId: SessionId, input: SessionThoughtInput): Promise<ProcessResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Run an operation while atomically holding an active session open.
|
|
93
|
+
*
|
|
94
|
+
* @param sessionId - The session ID
|
|
95
|
+
* @param operation - Callback that receives the admitted child server
|
|
96
|
+
* @returns The callback value or an explicit unavailable status
|
|
97
|
+
*/
|
|
98
|
+
runWithSession<T>(sessionId: SessionId, operation: (session: SessionServer) => Promise<T>): Promise<SessionRunResult<T>>;
|
|
99
|
+
/**
|
|
100
|
+
* Close a session and release its resources.
|
|
101
|
+
*
|
|
102
|
+
* @param sessionId - The session ID to close
|
|
103
|
+
* @throws SessionNotFoundError if the session does not exist
|
|
104
|
+
*/
|
|
105
|
+
closeSession(sessionId: SessionId): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Get information about a session.
|
|
108
|
+
*
|
|
109
|
+
* @param sessionId - The session ID
|
|
110
|
+
* @returns Session info, or undefined if not found
|
|
111
|
+
*/
|
|
112
|
+
getSessionInfo(sessionId: SessionId): SessionInfo | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Get all active sessions.
|
|
115
|
+
*
|
|
116
|
+
* @returns Array of session information for currently active sessions
|
|
117
|
+
*/
|
|
118
|
+
getActiveSessions(): SessionInfo[];
|
|
119
|
+
/**
|
|
120
|
+
* Get connection pool statistics.
|
|
121
|
+
*
|
|
122
|
+
* @returns A snapshot of the pool's statistics
|
|
123
|
+
*/
|
|
124
|
+
getStats(): ConnectionPoolStats;
|
|
125
|
+
/**
|
|
126
|
+
* Close all sessions and stop the cleanup timer.
|
|
127
|
+
*/
|
|
128
|
+
terminate(): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Dispose of the connection pool, releasing all resources.
|
|
131
|
+
*
|
|
132
|
+
* Implements the {@link IDisposable} interface. Typically delegates
|
|
133
|
+
* to {@link IConnectionPool.terminate}.
|
|
134
|
+
*/
|
|
135
|
+
dispose(): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Check if the connection pool is active (not terminated).
|
|
138
|
+
*
|
|
139
|
+
* @returns true if the pool is still running
|
|
140
|
+
*/
|
|
141
|
+
isRunning(): boolean;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=IConnectionPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
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} from '../errors.js';
|
|
3
|
+
/** Error thrown when attempting to process a session that is not active. */
|
|
4
|
+
export declare class SessionNotActiveError extends SequentialThinkingError {
|
|
5
|
+
constructor(sessionId: SessionId);
|
|
6
|
+
}
|
|
7
|
+
/** Error thrown when a requested session is not found in the pool. */
|
|
8
|
+
export declare class SessionNotFoundError extends SequentialThinkingError {
|
|
9
|
+
constructor(sessionId: SessionId);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=PoolErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PoolErrors.d.ts","sourceRoot":"","sources":["../../src/pool/PoolErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAe,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEpE,4EAA4E;AAC5E,qBAAa,qBAAsB,SAAQ,uBAAuB;gBACrD,SAAS,EAAE,SAAS;CAIhC;AAED,sEAAsE;AACtE,qBAAa,oBAAqB,SAAQ,uBAAuB;gBACpD,SAAS,EAAE,SAAS;CAIhC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ERROR_CODES, SequentialThinkingError } from "../errors.js";
|
|
2
|
+
class SessionNotActiveError extends SequentialThinkingError {
|
|
3
|
+
constructor(sessionId){
|
|
4
|
+
super(`Session '${sessionId}' is not active`, ERROR_CODES.SESSION_NOT_ACTIVE);
|
|
5
|
+
this.name = 'SessionNotActiveError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
class SessionNotFoundError extends SequentialThinkingError {
|
|
9
|
+
constructor(sessionId){
|
|
10
|
+
super(`Session not found: ${sessionId}`, ERROR_CODES.SESSION_NOT_FOUND);
|
|
11
|
+
this.name = 'SessionNotFoundError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export { SessionNotActiveError, SessionNotFoundError };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=PoolErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool/PoolErrors.js","sources":["../../src/pool/PoolErrors.ts"],"sourcesContent":["import type { SessionId } from '../contracts/ids.js';\nimport { ERROR_CODES, SequentialThinkingError } from '../errors.js';\n\n/** Error thrown when attempting to process a session that is not active. */\nexport class SessionNotActiveError extends SequentialThinkingError {\n\tconstructor(sessionId: SessionId) {\n\t\tsuper(`Session '${sessionId}' is not active`, ERROR_CODES.SESSION_NOT_ACTIVE);\n\t\tthis.name = 'SessionNotActiveError';\n\t}\n}\n\n/** Error thrown when a requested session is not found in the pool. */\nexport class SessionNotFoundError extends SequentialThinkingError {\n\tconstructor(sessionId: SessionId) {\n\t\tsuper(`Session not found: ${sessionId}`, ERROR_CODES.SESSION_NOT_FOUND);\n\t\tthis.name = 'SessionNotFoundError';\n\t}\n}\n"],"names":["SessionNotActiveError","SequentialThinkingError","sessionId","ERROR_CODES","SessionNotFoundError"],"mappings":";AAIO,MAAMA,8BAA8BC;IAC1C,YAAYC,SAAoB,CAAE;QACjC,KAAK,CAAC,CAAC,SAAS,EAAEA,UAAU,eAAe,CAAC,EAAEC,YAAY,kBAAkB;QAC5E,IAAI,CAAC,IAAI,GAAG;IACb;AACD;AAGO,MAAMC,6BAA6BH;IACzC,YAAYC,SAAoB,CAAE;QACjC,KAAK,CAAC,CAAC,mBAAmB,EAAEA,WAAW,EAAEC,YAAY,iBAAiB;QACtE,IAAI,CAAC,IAAI,GAAG;IACb;AACD"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base registry providing shared CRUD, caching, and discovery logic.
|
|
3
|
+
*
|
|
4
|
+
* This abstract generic class extracts the common patterns from `ToolRegistry`
|
|
5
|
+
* and `SkillRegistry` into a single reusable base. Subclasses only need to
|
|
6
|
+
* implement item-specific parsing, file filtering, and error construction.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The registry item type (must have a `name` property)
|
|
9
|
+
* @module registry
|
|
10
|
+
*/
|
|
11
|
+
import { DiscoveryCache } from '../cache/DiscoveryCache.js';
|
|
12
|
+
import type { Logger } from '../logger/StructuredLogger.js';
|
|
13
|
+
/**
|
|
14
|
+
* Configuration options for creating a `BaseRegistry` instance.
|
|
15
|
+
*/
|
|
16
|
+
export interface BaseRegistryOptions {
|
|
17
|
+
/** Optional logger for diagnostics. */
|
|
18
|
+
logger?: Logger;
|
|
19
|
+
/** Optional cache for lookups. */
|
|
20
|
+
cache?: DiscoveryCache<{
|
|
21
|
+
name: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Directory paths to search for items.
|
|
25
|
+
*/
|
|
26
|
+
searchDirs?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Enable lazy discovery (discover on first access instead of startup).
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
lazyDiscovery?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Abstract base registry for managing named items with discovery and caching.
|
|
35
|
+
*
|
|
36
|
+
* Provides shared CRUD operations, filesystem discovery with deduplication,
|
|
37
|
+
* and optional LRU caching. Subclasses implement item-specific parsing logic
|
|
38
|
+
* and error construction.
|
|
39
|
+
*
|
|
40
|
+
* @template T - The registry item type (must have a `name` property)
|
|
41
|
+
*/
|
|
42
|
+
export declare abstract class BaseRegistry<T extends {
|
|
43
|
+
name: string;
|
|
44
|
+
}> {
|
|
45
|
+
/** Internal storage for items indexed by name. */
|
|
46
|
+
protected _items: Map<string, T>;
|
|
47
|
+
private _manualItems;
|
|
48
|
+
private _discoveredItemsByPath;
|
|
49
|
+
/** Logger for diagnostics. */
|
|
50
|
+
protected _logger: Logger;
|
|
51
|
+
/** Optional cache for lookups. */
|
|
52
|
+
protected _cache: DiscoveryCache<T>;
|
|
53
|
+
/** Directory paths to search for items. */
|
|
54
|
+
protected _searchDirs: string[];
|
|
55
|
+
/** Whether discovery has been performed. */
|
|
56
|
+
protected _discovered: boolean;
|
|
57
|
+
/** Promise for in-progress discovery (null if not in progress). */
|
|
58
|
+
protected _discoveryPromise: Promise<number> | null;
|
|
59
|
+
private _refreshRequested;
|
|
60
|
+
/** File extensions to match during discovery. */
|
|
61
|
+
protected abstract readonly _fileExtensions: string[];
|
|
62
|
+
/**
|
|
63
|
+
* Creates an error for invalid item data.
|
|
64
|
+
* @param reason - The reason for the validation failure
|
|
65
|
+
*/
|
|
66
|
+
protected abstract _createInvalidError(reason: string): Error;
|
|
67
|
+
/**
|
|
68
|
+
* Creates an error for duplicate items.
|
|
69
|
+
* @param name - The name of the duplicate item
|
|
70
|
+
*/
|
|
71
|
+
protected abstract _createDuplicateError(name: string): Error;
|
|
72
|
+
/**
|
|
73
|
+
* Creates an error for items not found.
|
|
74
|
+
* @param name - The name of the missing item
|
|
75
|
+
* @param action - The action that was attempted
|
|
76
|
+
*/
|
|
77
|
+
protected abstract _createNotFoundError(name: string, action: string): Error;
|
|
78
|
+
/**
|
|
79
|
+
* Parses frontmatter content into a partial item.
|
|
80
|
+
* @param content - The file content to parse
|
|
81
|
+
* @returns A partial item, with an `_error` property if parsing failed
|
|
82
|
+
*/
|
|
83
|
+
protected abstract _parseFrontmatter(content: string): Partial<T> & {
|
|
84
|
+
_error?: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Determines whether a file should be skipped during discovery.
|
|
88
|
+
* @param fileName - The name of the file to check
|
|
89
|
+
* @returns true if the file should be skipped
|
|
90
|
+
*/
|
|
91
|
+
protected abstract _shouldSkipFile(fileName: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Constructs a complete item from parsed frontmatter data.
|
|
94
|
+
* Returns null if the parsed data is insufficient.
|
|
95
|
+
* @param parsed - The parsed frontmatter data
|
|
96
|
+
* @returns A complete item, or null if data is insufficient
|
|
97
|
+
*/
|
|
98
|
+
protected abstract _buildItem(parsed: Partial<T>): T | null;
|
|
99
|
+
/**
|
|
100
|
+
* The entity name used in log messages (e.g., 'tool', 'skill').
|
|
101
|
+
*/
|
|
102
|
+
protected abstract readonly _entityName: string;
|
|
103
|
+
constructor(options: BaseRegistryOptions);
|
|
104
|
+
/**
|
|
105
|
+
* Internal logging method.
|
|
106
|
+
* @param message - The message to log
|
|
107
|
+
* @param meta - Optional metadata
|
|
108
|
+
*/
|
|
109
|
+
protected log(message: string, meta?: Record<string, unknown>): void;
|
|
110
|
+
/**
|
|
111
|
+
* Adds an item to the registry.
|
|
112
|
+
*
|
|
113
|
+
* @param item - The item to add
|
|
114
|
+
* @throws If item already exists or name is invalid
|
|
115
|
+
*/
|
|
116
|
+
add(item: T): void;
|
|
117
|
+
/**
|
|
118
|
+
* Removes an item from the registry.
|
|
119
|
+
*
|
|
120
|
+
* @param name - The name of the item to remove
|
|
121
|
+
* @throws If item not found
|
|
122
|
+
*/
|
|
123
|
+
remove(name: string): void;
|
|
124
|
+
/**
|
|
125
|
+
* Updates an existing item with partial data.
|
|
126
|
+
*
|
|
127
|
+
* @param name - The name of the item to update
|
|
128
|
+
* @param updates - Partial item data with fields to update
|
|
129
|
+
* @throws If item not found
|
|
130
|
+
*/
|
|
131
|
+
update(name: string, updates: Partial<T>): void;
|
|
132
|
+
/**
|
|
133
|
+
* Gets an item by name.
|
|
134
|
+
*
|
|
135
|
+
* @param name - The name of the item to get
|
|
136
|
+
* @returns The item if found, undefined otherwise
|
|
137
|
+
*/
|
|
138
|
+
get(name: string): T | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* Gets all items as an array.
|
|
141
|
+
*
|
|
142
|
+
* Uses cache if available for performance.
|
|
143
|
+
*
|
|
144
|
+
* @returns An array of all registered items
|
|
145
|
+
*/
|
|
146
|
+
getAll(): T[];
|
|
147
|
+
/**
|
|
148
|
+
* Checks if an item exists in the registry.
|
|
149
|
+
*
|
|
150
|
+
* @param name - The name of the item to check
|
|
151
|
+
* @returns true if the item exists, false otherwise
|
|
152
|
+
*/
|
|
153
|
+
has(name: string): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Gets all item names as an array.
|
|
156
|
+
*
|
|
157
|
+
* @returns An array of item names
|
|
158
|
+
*/
|
|
159
|
+
getNames(): string[];
|
|
160
|
+
/**
|
|
161
|
+
* Clears all items from the registry.
|
|
162
|
+
*/
|
|
163
|
+
clear(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Gets the number of items in the registry.
|
|
166
|
+
*
|
|
167
|
+
* @returns The count of registered items
|
|
168
|
+
*/
|
|
169
|
+
size(): number;
|
|
170
|
+
/**
|
|
171
|
+
* Asynchronously discovers items from the configured directories.
|
|
172
|
+
*
|
|
173
|
+
* Multiple concurrent calls share the same discovery promise.
|
|
174
|
+
* Subsequent calls return cached results if discovery has already completed.
|
|
175
|
+
*
|
|
176
|
+
* @returns A Promise resolving to the number of items discovered
|
|
177
|
+
*/
|
|
178
|
+
discoverAsync(): Promise<number>;
|
|
179
|
+
/**
|
|
180
|
+
* Re-scans configured directories and atomically reconciles discovered items.
|
|
181
|
+
*
|
|
182
|
+
* Calls made during an active scan share its promise and request at most one
|
|
183
|
+
* follow-up pass, ensuring an event that arrives mid-scan is not lost.
|
|
184
|
+
*
|
|
185
|
+
* @returns A Promise resolving to the number of discovered filesystem items
|
|
186
|
+
*/
|
|
187
|
+
refreshAsync(): Promise<number>;
|
|
188
|
+
private _beginDiscovery;
|
|
189
|
+
private _runDiscoveryLoop;
|
|
190
|
+
/**
|
|
191
|
+
* Performs the actual discovery operation.
|
|
192
|
+
*
|
|
193
|
+
* Scans configured directories for item files, parses their frontmatter,
|
|
194
|
+
* and adds valid items to the registry.
|
|
195
|
+
*
|
|
196
|
+
* @returns A Promise resolving to the number of items discovered
|
|
197
|
+
*/
|
|
198
|
+
protected _performDiscovery(): Promise<number>;
|
|
199
|
+
private _retainLastKnownGood;
|
|
200
|
+
private _retainDirectory;
|
|
201
|
+
/**
|
|
202
|
+
* Parses YAML frontmatter from file content.
|
|
203
|
+
*
|
|
204
|
+
* This is a shared utility for subclasses that parse YAML frontmatter.
|
|
205
|
+
*
|
|
206
|
+
* @param content - The file content to parse
|
|
207
|
+
* @returns The parsed YAML object, or null if no frontmatter found
|
|
208
|
+
*/
|
|
209
|
+
protected _extractFrontmatter(content: string): Record<string, unknown> | null;
|
|
210
|
+
/**
|
|
211
|
+
* Sets items from an external source.
|
|
212
|
+
*
|
|
213
|
+
* Clears existing items and adds new ones from the provided array.
|
|
214
|
+
*
|
|
215
|
+
* @param items - Array of items from an external source
|
|
216
|
+
*/
|
|
217
|
+
setAll(items: T[]): void;
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=BaseRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseRegistry.d.ts","sourceRoot":"","sources":["../../src/registry/BaseRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAG5D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,kCAAkC;IAClC,KAAK,CAAC,EAAE,cAAc,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEzC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,8BAAsB,YAAY,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;IAC5D,kDAAkD;IAClD,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACjC,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,sBAAsB,CAAiB;IAE/C,8BAA8B;IAC9B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAE1B,kCAAkC;IA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"node:path";
|
|
4
|
+
import { parse } from "yaml";
|
|
5
|
+
import { DiscoveryCache } from "../cache/DiscoveryCache.js";
|
|
6
|
+
import { NullLogger } from "../logger/NullLogger.js";
|
|
7
|
+
import { getErrorMessage } from "../errors.js";
|
|
8
|
+
class BaseRegistry {
|
|
9
|
+
_items;
|
|
10
|
+
_manualItems;
|
|
11
|
+
_discoveredItemsByPath;
|
|
12
|
+
_logger;
|
|
13
|
+
_cache;
|
|
14
|
+
_searchDirs;
|
|
15
|
+
_discovered = false;
|
|
16
|
+
_discoveryPromise = null;
|
|
17
|
+
_refreshRequested = false;
|
|
18
|
+
constructor(options){
|
|
19
|
+
this._items = new Map();
|
|
20
|
+
this._manualItems = new Map();
|
|
21
|
+
this._discoveredItemsByPath = new Map();
|
|
22
|
+
this._logger = options.logger ?? new NullLogger();
|
|
23
|
+
this._cache = options.cache || new DiscoveryCache({
|
|
24
|
+
maxSize: 50,
|
|
25
|
+
ttl: 300000
|
|
26
|
+
});
|
|
27
|
+
this._searchDirs = options.searchDirs ?? [];
|
|
28
|
+
}
|
|
29
|
+
log(message, meta) {
|
|
30
|
+
this._logger.info(message, meta);
|
|
31
|
+
}
|
|
32
|
+
add(item) {
|
|
33
|
+
if (!item.name) throw this._createInvalidError(`${this._entityName} must have a valid name`);
|
|
34
|
+
if (this._items.has(item.name)) throw this._createDuplicateError(item.name);
|
|
35
|
+
this._items.set(item.name, item);
|
|
36
|
+
this._manualItems.set(item.name, item);
|
|
37
|
+
this.log(`Added ${this._entityName}: ${item.name}`, {
|
|
38
|
+
[`${this._entityName}Name`]: item.name
|
|
39
|
+
});
|
|
40
|
+
this._cache?.invalidate('all');
|
|
41
|
+
}
|
|
42
|
+
remove(name) {
|
|
43
|
+
if (!this._items.has(name)) throw this._createNotFoundError(name, 'remove');
|
|
44
|
+
this._items.delete(name);
|
|
45
|
+
this._manualItems.delete(name);
|
|
46
|
+
for (const [filePath, item] of this._discoveredItemsByPath)if (item.name === name) this._discoveredItemsByPath.delete(filePath);
|
|
47
|
+
this.log(`Removed ${this._entityName}: ${name}`, {
|
|
48
|
+
[`${this._entityName}Name`]: name
|
|
49
|
+
});
|
|
50
|
+
this._cache?.invalidate('all');
|
|
51
|
+
this._cache?.invalidate(name);
|
|
52
|
+
}
|
|
53
|
+
update(name, updates) {
|
|
54
|
+
if (!this._items.has(name)) throw this._createNotFoundError(name, 'update');
|
|
55
|
+
const existing = this._items.get(name);
|
|
56
|
+
const updated = {
|
|
57
|
+
...existing,
|
|
58
|
+
...updates
|
|
59
|
+
};
|
|
60
|
+
this._items.set(name, updated);
|
|
61
|
+
if (this._manualItems.has(name)) this._manualItems.set(name, updated);
|
|
62
|
+
for (const [filePath, item] of this._discoveredItemsByPath)if (item.name === name) this._discoveredItemsByPath.set(filePath, updated);
|
|
63
|
+
this.log(`Updated ${this._entityName}: ${name}`, {
|
|
64
|
+
[`${this._entityName}Name`]: name
|
|
65
|
+
});
|
|
66
|
+
this._cache?.invalidate('all');
|
|
67
|
+
this._cache?.invalidate(name);
|
|
68
|
+
}
|
|
69
|
+
get(name) {
|
|
70
|
+
return this._items.get(name);
|
|
71
|
+
}
|
|
72
|
+
getAll() {
|
|
73
|
+
if (this._cache) {
|
|
74
|
+
const cached = this._cache.get('all');
|
|
75
|
+
if (cached) return cached;
|
|
76
|
+
}
|
|
77
|
+
const items = Array.from(this._items.values());
|
|
78
|
+
this._cache?.set('all', items);
|
|
79
|
+
return items;
|
|
80
|
+
}
|
|
81
|
+
has(name) {
|
|
82
|
+
return this._items.has(name);
|
|
83
|
+
}
|
|
84
|
+
getNames() {
|
|
85
|
+
return Array.from(this._items.keys());
|
|
86
|
+
}
|
|
87
|
+
clear() {
|
|
88
|
+
this._items.clear();
|
|
89
|
+
this._manualItems.clear();
|
|
90
|
+
this._discoveredItemsByPath.clear();
|
|
91
|
+
this.log(`Cleared all ${this._entityName}s`);
|
|
92
|
+
this._cache?.clear();
|
|
93
|
+
}
|
|
94
|
+
size() {
|
|
95
|
+
return this._items.size;
|
|
96
|
+
}
|
|
97
|
+
async discoverAsync() {
|
|
98
|
+
if (this._discoveryPromise) return this._discoveryPromise;
|
|
99
|
+
if (this._discovered) {
|
|
100
|
+
const cached = this._cache.get('all');
|
|
101
|
+
return cached?.length ?? 0;
|
|
102
|
+
}
|
|
103
|
+
return this._beginDiscovery();
|
|
104
|
+
}
|
|
105
|
+
async refreshAsync() {
|
|
106
|
+
this._refreshRequested = true;
|
|
107
|
+
return this._discoveryPromise ?? this._beginDiscovery();
|
|
108
|
+
}
|
|
109
|
+
_beginDiscovery() {
|
|
110
|
+
const operation = this._runDiscoveryLoop();
|
|
111
|
+
this._discoveryPromise = operation;
|
|
112
|
+
const clearOperation = ()=>{
|
|
113
|
+
if (this._discoveryPromise === operation) this._discoveryPromise = null;
|
|
114
|
+
};
|
|
115
|
+
operation.then(clearOperation, clearOperation);
|
|
116
|
+
return operation;
|
|
117
|
+
}
|
|
118
|
+
async _runDiscoveryLoop() {
|
|
119
|
+
this._refreshRequested = false;
|
|
120
|
+
let count = await this._performDiscovery();
|
|
121
|
+
while(this._refreshRequested){
|
|
122
|
+
this._refreshRequested = false;
|
|
123
|
+
count = await this._performDiscovery();
|
|
124
|
+
}
|
|
125
|
+
return count;
|
|
126
|
+
}
|
|
127
|
+
async _performDiscovery() {
|
|
128
|
+
const discoveredItems = new Map();
|
|
129
|
+
const claimedNames = new Set(this._manualItems.keys());
|
|
130
|
+
for (const dir of this._searchDirs)try {
|
|
131
|
+
if (!existsSync(dir)) continue;
|
|
132
|
+
const entries = await readdir(dir, {
|
|
133
|
+
withFileTypes: true
|
|
134
|
+
});
|
|
135
|
+
for (const entry of entries)if (!this._shouldSkipFile(entry.name)) {
|
|
136
|
+
if (entry.isFile() && this._fileExtensions.some((ext)=>entry.name.endsWith(ext))) {
|
|
137
|
+
const filePath = join(dir, entry.name);
|
|
138
|
+
try {
|
|
139
|
+
const content = await readFile(filePath, 'utf-8');
|
|
140
|
+
const parsed = this._parseFrontmatter(content);
|
|
141
|
+
if (parsed._error) {
|
|
142
|
+
this._retainLastKnownGood(filePath, parsed._error, discoveredItems, claimedNames);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (parsed.name) {
|
|
146
|
+
const item = this._buildItem(parsed);
|
|
147
|
+
if (item && !claimedNames.has(item.name)) {
|
|
148
|
+
discoveredItems.set(filePath, item);
|
|
149
|
+
claimedNames.add(item.name);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} catch (readError) {
|
|
153
|
+
this._retainLastKnownGood(filePath, getErrorMessage(readError), discoveredItems, claimedNames);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
} catch (error) {
|
|
158
|
+
this._logger.warn(`Failed to scan ${this._entityName} directory`, {
|
|
159
|
+
directory: dir,
|
|
160
|
+
error: getErrorMessage(error)
|
|
161
|
+
});
|
|
162
|
+
this._retainDirectory(dir, discoveredItems, claimedNames);
|
|
163
|
+
}
|
|
164
|
+
this._discoveredItemsByPath = discoveredItems;
|
|
165
|
+
this._items = new Map(this._manualItems);
|
|
166
|
+
for (const item of discoveredItems.values())if (!this._items.has(item.name)) this._items.set(item.name, item);
|
|
167
|
+
this._discovered = true;
|
|
168
|
+
this._cache.clear();
|
|
169
|
+
this._cache.set('all', Array.from(this._items.values()));
|
|
170
|
+
this.log(`Discovery complete: found ${discoveredItems.size} ${this._entityName}s`, {
|
|
171
|
+
discoveredCount: discoveredItems.size
|
|
172
|
+
});
|
|
173
|
+
return discoveredItems.size;
|
|
174
|
+
}
|
|
175
|
+
_retainLastKnownGood(filePath, reason, discoveredItems, claimedNames) {
|
|
176
|
+
const previous = this._discoveredItemsByPath.get(filePath);
|
|
177
|
+
if (previous && !claimedNames.has(previous.name)) {
|
|
178
|
+
discoveredItems.set(filePath, previous);
|
|
179
|
+
claimedNames.add(previous.name);
|
|
180
|
+
}
|
|
181
|
+
this._logger.warn(`Invalid ${this._entityName} discovery file`, {
|
|
182
|
+
filePath,
|
|
183
|
+
reason,
|
|
184
|
+
retainedLastKnownGood: void 0 !== previous
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
_retainDirectory(directory, discoveredItems, claimedNames) {
|
|
188
|
+
for (const [filePath, item] of this._discoveredItemsByPath)if (dirname(filePath) === directory && !claimedNames.has(item.name)) {
|
|
189
|
+
discoveredItems.set(filePath, item);
|
|
190
|
+
claimedNames.add(item.name);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
_extractFrontmatter(content) {
|
|
194
|
+
const match = content.match(/^---\n([\s\S]+?)\n---/);
|
|
195
|
+
if (!match) return null;
|
|
196
|
+
return parse(match[1]);
|
|
197
|
+
}
|
|
198
|
+
setAll(items) {
|
|
199
|
+
this.clear();
|
|
200
|
+
for (const item of items)try {
|
|
201
|
+
this.add(item);
|
|
202
|
+
} catch (error) {
|
|
203
|
+
this.log(`Error adding ${this._entityName} '${item.name}':`, {
|
|
204
|
+
[`${this._entityName}Name`]: item.name,
|
|
205
|
+
error: getErrorMessage(error)
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
this.log(`Set ${items.length} ${this._entityName}s from external source`, {
|
|
209
|
+
[`${this._entityName}Count`]: items.length
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
export { BaseRegistry };
|
|
214
|
+
|
|
215
|
+
//# sourceMappingURL=BaseRegistry.js.map
|