@framers/agentos 0.1.120 → 0.1.122
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/README.md +21 -0
- package/dist/api/agency.d.ts.map +1 -1
- package/dist/api/agency.js +227 -84
- package/dist/api/agency.js.map +1 -1
- package/dist/api/analyzeVideo.d.ts +127 -0
- package/dist/api/analyzeVideo.d.ts.map +1 -0
- package/dist/api/analyzeVideo.js +136 -0
- package/dist/api/analyzeVideo.js.map +1 -0
- package/dist/api/detectScenes.d.ts +82 -0
- package/dist/api/detectScenes.d.ts.map +1 -0
- package/dist/api/detectScenes.js +67 -0
- package/dist/api/detectScenes.js.map +1 -0
- package/dist/api/generateImage.d.ts +7 -0
- package/dist/api/generateImage.d.ts.map +1 -1
- package/dist/api/generateImage.js +133 -9
- package/dist/api/generateImage.js.map +1 -1
- package/dist/api/generateMusic.d.ts +98 -0
- package/dist/api/generateMusic.d.ts.map +1 -0
- package/dist/api/generateMusic.js +319 -0
- package/dist/api/generateMusic.js.map +1 -0
- package/dist/api/generateSFX.d.ts +96 -0
- package/dist/api/generateSFX.d.ts.map +1 -0
- package/dist/api/generateSFX.js +317 -0
- package/dist/api/generateSFX.js.map +1 -0
- package/dist/api/generateVideo.d.ts +113 -0
- package/dist/api/generateVideo.d.ts.map +1 -0
- package/dist/api/generateVideo.js +342 -0
- package/dist/api/generateVideo.js.map +1 -0
- package/dist/api/model.d.ts.map +1 -1
- package/dist/api/model.js +8 -4
- package/dist/api/model.js.map +1 -1
- package/dist/api/performOCR.d.ts +169 -0
- package/dist/api/performOCR.d.ts.map +1 -0
- package/dist/api/performOCR.js +198 -0
- package/dist/api/performOCR.js.map +1 -0
- package/dist/api/provider-defaults.d.ts +7 -5
- package/dist/api/provider-defaults.d.ts.map +1 -1
- package/dist/api/provider-defaults.js +32 -10
- package/dist/api/provider-defaults.js.map +1 -1
- package/dist/api/strategies/debate.d.ts.map +1 -1
- package/dist/api/strategies/debate.js +1 -0
- package/dist/api/strategies/debate.js.map +1 -1
- package/dist/api/strategies/graph.d.ts.map +1 -1
- package/dist/api/strategies/graph.js +69 -13
- package/dist/api/strategies/graph.js.map +1 -1
- package/dist/api/strategies/hierarchical.d.ts.map +1 -1
- package/dist/api/strategies/hierarchical.js +1 -0
- package/dist/api/strategies/hierarchical.js.map +1 -1
- package/dist/api/strategies/parallel.d.ts.map +1 -1
- package/dist/api/strategies/parallel.js +1 -0
- package/dist/api/strategies/parallel.js.map +1 -1
- package/dist/api/strategies/review-loop.d.ts.map +1 -1
- package/dist/api/strategies/review-loop.js +1 -0
- package/dist/api/strategies/review-loop.js.map +1 -1
- package/dist/api/strategies/sequential.d.ts.map +1 -1
- package/dist/api/strategies/sequential.js +54 -48
- package/dist/api/strategies/sequential.js.map +1 -1
- package/dist/api/streamBuffer.d.ts +20 -0
- package/dist/api/streamBuffer.d.ts.map +1 -0
- package/dist/api/streamBuffer.js +81 -0
- package/dist/api/streamBuffer.js.map +1 -0
- package/dist/api/types.d.ts +145 -5
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js.map +1 -1
- package/dist/channels/adapters/RedditChannelAdapter.js.map +1 -1
- package/dist/core/audio/AudioProcessor.d.ts.map +1 -1
- package/dist/core/audio/AudioProcessor.js +1 -0
- package/dist/core/audio/AudioProcessor.js.map +1 -1
- package/dist/core/audio/EnvironmentalCalibrator.d.ts.map +1 -1
- package/dist/core/audio/EnvironmentalCalibrator.js +1 -0
- package/dist/core/audio/EnvironmentalCalibrator.js.map +1 -1
- package/dist/core/audio/FallbackAudioProxy.d.ts +169 -0
- package/dist/core/audio/FallbackAudioProxy.d.ts.map +1 -0
- package/dist/core/audio/FallbackAudioProxy.js +236 -0
- package/dist/core/audio/FallbackAudioProxy.js.map +1 -0
- package/dist/core/audio/IAudioGenerator.d.ts +103 -0
- package/dist/core/audio/IAudioGenerator.d.ts.map +1 -0
- package/dist/core/audio/IAudioGenerator.js +24 -0
- package/dist/core/audio/IAudioGenerator.js.map +1 -0
- package/dist/core/audio/index.d.ts +54 -0
- package/dist/core/audio/index.d.ts.map +1 -1
- package/dist/core/audio/index.js +93 -0
- package/dist/core/audio/index.js.map +1 -1
- package/dist/core/audio/providers/AudioGenLocalProvider.d.ts +136 -0
- package/dist/core/audio/providers/AudioGenLocalProvider.d.ts.map +1 -0
- package/dist/core/audio/providers/AudioGenLocalProvider.js +235 -0
- package/dist/core/audio/providers/AudioGenLocalProvider.js.map +1 -0
- package/dist/core/audio/providers/ElevenLabsSFXProvider.d.ts +107 -0
- package/dist/core/audio/providers/ElevenLabsSFXProvider.d.ts.map +1 -0
- package/dist/core/audio/providers/ElevenLabsSFXProvider.js +154 -0
- package/dist/core/audio/providers/ElevenLabsSFXProvider.js.map +1 -0
- package/dist/core/audio/providers/FalAudioProvider.d.ts +207 -0
- package/dist/core/audio/providers/FalAudioProvider.d.ts.map +1 -0
- package/dist/core/audio/providers/FalAudioProvider.js +315 -0
- package/dist/core/audio/providers/FalAudioProvider.js.map +1 -0
- package/dist/core/audio/providers/MusicGenLocalProvider.d.ts +136 -0
- package/dist/core/audio/providers/MusicGenLocalProvider.d.ts.map +1 -0
- package/dist/core/audio/providers/MusicGenLocalProvider.js +235 -0
- package/dist/core/audio/providers/MusicGenLocalProvider.js.map +1 -0
- package/dist/core/audio/providers/ReplicateAudioProvider.d.ts +200 -0
- package/dist/core/audio/providers/ReplicateAudioProvider.d.ts.map +1 -0
- package/dist/core/audio/providers/ReplicateAudioProvider.js +346 -0
- package/dist/core/audio/providers/ReplicateAudioProvider.js.map +1 -0
- package/dist/core/audio/providers/StableAudioProvider.d.ts +138 -0
- package/dist/core/audio/providers/StableAudioProvider.d.ts.map +1 -0
- package/dist/core/audio/providers/StableAudioProvider.js +192 -0
- package/dist/core/audio/providers/StableAudioProvider.js.map +1 -0
- package/dist/core/audio/providers/SunoProvider.d.ts +182 -0
- package/dist/core/audio/providers/SunoProvider.d.ts.map +1 -0
- package/dist/core/audio/providers/SunoProvider.js +312 -0
- package/dist/core/audio/providers/SunoProvider.js.map +1 -0
- package/dist/core/audio/providers/UdioProvider.d.ts +177 -0
- package/dist/core/audio/providers/UdioProvider.d.ts.map +1 -0
- package/dist/core/audio/providers/UdioProvider.js +305 -0
- package/dist/core/audio/providers/UdioProvider.js.map +1 -0
- package/dist/core/audio/types.d.ts +257 -0
- package/dist/core/audio/types.d.ts.map +1 -0
- package/dist/core/audio/types.js +21 -0
- package/dist/core/audio/types.js.map +1 -0
- package/dist/core/images/FallbackImageProxy.d.ts +183 -0
- package/dist/core/images/FallbackImageProxy.d.ts.map +1 -0
- package/dist/core/images/FallbackImageProxy.js +283 -0
- package/dist/core/images/FallbackImageProxy.js.map +1 -0
- package/dist/core/images/IImageProvider.d.ts +1 -1
- package/dist/core/images/IImageProvider.d.ts.map +1 -1
- package/dist/core/images/index.d.ts +1 -0
- package/dist/core/images/index.d.ts.map +1 -1
- package/dist/core/images/index.js +1 -0
- package/dist/core/images/index.js.map +1 -1
- package/dist/core/llm/providers/AIModelProviderManager.d.ts +3 -1
- package/dist/core/llm/providers/AIModelProviderManager.d.ts.map +1 -1
- package/dist/core/llm/providers/AIModelProviderManager.js +8 -0
- package/dist/core/llm/providers/AIModelProviderManager.js.map +1 -1
- package/dist/core/llm/providers/errors/ClaudeCodeProviderError.d.ts +52 -0
- package/dist/core/llm/providers/errors/ClaudeCodeProviderError.d.ts.map +1 -0
- package/dist/core/llm/providers/errors/ClaudeCodeProviderError.js +36 -0
- package/dist/core/llm/providers/errors/ClaudeCodeProviderError.js.map +1 -0
- package/dist/core/llm/providers/errors/GeminiCLIProviderError.d.ts +32 -0
- package/dist/core/llm/providers/errors/GeminiCLIProviderError.d.ts.map +1 -0
- package/dist/core/llm/providers/errors/GeminiCLIProviderError.js +27 -0
- package/dist/core/llm/providers/errors/GeminiCLIProviderError.js.map +1 -0
- package/dist/core/llm/providers/implementations/ClaudeCodeCLIBridge.d.ts +38 -0
- package/dist/core/llm/providers/implementations/ClaudeCodeCLIBridge.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/ClaudeCodeCLIBridge.js +128 -0
- package/dist/core/llm/providers/implementations/ClaudeCodeCLIBridge.js.map +1 -0
- package/dist/core/llm/providers/implementations/ClaudeCodeProvider.d.ts +107 -0
- package/dist/core/llm/providers/implementations/ClaudeCodeProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/ClaudeCodeProvider.js +504 -0
- package/dist/core/llm/providers/implementations/ClaudeCodeProvider.js.map +1 -0
- package/dist/core/llm/providers/implementations/GeminiCLIBridge.d.ts +60 -0
- package/dist/core/llm/providers/implementations/GeminiCLIBridge.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/GeminiCLIBridge.js +177 -0
- package/dist/core/llm/providers/implementations/GeminiCLIBridge.js.map +1 -0
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.d.ts +55 -0
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.js +447 -0
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.js.map +1 -0
- package/dist/core/media/ProviderPreferences.d.ts +158 -0
- package/dist/core/media/ProviderPreferences.d.ts.map +1 -0
- package/dist/core/media/ProviderPreferences.js +183 -0
- package/dist/core/media/ProviderPreferences.js.map +1 -0
- package/dist/core/subprocess/CLIRegistry.d.ts +71 -0
- package/dist/core/subprocess/CLIRegistry.d.ts.map +1 -0
- package/dist/core/subprocess/CLIRegistry.js +210 -0
- package/dist/core/subprocess/CLIRegistry.js.map +1 -0
- package/dist/core/subprocess/CLISubprocessBridge.d.ts +117 -0
- package/dist/core/subprocess/CLISubprocessBridge.d.ts.map +1 -0
- package/dist/core/subprocess/CLISubprocessBridge.js +199 -0
- package/dist/core/subprocess/CLISubprocessBridge.js.map +1 -0
- package/dist/core/subprocess/errors.d.ts +76 -0
- package/dist/core/subprocess/errors.d.ts.map +1 -0
- package/dist/core/subprocess/errors.js +75 -0
- package/dist/core/subprocess/errors.js.map +1 -0
- package/dist/core/subprocess/index.d.ts +11 -0
- package/dist/core/subprocess/index.d.ts.map +1 -0
- package/dist/core/subprocess/index.js +10 -0
- package/dist/core/subprocess/index.js.map +1 -0
- package/dist/core/subprocess/types.d.ts +100 -0
- package/dist/core/subprocess/types.d.ts.map +1 -0
- package/dist/core/subprocess/types.js +9 -0
- package/dist/core/subprocess/types.js.map +1 -0
- package/dist/core/video/FallbackVideoProxy.d.ts +166 -0
- package/dist/core/video/FallbackVideoProxy.d.ts.map +1 -0
- package/dist/core/video/FallbackVideoProxy.js +228 -0
- package/dist/core/video/FallbackVideoProxy.js.map +1 -0
- package/dist/core/video/IVideoAnalyzer.d.ts +29 -0
- package/dist/core/video/IVideoAnalyzer.d.ts.map +1 -0
- package/dist/core/video/IVideoAnalyzer.js +12 -0
- package/dist/core/video/IVideoAnalyzer.js.map +1 -0
- package/dist/core/video/IVideoGenerator.d.ts +76 -0
- package/dist/core/video/IVideoGenerator.d.ts.map +1 -0
- package/dist/core/video/IVideoGenerator.js +13 -0
- package/dist/core/video/IVideoGenerator.js.map +1 -0
- package/dist/core/video/VideoAnalyzer.d.ts +278 -0
- package/dist/core/video/VideoAnalyzer.d.ts.map +1 -0
- package/dist/core/video/VideoAnalyzer.js +648 -0
- package/dist/core/video/VideoAnalyzer.js.map +1 -0
- package/dist/core/video/index.d.ts +55 -0
- package/dist/core/video/index.d.ts.map +1 -0
- package/dist/core/video/index.js +78 -0
- package/dist/core/video/index.js.map +1 -0
- package/dist/core/video/providers/FalVideoProvider.d.ts +195 -0
- package/dist/core/video/providers/FalVideoProvider.d.ts.map +1 -0
- package/dist/core/video/providers/FalVideoProvider.js +322 -0
- package/dist/core/video/providers/FalVideoProvider.js.map +1 -0
- package/dist/core/video/providers/ReplicateVideoProvider.d.ts +194 -0
- package/dist/core/video/providers/ReplicateVideoProvider.d.ts.map +1 -0
- package/dist/core/video/providers/ReplicateVideoProvider.js +356 -0
- package/dist/core/video/providers/ReplicateVideoProvider.js.map +1 -0
- package/dist/core/video/providers/RunwayVideoProvider.d.ts +175 -0
- package/dist/core/video/providers/RunwayVideoProvider.d.ts.map +1 -0
- package/dist/core/video/providers/RunwayVideoProvider.js +293 -0
- package/dist/core/video/providers/RunwayVideoProvider.js.map +1 -0
- package/dist/core/video/types.d.ts +441 -0
- package/dist/core/video/types.d.ts.map +1 -0
- package/dist/core/video/types.js +10 -0
- package/dist/core/video/types.js.map +1 -0
- package/dist/core/vision/SceneDetector.d.ts +180 -0
- package/dist/core/vision/SceneDetector.d.ts.map +1 -0
- package/dist/core/vision/SceneDetector.js +366 -0
- package/dist/core/vision/SceneDetector.js.map +1 -0
- package/dist/core/vision/index.d.ts +2 -1
- package/dist/core/vision/index.d.ts.map +1 -1
- package/dist/core/vision/index.js +1 -0
- package/dist/core/vision/index.js.map +1 -1
- package/dist/core/vision/types.d.ts +125 -0
- package/dist/core/vision/types.d.ts.map +1 -1
- package/dist/discovery/CapabilityDiscoveryEngine.d.ts +32 -0
- package/dist/discovery/CapabilityDiscoveryEngine.d.ts.map +1 -1
- package/dist/discovery/CapabilityDiscoveryEngine.js +46 -0
- package/dist/discovery/CapabilityDiscoveryEngine.js.map +1 -1
- package/dist/emergent/AdaptPersonalityTool.d.ts +158 -0
- package/dist/emergent/AdaptPersonalityTool.d.ts.map +1 -0
- package/dist/emergent/AdaptPersonalityTool.js +190 -0
- package/dist/emergent/AdaptPersonalityTool.js.map +1 -0
- package/dist/emergent/CreateWorkflowTool.d.ts +181 -0
- package/dist/emergent/CreateWorkflowTool.d.ts.map +1 -0
- package/dist/emergent/CreateWorkflowTool.js +307 -0
- package/dist/emergent/CreateWorkflowTool.js.map +1 -0
- package/dist/emergent/ManageSkillsTool.d.ts +154 -0
- package/dist/emergent/ManageSkillsTool.d.ts.map +1 -0
- package/dist/emergent/ManageSkillsTool.js +241 -0
- package/dist/emergent/ManageSkillsTool.js.map +1 -0
- package/dist/emergent/PersonalityMutationStore.d.ts +183 -0
- package/dist/emergent/PersonalityMutationStore.d.ts.map +1 -0
- package/dist/emergent/PersonalityMutationStore.js +222 -0
- package/dist/emergent/PersonalityMutationStore.js.map +1 -0
- package/dist/emergent/SelfEvaluateTool.d.ts +189 -0
- package/dist/emergent/SelfEvaluateTool.d.ts.map +1 -0
- package/dist/emergent/SelfEvaluateTool.js +353 -0
- package/dist/emergent/SelfEvaluateTool.js.map +1 -0
- package/dist/emergent/SelfImprovementConfig.d.ts +166 -0
- package/dist/emergent/SelfImprovementConfig.d.ts.map +1 -0
- package/dist/emergent/SelfImprovementConfig.js +43 -0
- package/dist/emergent/SelfImprovementConfig.js.map +1 -0
- package/dist/emergent/index.d.ts +1 -0
- package/dist/emergent/index.d.ts.map +1 -1
- package/dist/emergent/index.js +1 -0
- package/dist/emergent/index.js.map +1 -1
- package/dist/emergent/types.d.ts +9 -0
- package/dist/emergent/types.d.ts.map +1 -1
- package/dist/emergent/types.js.map +1 -1
- package/dist/extensions/MultiRegistryLoader.js.map +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/CognitiveMemoryManager.d.ts +40 -0
- package/dist/memory/CognitiveMemoryManager.d.ts.map +1 -1
- package/dist/memory/CognitiveMemoryManager.js +54 -1
- package/dist/memory/CognitiveMemoryManager.js.map +1 -1
- package/dist/memory/facade/Memory.d.ts +4 -0
- package/dist/memory/facade/Memory.d.ts.map +1 -1
- package/dist/memory/facade/Memory.js +140 -4
- package/dist/memory/facade/Memory.js.map +1 -1
- package/dist/memory/facade/types.d.ts +30 -2
- package/dist/memory/facade/types.d.ts.map +1 -1
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +1 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/types.d.ts +15 -0
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/query-router/QueryClassifier.d.ts +192 -21
- package/dist/query-router/QueryClassifier.d.ts.map +1 -1
- package/dist/query-router/QueryClassifier.js +604 -23
- package/dist/query-router/QueryClassifier.js.map +1 -1
- package/dist/query-router/QueryDispatcher.d.ts +106 -8
- package/dist/query-router/QueryDispatcher.d.ts.map +1 -1
- package/dist/query-router/QueryDispatcher.js +387 -8
- package/dist/query-router/QueryDispatcher.js.map +1 -1
- package/dist/query-router/QueryRouter.d.ts +198 -14
- package/dist/query-router/QueryRouter.d.ts.map +1 -1
- package/dist/query-router/QueryRouter.js +738 -50
- package/dist/query-router/QueryRouter.js.map +1 -1
- package/dist/query-router/index.d.ts +1 -1
- package/dist/query-router/index.d.ts.map +1 -1
- package/dist/query-router/index.js +1 -1
- package/dist/query-router/index.js.map +1 -1
- package/dist/query-router/types.d.ts +396 -3
- package/dist/query-router/types.d.ts.map +1 -1
- package/dist/query-router/types.js +35 -0
- package/dist/query-router/types.js.map +1 -1
- package/dist/rag/HydeRetriever.d.ts +108 -0
- package/dist/rag/HydeRetriever.d.ts.map +1 -1
- package/dist/rag/HydeRetriever.js +184 -0
- package/dist/rag/HydeRetriever.js.map +1 -1
- package/dist/rag/IRetrievalAugmentor.d.ts +15 -0
- package/dist/rag/IRetrievalAugmentor.d.ts.map +1 -1
- package/dist/rag/RetrievalAugmentor.d.ts +58 -0
- package/dist/rag/RetrievalAugmentor.d.ts.map +1 -1
- package/dist/rag/RetrievalAugmentor.js +200 -32
- package/dist/rag/RetrievalAugmentor.js.map +1 -1
- package/dist/rag/VectorStoreManager.js +1 -1
- package/dist/rag/audit/RAGAuditCollector.d.ts +7 -0
- package/dist/rag/audit/RAGAuditCollector.d.ts.map +1 -1
- package/dist/rag/audit/RAGAuditCollector.js +10 -0
- package/dist/rag/audit/RAGAuditCollector.js.map +1 -1
- package/dist/rag/audit/RAGAuditTypes.d.ts +10 -1
- package/dist/rag/audit/RAGAuditTypes.d.ts.map +1 -1
- package/dist/rag/chunking/SemanticChunker.d.ts +210 -0
- package/dist/rag/chunking/SemanticChunker.d.ts.map +1 -0
- package/dist/rag/chunking/SemanticChunker.js +460 -0
- package/dist/rag/chunking/SemanticChunker.js.map +1 -0
- package/dist/rag/chunking/index.d.ts +10 -0
- package/dist/rag/chunking/index.d.ts.map +1 -0
- package/dist/rag/chunking/index.js +10 -0
- package/dist/rag/chunking/index.js.map +1 -0
- package/dist/rag/implementations/vector_stores/PineconeVectorStore.d.ts +103 -0
- package/dist/rag/implementations/vector_stores/PineconeVectorStore.d.ts.map +1 -0
- package/dist/rag/implementations/vector_stores/PineconeVectorStore.js +315 -0
- package/dist/rag/implementations/vector_stores/PineconeVectorStore.js.map +1 -0
- package/dist/rag/implementations/vector_stores/PostgresVectorStore.d.ts +107 -0
- package/dist/rag/implementations/vector_stores/PostgresVectorStore.d.ts.map +1 -0
- package/dist/rag/implementations/vector_stores/PostgresVectorStore.js +438 -0
- package/dist/rag/implementations/vector_stores/PostgresVectorStore.js.map +1 -0
- package/dist/rag/index.d.ts +15 -1
- package/dist/rag/index.d.ts.map +1 -1
- package/dist/rag/index.js +32 -0
- package/dist/rag/index.js.map +1 -1
- package/dist/rag/migration/MigrationEngine.d.ts +47 -0
- package/dist/rag/migration/MigrationEngine.d.ts.map +1 -0
- package/dist/rag/migration/MigrationEngine.js +168 -0
- package/dist/rag/migration/MigrationEngine.js.map +1 -0
- package/dist/rag/migration/adapters/PineconeSourceAdapter.d.ts +23 -0
- package/dist/rag/migration/adapters/PineconeSourceAdapter.d.ts.map +1 -0
- package/dist/rag/migration/adapters/PineconeSourceAdapter.js +63 -0
- package/dist/rag/migration/adapters/PineconeSourceAdapter.js.map +1 -0
- package/dist/rag/migration/adapters/PostgresSourceAdapter.d.ts +30 -0
- package/dist/rag/migration/adapters/PostgresSourceAdapter.d.ts.map +1 -0
- package/dist/rag/migration/adapters/PostgresSourceAdapter.js +71 -0
- package/dist/rag/migration/adapters/PostgresSourceAdapter.js.map +1 -0
- package/dist/rag/migration/adapters/PostgresTargetAdapter.d.ts +38 -0
- package/dist/rag/migration/adapters/PostgresTargetAdapter.d.ts.map +1 -0
- package/dist/rag/migration/adapters/PostgresTargetAdapter.js +114 -0
- package/dist/rag/migration/adapters/PostgresTargetAdapter.js.map +1 -0
- package/dist/rag/migration/adapters/QdrantSourceAdapter.d.ts +36 -0
- package/dist/rag/migration/adapters/QdrantSourceAdapter.d.ts.map +1 -0
- package/dist/rag/migration/adapters/QdrantSourceAdapter.js +109 -0
- package/dist/rag/migration/adapters/QdrantSourceAdapter.js.map +1 -0
- package/dist/rag/migration/adapters/QdrantTargetAdapter.d.ts +35 -0
- package/dist/rag/migration/adapters/QdrantTargetAdapter.d.ts.map +1 -0
- package/dist/rag/migration/adapters/QdrantTargetAdapter.js +110 -0
- package/dist/rag/migration/adapters/QdrantTargetAdapter.js.map +1 -0
- package/dist/rag/migration/adapters/SqliteSourceAdapter.d.ts +37 -0
- package/dist/rag/migration/adapters/SqliteSourceAdapter.d.ts.map +1 -0
- package/dist/rag/migration/adapters/SqliteSourceAdapter.js +72 -0
- package/dist/rag/migration/adapters/SqliteSourceAdapter.js.map +1 -0
- package/dist/rag/migration/adapters/SqliteTargetAdapter.d.ts +47 -0
- package/dist/rag/migration/adapters/SqliteTargetAdapter.d.ts.map +1 -0
- package/dist/rag/migration/adapters/SqliteTargetAdapter.js +93 -0
- package/dist/rag/migration/adapters/SqliteTargetAdapter.js.map +1 -0
- package/dist/rag/migration/types.d.ts +108 -0
- package/dist/rag/migration/types.d.ts.map +1 -0
- package/dist/rag/migration/types.js +11 -0
- package/dist/rag/migration/types.js.map +1 -0
- package/dist/rag/multimodal/MultimodalIndexer.d.ts +35 -0
- package/dist/rag/multimodal/MultimodalIndexer.d.ts.map +1 -1
- package/dist/rag/multimodal/MultimodalIndexer.js +66 -1
- package/dist/rag/multimodal/MultimodalIndexer.js.map +1 -1
- package/dist/rag/multimodal/types.d.ts +24 -0
- package/dist/rag/multimodal/types.d.ts.map +1 -1
- package/dist/rag/raptor/RaptorTree.d.ts +268 -0
- package/dist/rag/raptor/RaptorTree.d.ts.map +1 -0
- package/dist/rag/raptor/RaptorTree.js +443 -0
- package/dist/rag/raptor/RaptorTree.js.map +1 -0
- package/dist/rag/raptor/index.d.ts +11 -0
- package/dist/rag/raptor/index.d.ts.map +1 -0
- package/dist/rag/raptor/index.js +11 -0
- package/dist/rag/raptor/index.js.map +1 -0
- package/dist/rag/reranking/providers/CohereReranker.js.map +1 -1
- package/dist/rag/search/BM25Index.d.ts +282 -0
- package/dist/rag/search/BM25Index.d.ts.map +1 -0
- package/dist/rag/search/BM25Index.js +344 -0
- package/dist/rag/search/BM25Index.js.map +1 -0
- package/dist/rag/search/HybridSearcher.d.ts +198 -0
- package/dist/rag/search/HybridSearcher.d.ts.map +1 -0
- package/dist/rag/search/HybridSearcher.js +316 -0
- package/dist/rag/search/HybridSearcher.js.map +1 -0
- package/dist/rag/search/index.d.ts +12 -0
- package/dist/rag/search/index.d.ts.map +1 -0
- package/dist/rag/search/index.js +12 -0
- package/dist/rag/search/index.js.map +1 -0
- package/dist/rag/setup/DockerDetector.d.ts +67 -0
- package/dist/rag/setup/DockerDetector.d.ts.map +1 -0
- package/dist/rag/setup/DockerDetector.js +125 -0
- package/dist/rag/setup/DockerDetector.js.map +1 -0
- package/dist/rag/setup/PostgresSetup.d.ts +20 -0
- package/dist/rag/setup/PostgresSetup.d.ts.map +1 -0
- package/dist/rag/setup/PostgresSetup.js +133 -0
- package/dist/rag/setup/PostgresSetup.js.map +1 -0
- package/dist/rag/setup/QdrantSetup.d.ts +26 -0
- package/dist/rag/setup/QdrantSetup.d.ts.map +1 -0
- package/dist/rag/setup/QdrantSetup.js +96 -0
- package/dist/rag/setup/QdrantSetup.js.map +1 -0
- package/dist/rag/setup/types.d.ts +55 -0
- package/dist/rag/setup/types.d.ts.map +1 -0
- package/dist/rag/setup/types.js +6 -0
- package/dist/rag/setup/types.js.map +1 -0
- package/dist/rag/unified/UnifiedRetriever.d.ts +472 -0
- package/dist/rag/unified/UnifiedRetriever.d.ts.map +1 -0
- package/dist/rag/unified/UnifiedRetriever.js +887 -0
- package/dist/rag/unified/UnifiedRetriever.js.map +1 -0
- package/dist/rag/unified/index.d.ts +24 -0
- package/dist/rag/unified/index.d.ts.map +1 -0
- package/dist/rag/unified/index.js +23 -0
- package/dist/rag/unified/index.js.map +1 -0
- package/dist/rag/unified/types.d.ts +546 -0
- package/dist/rag/unified/types.d.ts.map +1 -0
- package/dist/rag/unified/types.js +177 -0
- package/dist/rag/unified/types.js.map +1 -0
- package/dist/speech/providers/AssemblyAISTTProvider.js.map +1 -1
- package/dist/speech/providers/AzureSpeechSTTProvider.js.map +1 -1
- package/dist/speech/providers/BuiltInAdaptiveVadProvider.d.ts +1 -1
- package/dist/speech/providers/DeepgramBatchSTTProvider.js.map +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/audio/providers/FalAudioProvider
|
|
3
|
+
*
|
|
4
|
+
* Audio generation provider for the Fal.ai serverless GPU platform.
|
|
5
|
+
*
|
|
6
|
+
* Fal.ai hosts audio generation models (Stable Audio, etc.) behind a
|
|
7
|
+
* queue-based API. This provider implements the three-step pattern
|
|
8
|
+
* established by {@link FalVideoProvider}: submit to queue, poll for status,
|
|
9
|
+
* then fetch the completed result.
|
|
10
|
+
*
|
|
11
|
+
* ## Supported models
|
|
12
|
+
*
|
|
13
|
+
* | Model ID | Description |
|
|
14
|
+
* |------------------------|--------------------------------------|
|
|
15
|
+
* | `fal-ai/stable-audio` | Stable Audio on Fal.ai — default |
|
|
16
|
+
*
|
|
17
|
+
* ## API flow (three-step queue)
|
|
18
|
+
*
|
|
19
|
+
* 1. **Submit** — `POST ${baseURL}/${model}` with prompt/params.
|
|
20
|
+
* Returns `{ request_id }` immediately.
|
|
21
|
+
* 2. **Poll** — `GET ${baseURL}/${model}/requests/${request_id}/status`
|
|
22
|
+
* until `status === 'COMPLETED'` or `'FAILED'`.
|
|
23
|
+
* 3. **Fetch** — `GET ${baseURL}/${model}/requests/${request_id}`
|
|
24
|
+
* returns `{ audio: { url } }`.
|
|
25
|
+
*
|
|
26
|
+
* ## Authentication
|
|
27
|
+
*
|
|
28
|
+
* Requires a `FAL_API_KEY`. Sent as `Authorization: Key ${apiKey}`.
|
|
29
|
+
*
|
|
30
|
+
* @see {@link IAudioGenerator} for the provider interface contract.
|
|
31
|
+
* @see {@link FalVideoProvider} for the video counterpart.
|
|
32
|
+
* @see {@link FalImageProvider} for the image counterpart.
|
|
33
|
+
*/
|
|
34
|
+
import type { IAudioGenerator } from '../IAudioGenerator.js';
|
|
35
|
+
import type { MusicGenerateRequest, SFXGenerateRequest, AudioResult } from '../types.js';
|
|
36
|
+
/**
|
|
37
|
+
* Configuration for the Fal.ai audio generation provider.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const config: FalAudioProviderConfig = {
|
|
42
|
+
* apiKey: process.env.FAL_API_KEY!,
|
|
43
|
+
* defaultModelId: 'fal-ai/stable-audio',
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export interface FalAudioProviderConfig {
|
|
48
|
+
/**
|
|
49
|
+
* Fal.ai API key. Sent as `Authorization: Key ${apiKey}`.
|
|
50
|
+
* Obtain from https://fal.ai/dashboard/keys
|
|
51
|
+
*/
|
|
52
|
+
apiKey: string;
|
|
53
|
+
/**
|
|
54
|
+
* Base URL for the Fal.ai queue API. Override for testing or proxy setups.
|
|
55
|
+
* @default 'https://queue.fal.run'
|
|
56
|
+
*/
|
|
57
|
+
baseURL?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Default model to use when the request doesn't specify one.
|
|
60
|
+
* @default 'fal-ai/stable-audio'
|
|
61
|
+
*/
|
|
62
|
+
defaultModelId?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Milliseconds between status polls while waiting for generation.
|
|
65
|
+
* @default 2000
|
|
66
|
+
*/
|
|
67
|
+
pollIntervalMs?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Maximum milliseconds to wait for generation before timing out.
|
|
70
|
+
* @default 300000
|
|
71
|
+
*/
|
|
72
|
+
timeoutMs?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Audio generation provider connecting to the Fal.ai serverless platform.
|
|
76
|
+
*
|
|
77
|
+
* Implements the three-step queue pattern: submit a generation task,
|
|
78
|
+
* poll the status endpoint until completion, then fetch the result.
|
|
79
|
+
* This mirrors the flow used by {@link FalVideoProvider}.
|
|
80
|
+
*
|
|
81
|
+
* Supports both music and SFX generation through the same endpoint.
|
|
82
|
+
*
|
|
83
|
+
* @implements {IAudioGenerator}
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const provider = new FalAudioProvider();
|
|
88
|
+
* await provider.initialize({ apiKey: process.env.FAL_API_KEY! });
|
|
89
|
+
*
|
|
90
|
+
* const result = await provider.generateMusic({
|
|
91
|
+
* modelId: 'fal-ai/stable-audio',
|
|
92
|
+
* prompt: 'A dreamy ambient track with reverb-heavy synths',
|
|
93
|
+
* durationSec: 30,
|
|
94
|
+
* });
|
|
95
|
+
* console.log(result.audio[0].url);
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare class FalAudioProvider implements IAudioGenerator {
|
|
99
|
+
/** @inheritdoc */
|
|
100
|
+
readonly providerId = "fal-audio";
|
|
101
|
+
/** @inheritdoc */
|
|
102
|
+
isInitialized: boolean;
|
|
103
|
+
/** @inheritdoc */
|
|
104
|
+
defaultModelId?: string;
|
|
105
|
+
/** Internal resolved configuration. */
|
|
106
|
+
private _config;
|
|
107
|
+
/**
|
|
108
|
+
* Initialize the provider with API credentials and optional configuration.
|
|
109
|
+
*
|
|
110
|
+
* @param config - Configuration object. Must include `apiKey`.
|
|
111
|
+
* @throws {Error} If `apiKey` is missing or empty.
|
|
112
|
+
*/
|
|
113
|
+
initialize(config: Record<string, unknown>): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Generate music from a text prompt using the Fal.ai queue API.
|
|
116
|
+
*
|
|
117
|
+
* Submits the task, polls until complete, then fetches the result.
|
|
118
|
+
*
|
|
119
|
+
* @param request - Music generation request with prompt and optional params.
|
|
120
|
+
* @returns The generated audio result envelope.
|
|
121
|
+
*
|
|
122
|
+
* @throws {Error} If the provider is not initialized.
|
|
123
|
+
* @throws {Error} If the API returns an error or times out.
|
|
124
|
+
*/
|
|
125
|
+
generateMusic(request: MusicGenerateRequest): Promise<AudioResult>;
|
|
126
|
+
/**
|
|
127
|
+
* Generate a sound effect from a text prompt using the Fal.ai queue API.
|
|
128
|
+
*
|
|
129
|
+
* Submits the task, polls until complete, then fetches the result.
|
|
130
|
+
*
|
|
131
|
+
* @param request - SFX generation request with prompt and optional params.
|
|
132
|
+
* @returns The generated audio result envelope.
|
|
133
|
+
*
|
|
134
|
+
* @throws {Error} If the provider is not initialized.
|
|
135
|
+
* @throws {Error} If the API returns an error or times out.
|
|
136
|
+
*/
|
|
137
|
+
generateSFX(request: SFXGenerateRequest): Promise<AudioResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Fal.ai audio supports both music and SFX generation.
|
|
140
|
+
*
|
|
141
|
+
* @param capability - The capability to check.
|
|
142
|
+
* @returns `true` for both `'music'` and `'sfx'`.
|
|
143
|
+
*/
|
|
144
|
+
supports(capability: 'music' | 'sfx'): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Release any resources held by the provider. No-op for HTTP-only providers.
|
|
147
|
+
*/
|
|
148
|
+
shutdown(): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Run the full three-step generation flow: submit, poll, fetch.
|
|
151
|
+
*
|
|
152
|
+
* @param prompt - Text description of the desired audio.
|
|
153
|
+
* @param durationSec - Desired duration in seconds.
|
|
154
|
+
* @param modelId - Optional model override.
|
|
155
|
+
* @returns Normalized audio result envelope.
|
|
156
|
+
*
|
|
157
|
+
* @throws {Error} If any step of the flow fails.
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
private _generate;
|
|
161
|
+
/**
|
|
162
|
+
* Submit a generation task to the Fal.ai queue.
|
|
163
|
+
*
|
|
164
|
+
* @param model - Full model path (e.g. 'fal-ai/stable-audio').
|
|
165
|
+
* @param body - Request body with prompt and generation params.
|
|
166
|
+
* @returns The request_id for status polling.
|
|
167
|
+
*
|
|
168
|
+
* @throws {Error} If the submission request fails.
|
|
169
|
+
* @internal
|
|
170
|
+
*/
|
|
171
|
+
private _submitTask;
|
|
172
|
+
/**
|
|
173
|
+
* Poll the Fal.ai status endpoint until the task completes or times out.
|
|
174
|
+
*
|
|
175
|
+
* @param model - Full model path.
|
|
176
|
+
* @param requestId - The request ID from submission.
|
|
177
|
+
*
|
|
178
|
+
* @throws {Error} If the generation fails or times out.
|
|
179
|
+
* @internal
|
|
180
|
+
*/
|
|
181
|
+
private _pollStatus;
|
|
182
|
+
/**
|
|
183
|
+
* Fetch the completed generation result from the Fal.ai result endpoint.
|
|
184
|
+
*
|
|
185
|
+
* Called after polling confirms the task is COMPLETED.
|
|
186
|
+
*
|
|
187
|
+
* @param model - Full model path.
|
|
188
|
+
* @param requestId - The request ID from submission.
|
|
189
|
+
* @returns The generation result with audio URL.
|
|
190
|
+
*
|
|
191
|
+
* @throws {Error} If the result fetch fails.
|
|
192
|
+
* @internal
|
|
193
|
+
*/
|
|
194
|
+
private _fetchResult;
|
|
195
|
+
/**
|
|
196
|
+
* Build an {@link AudioResult} from a completed Fal.ai result.
|
|
197
|
+
*
|
|
198
|
+
* @param result - The Fal.ai result response.
|
|
199
|
+
* @param model - Model ID used for the generation.
|
|
200
|
+
* @returns Normalized audio result envelope.
|
|
201
|
+
*
|
|
202
|
+
* @throws {Error} If the result has no audio URL.
|
|
203
|
+
* @internal
|
|
204
|
+
*/
|
|
205
|
+
private _buildResult;
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=FalAudioProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"F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,CAAC;IAQ/B;;;;;;;;;;OAUG;YACW,SAAS;IAqBvB;;;;;;;;;OASG;YACW,WAAW;IAyBzB;;;;;;;;OAQG;YACW,WAAW;IAoCzB;;;;;;;;;;;OAWG;YACW,YAAY;IAiB1B;;;;;;;;;OASG;IACH,OAAO,CAAC,YAAY;CAsBrB"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/audio/providers/FalAudioProvider
|
|
3
|
+
*
|
|
4
|
+
* Audio generation provider for the Fal.ai serverless GPU platform.
|
|
5
|
+
*
|
|
6
|
+
* Fal.ai hosts audio generation models (Stable Audio, etc.) behind a
|
|
7
|
+
* queue-based API. This provider implements the three-step pattern
|
|
8
|
+
* established by {@link FalVideoProvider}: submit to queue, poll for status,
|
|
9
|
+
* then fetch the completed result.
|
|
10
|
+
*
|
|
11
|
+
* ## Supported models
|
|
12
|
+
*
|
|
13
|
+
* | Model ID | Description |
|
|
14
|
+
* |------------------------|--------------------------------------|
|
|
15
|
+
* | `fal-ai/stable-audio` | Stable Audio on Fal.ai — default |
|
|
16
|
+
*
|
|
17
|
+
* ## API flow (three-step queue)
|
|
18
|
+
*
|
|
19
|
+
* 1. **Submit** — `POST ${baseURL}/${model}` with prompt/params.
|
|
20
|
+
* Returns `{ request_id }` immediately.
|
|
21
|
+
* 2. **Poll** — `GET ${baseURL}/${model}/requests/${request_id}/status`
|
|
22
|
+
* until `status === 'COMPLETED'` or `'FAILED'`.
|
|
23
|
+
* 3. **Fetch** — `GET ${baseURL}/${model}/requests/${request_id}`
|
|
24
|
+
* returns `{ audio: { url } }`.
|
|
25
|
+
*
|
|
26
|
+
* ## Authentication
|
|
27
|
+
*
|
|
28
|
+
* Requires a `FAL_API_KEY`. Sent as `Authorization: Key ${apiKey}`.
|
|
29
|
+
*
|
|
30
|
+
* @see {@link IAudioGenerator} for the provider interface contract.
|
|
31
|
+
* @see {@link FalVideoProvider} for the video counterpart.
|
|
32
|
+
* @see {@link FalImageProvider} for the image counterpart.
|
|
33
|
+
*/
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Helpers
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
/**
|
|
38
|
+
* Sleep for the specified number of milliseconds.
|
|
39
|
+
* Used between poll requests to avoid rate-limiting.
|
|
40
|
+
* @param ms - Duration in milliseconds.
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
function sleep(ms) {
|
|
44
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
45
|
+
}
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
// Implementation
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
/**
|
|
50
|
+
* Audio generation provider connecting to the Fal.ai serverless platform.
|
|
51
|
+
*
|
|
52
|
+
* Implements the three-step queue pattern: submit a generation task,
|
|
53
|
+
* poll the status endpoint until completion, then fetch the result.
|
|
54
|
+
* This mirrors the flow used by {@link FalVideoProvider}.
|
|
55
|
+
*
|
|
56
|
+
* Supports both music and SFX generation through the same endpoint.
|
|
57
|
+
*
|
|
58
|
+
* @implements {IAudioGenerator}
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const provider = new FalAudioProvider();
|
|
63
|
+
* await provider.initialize({ apiKey: process.env.FAL_API_KEY! });
|
|
64
|
+
*
|
|
65
|
+
* const result = await provider.generateMusic({
|
|
66
|
+
* modelId: 'fal-ai/stable-audio',
|
|
67
|
+
* prompt: 'A dreamy ambient track with reverb-heavy synths',
|
|
68
|
+
* durationSec: 30,
|
|
69
|
+
* });
|
|
70
|
+
* console.log(result.audio[0].url);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export class FalAudioProvider {
|
|
74
|
+
constructor() {
|
|
75
|
+
/** @inheritdoc */
|
|
76
|
+
this.providerId = 'fal-audio';
|
|
77
|
+
/** @inheritdoc */
|
|
78
|
+
this.isInitialized = false;
|
|
79
|
+
}
|
|
80
|
+
// -------------------------------------------------------------------------
|
|
81
|
+
// Lifecycle
|
|
82
|
+
// -------------------------------------------------------------------------
|
|
83
|
+
/**
|
|
84
|
+
* Initialize the provider with API credentials and optional configuration.
|
|
85
|
+
*
|
|
86
|
+
* @param config - Configuration object. Must include `apiKey`.
|
|
87
|
+
* @throws {Error} If `apiKey` is missing or empty.
|
|
88
|
+
*/
|
|
89
|
+
async initialize(config) {
|
|
90
|
+
const apiKey = typeof config.apiKey === 'string' ? config.apiKey.trim() : '';
|
|
91
|
+
if (!apiKey) {
|
|
92
|
+
throw new Error('Fal.ai audio provider requires apiKey (FAL_API_KEY).');
|
|
93
|
+
}
|
|
94
|
+
this._config = {
|
|
95
|
+
apiKey,
|
|
96
|
+
baseURL: typeof config.baseURL === 'string' && config.baseURL.trim()
|
|
97
|
+
? config.baseURL.trim()
|
|
98
|
+
: 'https://queue.fal.run',
|
|
99
|
+
defaultModelId: typeof config.defaultModelId === 'string' && config.defaultModelId.trim()
|
|
100
|
+
? config.defaultModelId.trim()
|
|
101
|
+
: 'fal-ai/stable-audio',
|
|
102
|
+
pollIntervalMs: typeof config.pollIntervalMs === 'number' && config.pollIntervalMs > 0
|
|
103
|
+
? config.pollIntervalMs
|
|
104
|
+
: 2000,
|
|
105
|
+
timeoutMs: typeof config.timeoutMs === 'number' && config.timeoutMs > 0
|
|
106
|
+
? config.timeoutMs
|
|
107
|
+
: 300000,
|
|
108
|
+
};
|
|
109
|
+
this.defaultModelId = this._config.defaultModelId;
|
|
110
|
+
this.isInitialized = true;
|
|
111
|
+
}
|
|
112
|
+
// -------------------------------------------------------------------------
|
|
113
|
+
// Generation
|
|
114
|
+
// -------------------------------------------------------------------------
|
|
115
|
+
/**
|
|
116
|
+
* Generate music from a text prompt using the Fal.ai queue API.
|
|
117
|
+
*
|
|
118
|
+
* Submits the task, polls until complete, then fetches the result.
|
|
119
|
+
*
|
|
120
|
+
* @param request - Music generation request with prompt and optional params.
|
|
121
|
+
* @returns The generated audio result envelope.
|
|
122
|
+
*
|
|
123
|
+
* @throws {Error} If the provider is not initialized.
|
|
124
|
+
* @throws {Error} If the API returns an error or times out.
|
|
125
|
+
*/
|
|
126
|
+
async generateMusic(request) {
|
|
127
|
+
if (!this.isInitialized) {
|
|
128
|
+
throw new Error('Fal.ai audio provider is not initialized. Call initialize() first.');
|
|
129
|
+
}
|
|
130
|
+
return this._generate(request.prompt, request.durationSec, request.modelId);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Generate a sound effect from a text prompt using the Fal.ai queue API.
|
|
134
|
+
*
|
|
135
|
+
* Submits the task, polls until complete, then fetches the result.
|
|
136
|
+
*
|
|
137
|
+
* @param request - SFX generation request with prompt and optional params.
|
|
138
|
+
* @returns The generated audio result envelope.
|
|
139
|
+
*
|
|
140
|
+
* @throws {Error} If the provider is not initialized.
|
|
141
|
+
* @throws {Error} If the API returns an error or times out.
|
|
142
|
+
*/
|
|
143
|
+
async generateSFX(request) {
|
|
144
|
+
if (!this.isInitialized) {
|
|
145
|
+
throw new Error('Fal.ai audio provider is not initialized. Call initialize() first.');
|
|
146
|
+
}
|
|
147
|
+
return this._generate(request.prompt, request.durationSec, request.modelId);
|
|
148
|
+
}
|
|
149
|
+
// -------------------------------------------------------------------------
|
|
150
|
+
// Capability query
|
|
151
|
+
// -------------------------------------------------------------------------
|
|
152
|
+
/**
|
|
153
|
+
* Fal.ai audio supports both music and SFX generation.
|
|
154
|
+
*
|
|
155
|
+
* @param capability - The capability to check.
|
|
156
|
+
* @returns `true` for both `'music'` and `'sfx'`.
|
|
157
|
+
*/
|
|
158
|
+
supports(capability) {
|
|
159
|
+
return capability === 'music' || capability === 'sfx';
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Release any resources held by the provider. No-op for HTTP-only providers.
|
|
163
|
+
*/
|
|
164
|
+
async shutdown() {
|
|
165
|
+
this.isInitialized = false;
|
|
166
|
+
}
|
|
167
|
+
// -------------------------------------------------------------------------
|
|
168
|
+
// Private helpers
|
|
169
|
+
// -------------------------------------------------------------------------
|
|
170
|
+
/**
|
|
171
|
+
* Run the full three-step generation flow: submit, poll, fetch.
|
|
172
|
+
*
|
|
173
|
+
* @param prompt - Text description of the desired audio.
|
|
174
|
+
* @param durationSec - Desired duration in seconds.
|
|
175
|
+
* @param modelId - Optional model override.
|
|
176
|
+
* @returns Normalized audio result envelope.
|
|
177
|
+
*
|
|
178
|
+
* @throws {Error} If any step of the flow fails.
|
|
179
|
+
* @internal
|
|
180
|
+
*/
|
|
181
|
+
async _generate(prompt, durationSec, modelId) {
|
|
182
|
+
const model = modelId || this.defaultModelId || 'fal-ai/stable-audio';
|
|
183
|
+
const body = {
|
|
184
|
+
prompt,
|
|
185
|
+
};
|
|
186
|
+
if (durationSec !== undefined)
|
|
187
|
+
body.duration = durationSec;
|
|
188
|
+
// Three-step flow: submit -> poll -> fetch
|
|
189
|
+
const requestId = await this._submitTask(model, body);
|
|
190
|
+
await this._pollStatus(model, requestId);
|
|
191
|
+
const result = await this._fetchResult(model, requestId);
|
|
192
|
+
return this._buildResult(result, model);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Submit a generation task to the Fal.ai queue.
|
|
196
|
+
*
|
|
197
|
+
* @param model - Full model path (e.g. 'fal-ai/stable-audio').
|
|
198
|
+
* @param body - Request body with prompt and generation params.
|
|
199
|
+
* @returns The request_id for status polling.
|
|
200
|
+
*
|
|
201
|
+
* @throws {Error} If the submission request fails.
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
204
|
+
async _submitTask(model, body) {
|
|
205
|
+
const url = `${this._config.baseURL}/${model}`;
|
|
206
|
+
const response = await fetch(url, {
|
|
207
|
+
method: 'POST',
|
|
208
|
+
headers: {
|
|
209
|
+
Authorization: `Key ${this._config.apiKey}`,
|
|
210
|
+
'Content-Type': 'application/json',
|
|
211
|
+
},
|
|
212
|
+
body: JSON.stringify(body),
|
|
213
|
+
});
|
|
214
|
+
if (!response.ok) {
|
|
215
|
+
const errorText = await response.text();
|
|
216
|
+
throw new Error(`Fal.ai audio generation submission failed (${response.status}): ${errorText}`);
|
|
217
|
+
}
|
|
218
|
+
const data = (await response.json());
|
|
219
|
+
if (!data.request_id) {
|
|
220
|
+
throw new Error('Fal.ai audio submission response missing request_id.');
|
|
221
|
+
}
|
|
222
|
+
return data.request_id;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Poll the Fal.ai status endpoint until the task completes or times out.
|
|
226
|
+
*
|
|
227
|
+
* @param model - Full model path.
|
|
228
|
+
* @param requestId - The request ID from submission.
|
|
229
|
+
*
|
|
230
|
+
* @throws {Error} If the generation fails or times out.
|
|
231
|
+
* @internal
|
|
232
|
+
*/
|
|
233
|
+
async _pollStatus(model, requestId) {
|
|
234
|
+
const startedAt = Date.now();
|
|
235
|
+
while (Date.now() - startedAt < this._config.timeoutMs) {
|
|
236
|
+
const url = `${this._config.baseURL}/${model}/requests/${requestId}/status`;
|
|
237
|
+
const response = await fetch(url, {
|
|
238
|
+
headers: {
|
|
239
|
+
Authorization: `Key ${this._config.apiKey}`,
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
if (!response.ok) {
|
|
243
|
+
const errorText = await response.text();
|
|
244
|
+
throw new Error(`Fal.ai audio status polling failed (${response.status}): ${errorText}`);
|
|
245
|
+
}
|
|
246
|
+
const data = (await response.json());
|
|
247
|
+
if (data.status === 'COMPLETED') {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (data.status === 'FAILED') {
|
|
251
|
+
throw new Error(`Fal.ai audio generation failed for request ${requestId}.`);
|
|
252
|
+
}
|
|
253
|
+
// 'IN_QUEUE' or 'IN_PROGRESS' — wait before next poll
|
|
254
|
+
await sleep(this._config.pollIntervalMs);
|
|
255
|
+
}
|
|
256
|
+
throw new Error(`Fal.ai audio generation timed out after ${this._config.timeoutMs}ms for request ${requestId}.`);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Fetch the completed generation result from the Fal.ai result endpoint.
|
|
260
|
+
*
|
|
261
|
+
* Called after polling confirms the task is COMPLETED.
|
|
262
|
+
*
|
|
263
|
+
* @param model - Full model path.
|
|
264
|
+
* @param requestId - The request ID from submission.
|
|
265
|
+
* @returns The generation result with audio URL.
|
|
266
|
+
*
|
|
267
|
+
* @throws {Error} If the result fetch fails.
|
|
268
|
+
* @internal
|
|
269
|
+
*/
|
|
270
|
+
async _fetchResult(model, requestId) {
|
|
271
|
+
const url = `${this._config.baseURL}/${model}/requests/${requestId}`;
|
|
272
|
+
const response = await fetch(url, {
|
|
273
|
+
headers: {
|
|
274
|
+
Authorization: `Key ${this._config.apiKey}`,
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
if (!response.ok) {
|
|
278
|
+
const errorText = await response.text();
|
|
279
|
+
throw new Error(`Fal.ai audio result fetch failed (${response.status}): ${errorText}`);
|
|
280
|
+
}
|
|
281
|
+
return (await response.json());
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Build an {@link AudioResult} from a completed Fal.ai result.
|
|
285
|
+
*
|
|
286
|
+
* @param result - The Fal.ai result response.
|
|
287
|
+
* @param model - Model ID used for the generation.
|
|
288
|
+
* @returns Normalized audio result envelope.
|
|
289
|
+
*
|
|
290
|
+
* @throws {Error} If the result has no audio URL.
|
|
291
|
+
* @internal
|
|
292
|
+
*/
|
|
293
|
+
_buildResult(result, model) {
|
|
294
|
+
if (!result.audio?.url) {
|
|
295
|
+
throw new Error('Fal.ai audio generation completed but returned no audio output.');
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
created: Math.floor(Date.now() / 1000),
|
|
299
|
+
modelId: model,
|
|
300
|
+
providerId: this.providerId,
|
|
301
|
+
audio: [{
|
|
302
|
+
url: result.audio.url,
|
|
303
|
+
mimeType: result.audio.content_type ?? 'audio/mpeg',
|
|
304
|
+
durationSec: result.audio.duration,
|
|
305
|
+
providerMetadata: {
|
|
306
|
+
seed: result.seed,
|
|
307
|
+
},
|
|
308
|
+
}],
|
|
309
|
+
usage: {
|
|
310
|
+
totalAudioClips: 1,
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=FalAudioProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FalAudioProvider.js","sourceRoot":"","sources":["../../../../src/core/audio/providers/FalAudioProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AA4FH,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;GAKG;AACH,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,gBAAgB;IAA7B;QACE,kBAAkB;QACF,eAAU,GAAG,WAAW,CAAC;QAEzC,kBAAkB;QACX,kBAAa,GAAG,KAAK,CAAC;IAgS/B,CAAC;IAxRC,4EAA4E;IAC5E,YAAY;IACZ,4EAA4E;IAE5E;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CAAC,MAA+B;QAC9C,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7E,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QAED,IAAI,CAAC,OAAO,GAAG;YACb,MAAM;YACN,OAAO,EACL,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC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;;;;;;;;OASG;IACK,YAAY,CAAC,MAA8B,EAAE,KAAa;QAChE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;QACrF,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;YACtC,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,KAAK,EAAE,CAAC;oBACN,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG;oBACrB,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,IAAI,YAAY;oBACnD,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ;oBAClC,gBAAgB,EAAE;wBAChB,IAAI,EAAE,MAAM,CAAC,IAAI;qBAClB;iBACF,CAAC;YACF,KAAK,EAAE;gBACL,eAAe,EAAE,CAAC;aACnB;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/audio/providers/MusicGenLocalProvider
|
|
3
|
+
*
|
|
4
|
+
* Local music generation provider using Meta's MusicGen model via
|
|
5
|
+
* the `@huggingface/transformers` library.
|
|
6
|
+
*
|
|
7
|
+
* MusicGen runs entirely on the local machine without any API keys or
|
|
8
|
+
* network requests. The model is loaded lazily on first use through the
|
|
9
|
+
* `pipeline('text-to-audio', ...)` API from HuggingFace Transformers.js.
|
|
10
|
+
*
|
|
11
|
+
* ## Requirements
|
|
12
|
+
*
|
|
13
|
+
* - `@huggingface/transformers` must be installed as a peer dependency.
|
|
14
|
+
* If not installed, the provider throws a helpful error message.
|
|
15
|
+
* - Sufficient RAM/VRAM for model inference (Xenova/musicgen-small ~1GB).
|
|
16
|
+
*
|
|
17
|
+
* ## Supported models
|
|
18
|
+
*
|
|
19
|
+
* | Model ID | Description |
|
|
20
|
+
* |----------------------------|-----------------------------------|
|
|
21
|
+
* | `Xenova/musicgen-small` | MusicGen Small — default, ~1GB |
|
|
22
|
+
*
|
|
23
|
+
* ## API flow (local inference)
|
|
24
|
+
*
|
|
25
|
+
* 1. **Load** — `pipeline('text-to-audio', modelId)` (lazy, cached).
|
|
26
|
+
* 2. **Generate** — `pipeline(prompt, { max_new_tokens })` returns audio tensor.
|
|
27
|
+
* 3. **Encode** — Convert raw audio data to WAV format.
|
|
28
|
+
*
|
|
29
|
+
* @see {@link IAudioGenerator} for the provider interface contract.
|
|
30
|
+
* @see {@link AudioGenLocalProvider} for the SFX counterpart.
|
|
31
|
+
*/
|
|
32
|
+
import type { IAudioGenerator } from '../IAudioGenerator.js';
|
|
33
|
+
import type { MusicGenerateRequest, SFXGenerateRequest, AudioResult } from '../types.js';
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for the MusicGen local provider.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const config: MusicGenLocalProviderConfig = {
|
|
40
|
+
* modelId: 'Xenova/musicgen-small',
|
|
41
|
+
* };
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export interface MusicGenLocalProviderConfig {
|
|
45
|
+
/**
|
|
46
|
+
* HuggingFace model ID for the MusicGen model.
|
|
47
|
+
* @default 'Xenova/musicgen-small'
|
|
48
|
+
*/
|
|
49
|
+
modelId?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Local music generation provider using Meta's MusicGen model.
|
|
53
|
+
*
|
|
54
|
+
* Runs inference entirely on the local machine via `@huggingface/transformers`.
|
|
55
|
+
* The model is loaded lazily on first call to `generateMusic()` or
|
|
56
|
+
* explicitly via `initialize()`.
|
|
57
|
+
*
|
|
58
|
+
* @implements {IAudioGenerator}
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const provider = new MusicGenLocalProvider();
|
|
63
|
+
* await provider.initialize({ modelId: 'Xenova/musicgen-small' });
|
|
64
|
+
*
|
|
65
|
+
* const result = await provider.generateMusic({
|
|
66
|
+
* prompt: 'A calm ambient soundscape with synth pads',
|
|
67
|
+
* durationSec: 10,
|
|
68
|
+
* });
|
|
69
|
+
* console.log(result.audio[0].base64?.substring(0, 50) + '...');
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare class MusicGenLocalProvider implements IAudioGenerator {
|
|
73
|
+
/** @inheritdoc */
|
|
74
|
+
readonly providerId = "musicgen-local";
|
|
75
|
+
/** @inheritdoc */
|
|
76
|
+
isInitialized: boolean;
|
|
77
|
+
/** @inheritdoc */
|
|
78
|
+
defaultModelId?: string;
|
|
79
|
+
/** The loaded text-to-audio pipeline instance. */
|
|
80
|
+
private _pipeline;
|
|
81
|
+
/** The resolved model ID. */
|
|
82
|
+
private _modelId;
|
|
83
|
+
/**
|
|
84
|
+
* Initialize the provider and optionally pre-load the model.
|
|
85
|
+
*
|
|
86
|
+
* The model is loaded lazily on first generation call. Calling initialize
|
|
87
|
+
* sets the configuration but does not load the model unless the pipeline
|
|
88
|
+
* was already created.
|
|
89
|
+
*
|
|
90
|
+
* @param config - Configuration object with optional `modelId`.
|
|
91
|
+
*/
|
|
92
|
+
initialize(config: Record<string, unknown>): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Generate music from a text prompt using the local MusicGen model.
|
|
95
|
+
*
|
|
96
|
+
* On first call, loads the model pipeline (may take several seconds).
|
|
97
|
+
* Subsequent calls reuse the cached pipeline instance.
|
|
98
|
+
*
|
|
99
|
+
* @param request - Music generation request with prompt and optional params.
|
|
100
|
+
* @returns The generated audio result envelope with base64-encoded WAV data.
|
|
101
|
+
*
|
|
102
|
+
* @throws {Error} If the provider is not initialized.
|
|
103
|
+
* @throws {Error} If `@huggingface/transformers` is not installed.
|
|
104
|
+
*/
|
|
105
|
+
generateMusic(request: MusicGenerateRequest): Promise<AudioResult>;
|
|
106
|
+
/**
|
|
107
|
+
* SFX generation is not supported by MusicGen.
|
|
108
|
+
*
|
|
109
|
+
* @throws {Error} Always throws — use {@link AudioGenLocalProvider} instead.
|
|
110
|
+
*/
|
|
111
|
+
generateSFX(_request: SFXGenerateRequest): Promise<AudioResult>;
|
|
112
|
+
/**
|
|
113
|
+
* MusicGen supports music generation only.
|
|
114
|
+
*
|
|
115
|
+
* @param capability - The capability to check.
|
|
116
|
+
* @returns `true` only for `'music'`; `false` for `'sfx'`.
|
|
117
|
+
*/
|
|
118
|
+
supports(capability: 'music' | 'sfx'): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Release model resources and reset initialization state.
|
|
121
|
+
*/
|
|
122
|
+
shutdown(): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Ensure the text-to-audio pipeline is loaded, creating it lazily if needed.
|
|
125
|
+
*
|
|
126
|
+
* Uses dynamic `import()` to load `@huggingface/transformers` as an optional
|
|
127
|
+
* peer dependency. Throws a helpful error if the package is not installed.
|
|
128
|
+
*
|
|
129
|
+
* @returns The loaded pipeline callable.
|
|
130
|
+
*
|
|
131
|
+
* @throws {Error} If `@huggingface/transformers` is not installed.
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
private _ensurePipeline;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=MusicGenLocalProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MusicGenLocalProvider.d.ts","sourceRoot":"","sources":["../../../../src/core/audio/providers/MusicGenLocalProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAMzF;;;;;;;;;GASG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA4DD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC3D,kBAAkB;IAClB,SAAgB,UAAU,oBAAoB;IAE9C,kBAAkB;IACX,aAAa,UAAS;IAE7B,kBAAkB;IACX,cAAc,CAAC,EAAE,MAAM,CAAC;IAE/B,kDAAkD;IAClD,OAAO,CAAC,SAAS,CAAiB;IAElC,6BAA6B;IAC7B,OAAO,CAAC,QAAQ,CAA2B;IAM3C;;;;;;;;OAQG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAahE;;;;;;;;;;;OAWG;IACG,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IAsCxE;;;;OAIG;IACG,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAUrE;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO;IAI9C;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B;;;;;;;;;;OAUG;YACW,eAAe;CAgB9B"}
|