@framers/agentos 0.1.0
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 +98 -0
- package/README.md +576 -0
- package/dist/api/AgentOS.d.ts +451 -0
- package/dist/api/AgentOS.d.ts.map +1 -0
- package/dist/api/AgentOS.js +1157 -0
- package/dist/api/AgentOS.js.map +1 -0
- package/dist/api/AgentOSOrchestrator.d.ts +157 -0
- package/dist/api/AgentOSOrchestrator.d.ts.map +1 -0
- package/dist/api/AgentOSOrchestrator.js +679 -0
- package/dist/api/AgentOSOrchestrator.js.map +1 -0
- package/dist/api/interfaces/IAgentOS.d.ts +138 -0
- package/dist/api/interfaces/IAgentOS.d.ts.map +1 -0
- package/dist/api/interfaces/IAgentOS.js +11 -0
- package/dist/api/interfaces/IAgentOS.js.map +1 -0
- package/dist/api/interfaces/IUnifiedAgent.d.ts +126 -0
- package/dist/api/interfaces/IUnifiedAgent.d.ts.map +1 -0
- package/dist/api/interfaces/IUnifiedAgent.js +3 -0
- package/dist/api/interfaces/IUnifiedAgent.js.map +1 -0
- package/dist/api/types/AgentOSInput.d.ts +114 -0
- package/dist/api/types/AgentOSInput.d.ts.map +1 -0
- package/dist/api/types/AgentOSInput.js +13 -0
- package/dist/api/types/AgentOSInput.js.map +1 -0
- package/dist/api/types/AgentOSResponse.d.ts +170 -0
- package/dist/api/types/AgentOSResponse.d.ts.map +1 -0
- package/dist/api/types/AgentOSResponse.js +25 -0
- package/dist/api/types/AgentOSResponse.js.map +1 -0
- package/dist/cognitive_substrate/GMI.d.ts +148 -0
- package/dist/cognitive_substrate/GMI.d.ts.map +1 -0
- package/dist/cognitive_substrate/GMI.js +1003 -0
- package/dist/cognitive_substrate/GMI.js.map +1 -0
- package/dist/cognitive_substrate/GMIManager.d.ts +98 -0
- package/dist/cognitive_substrate/GMIManager.d.ts.map +1 -0
- package/dist/cognitive_substrate/GMIManager.js +517 -0
- package/dist/cognitive_substrate/GMIManager.js.map +1 -0
- package/dist/cognitive_substrate/IGMI.d.ts +469 -0
- package/dist/cognitive_substrate/IGMI.d.ts.map +1 -0
- package/dist/cognitive_substrate/IGMI.js +111 -0
- package/dist/cognitive_substrate/IGMI.js.map +1 -0
- package/dist/cognitive_substrate/memory/IWorkingMemory.d.ts +139 -0
- package/dist/cognitive_substrate/memory/IWorkingMemory.d.ts.map +1 -0
- package/dist/cognitive_substrate/memory/IWorkingMemory.js +14 -0
- package/dist/cognitive_substrate/memory/IWorkingMemory.js.map +1 -0
- package/dist/cognitive_substrate/memory/InMemoryWorkingMemory.d.ts +143 -0
- package/dist/cognitive_substrate/memory/InMemoryWorkingMemory.d.ts.map +1 -0
- package/dist/cognitive_substrate/memory/InMemoryWorkingMemory.js +186 -0
- package/dist/cognitive_substrate/memory/InMemoryWorkingMemory.js.map +1 -0
- package/dist/cognitive_substrate/persona_overlays/PersonaOverlayManager.d.ts +33 -0
- package/dist/cognitive_substrate/persona_overlays/PersonaOverlayManager.d.ts.map +1 -0
- package/dist/cognitive_substrate/persona_overlays/PersonaOverlayManager.js +138 -0
- package/dist/cognitive_substrate/persona_overlays/PersonaOverlayManager.js.map +1 -0
- package/dist/cognitive_substrate/persona_overlays/PersonaOverlayTypes.d.ts +32 -0
- package/dist/cognitive_substrate/persona_overlays/PersonaOverlayTypes.d.ts.map +1 -0
- package/dist/cognitive_substrate/persona_overlays/PersonaOverlayTypes.js +2 -0
- package/dist/cognitive_substrate/persona_overlays/PersonaOverlayTypes.js.map +1 -0
- package/dist/cognitive_substrate/personas/IPersonaDefinition.d.ts +336 -0
- package/dist/cognitive_substrate/personas/IPersonaDefinition.d.ts.map +1 -0
- package/dist/cognitive_substrate/personas/IPersonaDefinition.js +8 -0
- package/dist/cognitive_substrate/personas/IPersonaDefinition.js.map +1 -0
- package/dist/cognitive_substrate/personas/IPersonaLoader.d.ts +78 -0
- package/dist/cognitive_substrate/personas/IPersonaLoader.d.ts.map +1 -0
- package/dist/cognitive_substrate/personas/IPersonaLoader.js +9 -0
- package/dist/cognitive_substrate/personas/IPersonaLoader.js.map +1 -0
- package/dist/cognitive_substrate/personas/PersonaLoader.d.ts +60 -0
- package/dist/cognitive_substrate/personas/PersonaLoader.d.ts.map +1 -0
- package/dist/cognitive_substrate/personas/PersonaLoader.js +138 -0
- package/dist/cognitive_substrate/personas/PersonaLoader.js.map +1 -0
- package/dist/cognitive_substrate/personas/PersonaValidation.d.ts +139 -0
- package/dist/cognitive_substrate/personas/PersonaValidation.d.ts.map +1 -0
- package/dist/cognitive_substrate/personas/PersonaValidation.js +277 -0
- package/dist/cognitive_substrate/personas/PersonaValidation.js.map +1 -0
- package/dist/cognitive_substrate/personas/definitions/atlas_systems_architect.json +29 -0
- package/dist/cognitive_substrate/personas/definitions/default_assistant_persona.json +346 -0
- package/dist/cognitive_substrate/personas/definitions/default_free_assistant.json +13 -0
- package/dist/cognitive_substrate/personas/definitions/index.d.ts +14 -0
- package/dist/cognitive_substrate/personas/definitions/index.d.ts.map +1 -0
- package/dist/cognitive_substrate/personas/definitions/index.js +35 -0
- package/dist/cognitive_substrate/personas/definitions/index.js.map +1 -0
- package/dist/cognitive_substrate/personas/definitions/nerf_generalist.json +11 -0
- package/dist/cognitive_substrate/personas/definitions/v_researcher.json +11 -0
- package/dist/config/AgentOSConfig.d.ts +74 -0
- package/dist/config/AgentOSConfig.d.ts.map +1 -0
- package/dist/config/AgentOSConfig.js +399 -0
- package/dist/config/AgentOSConfig.js.map +1 -0
- package/dist/config/EmbeddingManagerConfiguration.d.ts +190 -0
- package/dist/config/EmbeddingManagerConfiguration.d.ts.map +1 -0
- package/dist/config/EmbeddingManagerConfiguration.js +16 -0
- package/dist/config/EmbeddingManagerConfiguration.js.map +1 -0
- package/dist/config/MemoryLifecycleManagerConfiguration.d.ts +165 -0
- package/dist/config/MemoryLifecycleManagerConfiguration.d.ts.map +1 -0
- package/dist/config/MemoryLifecycleManagerConfiguration.js +69 -0
- package/dist/config/MemoryLifecycleManagerConfiguration.js.map +1 -0
- package/dist/config/RetrievalAugmentorConfiguration.d.ts +98 -0
- package/dist/config/RetrievalAugmentorConfiguration.d.ts.map +1 -0
- package/dist/config/RetrievalAugmentorConfiguration.js +47 -0
- package/dist/config/RetrievalAugmentorConfiguration.js.map +1 -0
- package/dist/config/ToolOrchestratorConfig.d.ts +69 -0
- package/dist/config/ToolOrchestratorConfig.d.ts.map +1 -0
- package/dist/config/ToolOrchestratorConfig.js +11 -0
- package/dist/config/ToolOrchestratorConfig.js.map +1 -0
- package/dist/config/VectorStoreConfiguration.d.ts +223 -0
- package/dist/config/VectorStoreConfiguration.d.ts.map +1 -0
- package/dist/config/VectorStoreConfiguration.js +59 -0
- package/dist/config/VectorStoreConfiguration.js.map +1 -0
- package/dist/config/extension-secrets.json +38 -0
- package/dist/config/extensionSecrets.d.ts +13 -0
- package/dist/config/extensionSecrets.d.ts.map +1 -0
- package/dist/config/extensionSecrets.js +24 -0
- package/dist/config/extensionSecrets.js.map +1 -0
- package/dist/core/agency/AgencyMemoryManager.d.ts +300 -0
- package/dist/core/agency/AgencyMemoryManager.d.ts.map +1 -0
- package/dist/core/agency/AgencyMemoryManager.js +657 -0
- package/dist/core/agency/AgencyMemoryManager.js.map +1 -0
- package/dist/core/agency/AgencyRegistry.d.ts +100 -0
- package/dist/core/agency/AgencyRegistry.d.ts.map +1 -0
- package/dist/core/agency/AgencyRegistry.js +209 -0
- package/dist/core/agency/AgencyRegistry.js.map +1 -0
- package/dist/core/agency/AgencyTypes.d.ts +200 -0
- package/dist/core/agency/AgencyTypes.d.ts.map +1 -0
- package/dist/core/agency/AgencyTypes.js +7 -0
- package/dist/core/agency/AgencyTypes.js.map +1 -0
- package/dist/core/agency/AgentCommunicationBus.d.ts +150 -0
- package/dist/core/agency/AgentCommunicationBus.d.ts.map +1 -0
- package/dist/core/agency/AgentCommunicationBus.js +568 -0
- package/dist/core/agency/AgentCommunicationBus.js.map +1 -0
- package/dist/core/agency/IAgentCommunicationBus.d.ts +469 -0
- package/dist/core/agency/IAgentCommunicationBus.d.ts.map +1 -0
- package/dist/core/agency/IAgentCommunicationBus.js +40 -0
- package/dist/core/agency/IAgentCommunicationBus.js.map +1 -0
- package/dist/core/agency/index.d.ts +18 -0
- package/dist/core/agency/index.d.ts.map +1 -0
- package/dist/core/agency/index.js +18 -0
- package/dist/core/agency/index.js.map +1 -0
- package/dist/core/agents/AgentCore.d.ts +385 -0
- package/dist/core/agents/AgentCore.d.ts.map +1 -0
- package/dist/core/agents/AgentCore.js +527 -0
- package/dist/core/agents/AgentCore.js.map +1 -0
- package/dist/core/agents/AgentFactory.d.ts +123 -0
- package/dist/core/agents/AgentFactory.d.ts.map +1 -0
- package/dist/core/agents/AgentFactory.js +232 -0
- package/dist/core/agents/AgentFactory.js.map +1 -0
- package/dist/core/agents/AgentPoolAgent.d.ts +244 -0
- package/dist/core/agents/AgentPoolAgent.d.ts.map +1 -0
- package/dist/core/agents/AgentPoolAgent.js +697 -0
- package/dist/core/agents/AgentPoolAgent.js.map +1 -0
- package/dist/core/agents/AgentPoolConfig.d.ts +191 -0
- package/dist/core/agents/AgentPoolConfig.d.ts.map +1 -0
- package/dist/core/agents/AgentPoolConfig.js +58 -0
- package/dist/core/agents/AgentPoolConfig.js.map +1 -0
- package/dist/core/agents/IAgent.d.ts +226 -0
- package/dist/core/agents/IAgent.d.ts.map +1 -0
- package/dist/core/agents/IAgent.js +14 -0
- package/dist/core/agents/IAgent.js.map +1 -0
- package/dist/core/agents/IAgentFactory.d.ts +137 -0
- package/dist/core/agents/IAgentFactory.d.ts.map +1 -0
- package/dist/core/agents/IAgentFactory.js +13 -0
- package/dist/core/agents/IAgentFactory.js.map +1 -0
- package/dist/core/agents/tools/Tool.d.ts +17 -0
- package/dist/core/agents/tools/Tool.d.ts.map +1 -0
- package/dist/core/agents/tools/Tool.js +8 -0
- package/dist/core/agents/tools/Tool.js.map +1 -0
- package/dist/core/ai_utilities/HybridUtilityAI.d.ts +1 -0
- package/dist/core/ai_utilities/HybridUtilityAI.d.ts.map +1 -0
- package/dist/core/ai_utilities/HybridUtilityAI.js +2 -0
- package/dist/core/ai_utilities/HybridUtilityAI.js.map +1 -0
- package/dist/core/ai_utilities/IUtilityAI.d.ts +212 -0
- package/dist/core/ai_utilities/IUtilityAI.d.ts.map +1 -0
- package/dist/core/ai_utilities/IUtilityAI.js +11 -0
- package/dist/core/ai_utilities/IUtilityAI.js.map +1 -0
- package/dist/core/ai_utilities/LLMUtilityAI.d.ts +94 -0
- package/dist/core/ai_utilities/LLMUtilityAI.d.ts.map +1 -0
- package/dist/core/ai_utilities/LLMUtilityAI.js +434 -0
- package/dist/core/ai_utilities/LLMUtilityAI.js.map +1 -0
- package/dist/core/ai_utilities/StatisticalUtilityAI.d.ts +102 -0
- package/dist/core/ai_utilities/StatisticalUtilityAI.d.ts.map +1 -0
- package/dist/core/ai_utilities/StatisticalUtilityAI.js +617 -0
- package/dist/core/ai_utilities/StatisticalUtilityAI.js.map +1 -0
- package/dist/core/conversation/ConversationContext.d.ts +259 -0
- package/dist/core/conversation/ConversationContext.d.ts.map +1 -0
- package/dist/core/conversation/ConversationContext.js +450 -0
- package/dist/core/conversation/ConversationContext.js.map +1 -0
- package/dist/core/conversation/ConversationManager.d.ts +223 -0
- package/dist/core/conversation/ConversationManager.d.ts.map +1 -0
- package/dist/core/conversation/ConversationManager.js +558 -0
- package/dist/core/conversation/ConversationManager.js.map +1 -0
- package/dist/core/conversation/ConversationMessage.d.ts +184 -0
- package/dist/core/conversation/ConversationMessage.d.ts.map +1 -0
- package/dist/core/conversation/ConversationMessage.js +66 -0
- package/dist/core/conversation/ConversationMessage.js.map +1 -0
- package/dist/core/evaluation/Evaluator.d.ts +28 -0
- package/dist/core/evaluation/Evaluator.d.ts.map +1 -0
- package/dist/core/evaluation/Evaluator.js +490 -0
- package/dist/core/evaluation/Evaluator.js.map +1 -0
- package/dist/core/evaluation/IEvaluator.d.ts +309 -0
- package/dist/core/evaluation/IEvaluator.d.ts.map +1 -0
- package/dist/core/evaluation/IEvaluator.js +12 -0
- package/dist/core/evaluation/IEvaluator.js.map +1 -0
- package/dist/core/evaluation/LLMJudge.d.ts +105 -0
- package/dist/core/evaluation/LLMJudge.d.ts.map +1 -0
- package/dist/core/evaluation/LLMJudge.js +229 -0
- package/dist/core/evaluation/LLMJudge.js.map +1 -0
- package/dist/core/evaluation/index.d.ts +9 -0
- package/dist/core/evaluation/index.d.ts.map +1 -0
- package/dist/core/evaluation/index.js +9 -0
- package/dist/core/evaluation/index.js.map +1 -0
- package/dist/core/guardrails/IGuardrailService.d.ts +142 -0
- package/dist/core/guardrails/IGuardrailService.d.ts.map +1 -0
- package/dist/core/guardrails/IGuardrailService.js +24 -0
- package/dist/core/guardrails/IGuardrailService.js.map +1 -0
- package/dist/core/guardrails/guardrailDispatcher.d.ts +36 -0
- package/dist/core/guardrails/guardrailDispatcher.d.ts.map +1 -0
- package/dist/core/guardrails/guardrailDispatcher.js +240 -0
- package/dist/core/guardrails/guardrailDispatcher.js.map +1 -0
- package/dist/core/hitl/HumanInteractionManager.d.ts +146 -0
- package/dist/core/hitl/HumanInteractionManager.d.ts.map +1 -0
- package/dist/core/hitl/HumanInteractionManager.js +491 -0
- package/dist/core/hitl/HumanInteractionManager.js.map +1 -0
- package/dist/core/hitl/IHumanInteractionManager.d.ts +521 -0
- package/dist/core/hitl/IHumanInteractionManager.d.ts.map +1 -0
- package/dist/core/hitl/IHumanInteractionManager.js +33 -0
- package/dist/core/hitl/IHumanInteractionManager.js.map +1 -0
- package/dist/core/hitl/index.d.ts +17 -0
- package/dist/core/hitl/index.d.ts.map +1 -0
- package/dist/core/hitl/index.js +17 -0
- package/dist/core/hitl/index.js.map +1 -0
- package/dist/core/knowledge/IKnowledgeGraph.d.ts +351 -0
- package/dist/core/knowledge/IKnowledgeGraph.d.ts.map +1 -0
- package/dist/core/knowledge/IKnowledgeGraph.js +10 -0
- package/dist/core/knowledge/IKnowledgeGraph.js.map +1 -0
- package/dist/core/knowledge/KnowledgeGraph.d.ts +93 -0
- package/dist/core/knowledge/KnowledgeGraph.d.ts.map +1 -0
- package/dist/core/knowledge/KnowledgeGraph.js +601 -0
- package/dist/core/knowledge/KnowledgeGraph.js.map +1 -0
- package/dist/core/knowledge/index.d.ts +8 -0
- package/dist/core/knowledge/index.d.ts.map +1 -0
- package/dist/core/knowledge/index.js +8 -0
- package/dist/core/knowledge/index.js.map +1 -0
- package/dist/core/language/LanguageService.d.ts +77 -0
- package/dist/core/language/LanguageService.d.ts.map +1 -0
- package/dist/core/language/LanguageService.js +305 -0
- package/dist/core/language/LanguageService.js.map +1 -0
- package/dist/core/language/index.d.ts +6 -0
- package/dist/core/language/index.d.ts.map +1 -0
- package/dist/core/language/index.js +6 -0
- package/dist/core/language/index.js.map +1 -0
- package/dist/core/language/interfaces.d.ts +168 -0
- package/dist/core/language/interfaces.d.ts.map +1 -0
- package/dist/core/language/interfaces.js +37 -0
- package/dist/core/language/interfaces.js.map +1 -0
- package/dist/core/language/providers/DeepLTranslationProvider.d.ts +16 -0
- package/dist/core/language/providers/DeepLTranslationProvider.d.ts.map +1 -0
- package/dist/core/language/providers/DeepLTranslationProvider.js +28 -0
- package/dist/core/language/providers/DeepLTranslationProvider.js.map +1 -0
- package/dist/core/language/providers/OpenAITranslationProvider.d.ts +17 -0
- package/dist/core/language/providers/OpenAITranslationProvider.d.ts.map +1 -0
- package/dist/core/language/providers/OpenAITranslationProvider.js +34 -0
- package/dist/core/language/providers/OpenAITranslationProvider.js.map +1 -0
- package/dist/core/language/providers/WhisperDetectionProvider.d.ts +16 -0
- package/dist/core/language/providers/WhisperDetectionProvider.d.ts.map +1 -0
- package/dist/core/language/providers/WhisperDetectionProvider.js +15 -0
- package/dist/core/language/providers/WhisperDetectionProvider.js.map +1 -0
- package/dist/core/llm/IPromptEngine.d.ts +627 -0
- package/dist/core/llm/IPromptEngine.d.ts.map +1 -0
- package/dist/core/llm/IPromptEngine.js +81 -0
- package/dist/core/llm/IPromptEngine.js.map +1 -0
- package/dist/core/llm/PromptEngine.d.ts +108 -0
- package/dist/core/llm/PromptEngine.d.ts.map +1 -0
- package/dist/core/llm/PromptEngine.js +872 -0
- package/dist/core/llm/PromptEngine.js.map +1 -0
- package/dist/core/llm/providers/AIModelProviderManager.d.ts +74 -0
- package/dist/core/llm/providers/AIModelProviderManager.d.ts.map +1 -0
- package/dist/core/llm/providers/AIModelProviderManager.js +263 -0
- package/dist/core/llm/providers/AIModelProviderManager.js.map +1 -0
- package/dist/core/llm/providers/IProvider.d.ts +327 -0
- package/dist/core/llm/providers/IProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/IProvider.js +39 -0
- package/dist/core/llm/providers/IProvider.js.map +1 -0
- package/dist/core/llm/providers/errors/OllamaProviderError.d.ts +36 -0
- package/dist/core/llm/providers/errors/OllamaProviderError.d.ts.map +1 -0
- package/dist/core/llm/providers/errors/OllamaProviderError.js +40 -0
- package/dist/core/llm/providers/errors/OllamaProviderError.js.map +1 -0
- package/dist/core/llm/providers/errors/OpenAIProviderError.d.ts +42 -0
- package/dist/core/llm/providers/errors/OpenAIProviderError.d.ts.map +1 -0
- package/dist/core/llm/providers/errors/OpenAIProviderError.js +44 -0
- package/dist/core/llm/providers/errors/OpenAIProviderError.js.map +1 -0
- package/dist/core/llm/providers/errors/OpenRouterProviderError.d.ts +39 -0
- package/dist/core/llm/providers/errors/OpenRouterProviderError.d.ts.map +1 -0
- package/dist/core/llm/providers/errors/OpenRouterProviderError.js +42 -0
- package/dist/core/llm/providers/errors/OpenRouterProviderError.js.map +1 -0
- package/dist/core/llm/providers/errors/ProviderError.d.ts +37 -0
- package/dist/core/llm/providers/errors/ProviderError.d.ts.map +1 -0
- package/dist/core/llm/providers/errors/ProviderError.js +36 -0
- package/dist/core/llm/providers/errors/ProviderError.js.map +1 -0
- package/dist/core/llm/providers/implementations/OllamaProvider.d.ts +80 -0
- package/dist/core/llm/providers/implementations/OllamaProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/OllamaProvider.js +473 -0
- package/dist/core/llm/providers/implementations/OllamaProvider.js.map +1 -0
- package/dist/core/llm/providers/implementations/OpenAIProvider.d.ts +160 -0
- package/dist/core/llm/providers/implementations/OpenAIProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/OpenAIProvider.js +672 -0
- package/dist/core/llm/providers/implementations/OpenAIProvider.js.map +1 -0
- package/dist/core/llm/providers/implementations/OpenRouterProvider.d.ts +51 -0
- package/dist/core/llm/providers/implementations/OpenRouterProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/OpenRouterProvider.js +499 -0
- package/dist/core/llm/providers/implementations/OpenRouterProvider.js.map +1 -0
- package/dist/core/llm/routing/IModelRouter.d.ts +129 -0
- package/dist/core/llm/routing/IModelRouter.d.ts.map +1 -0
- package/dist/core/llm/routing/IModelRouter.js +14 -0
- package/dist/core/llm/routing/IModelRouter.js.map +1 -0
- package/dist/core/llm/routing/ModelRouter.d.ts +157 -0
- package/dist/core/llm/routing/ModelRouter.d.ts.map +1 -0
- package/dist/core/llm/routing/ModelRouter.js +190 -0
- package/dist/core/llm/routing/ModelRouter.js.map +1 -0
- package/dist/core/llm/streaming/StreamingBatcher.d.ts +54 -0
- package/dist/core/llm/streaming/StreamingBatcher.d.ts.map +1 -0
- package/dist/core/llm/streaming/StreamingBatcher.js +173 -0
- package/dist/core/llm/streaming/StreamingBatcher.js.map +1 -0
- package/dist/core/llm/streaming/StreamingReconstructor.d.ts +69 -0
- package/dist/core/llm/streaming/StreamingReconstructor.d.ts.map +1 -0
- package/dist/core/llm/streaming/StreamingReconstructor.js +102 -0
- package/dist/core/llm/streaming/StreamingReconstructor.js.map +1 -0
- package/dist/core/marketplace/IMarketplace.d.ts +500 -0
- package/dist/core/marketplace/IMarketplace.d.ts.map +1 -0
- package/dist/core/marketplace/IMarketplace.js +10 -0
- package/dist/core/marketplace/IMarketplace.js.map +1 -0
- package/dist/core/marketplace/Marketplace.d.ts +122 -0
- package/dist/core/marketplace/Marketplace.d.ts.map +1 -0
- package/dist/core/marketplace/Marketplace.js +591 -0
- package/dist/core/marketplace/Marketplace.js.map +1 -0
- package/dist/core/marketplace/index.d.ts +8 -0
- package/dist/core/marketplace/index.d.ts.map +1 -0
- package/dist/core/marketplace/index.js +8 -0
- package/dist/core/marketplace/index.js.map +1 -0
- package/dist/core/observability/ITracer.d.ts +317 -0
- package/dist/core/observability/ITracer.d.ts.map +1 -0
- package/dist/core/observability/ITracer.js +55 -0
- package/dist/core/observability/ITracer.js.map +1 -0
- package/dist/core/observability/Tracer.d.ts +76 -0
- package/dist/core/observability/Tracer.d.ts.map +1 -0
- package/dist/core/observability/Tracer.js +360 -0
- package/dist/core/observability/Tracer.js.map +1 -0
- package/dist/core/observability/index.d.ts +9 -0
- package/dist/core/observability/index.d.ts.map +1 -0
- package/dist/core/observability/index.js +8 -0
- package/dist/core/observability/index.js.map +1 -0
- package/dist/core/orchestration/AgentOrchestrator.d.ts +243 -0
- package/dist/core/orchestration/AgentOrchestrator.d.ts.map +1 -0
- package/dist/core/orchestration/AgentOrchestrator.js +648 -0
- package/dist/core/orchestration/AgentOrchestrator.js.map +1 -0
- package/dist/core/orchestration/IAgentOrchestrator.d.ts +44 -0
- package/dist/core/orchestration/IAgentOrchestrator.d.ts.map +1 -0
- package/dist/core/orchestration/IAgentOrchestrator.js +4 -0
- package/dist/core/orchestration/IAgentOrchestrator.js.map +1 -0
- package/dist/core/orchestration/helpers.d.ts +12 -0
- package/dist/core/orchestration/helpers.d.ts.map +1 -0
- package/dist/core/orchestration/helpers.js +36 -0
- package/dist/core/orchestration/helpers.js.map +1 -0
- package/dist/core/planning/IPlanningEngine.d.ts +524 -0
- package/dist/core/planning/IPlanningEngine.d.ts.map +1 -0
- package/dist/core/planning/IPlanningEngine.js +32 -0
- package/dist/core/planning/IPlanningEngine.js.map +1 -0
- package/dist/core/planning/PlanningEngine.d.ts +161 -0
- package/dist/core/planning/PlanningEngine.d.ts.map +1 -0
- package/dist/core/planning/PlanningEngine.js +783 -0
- package/dist/core/planning/PlanningEngine.js.map +1 -0
- package/dist/core/planning/index.d.ts +25 -0
- package/dist/core/planning/index.d.ts.map +1 -0
- package/dist/core/planning/index.js +25 -0
- package/dist/core/planning/index.js.map +1 -0
- package/dist/core/sandbox/CodeSandbox.d.ts +86 -0
- package/dist/core/sandbox/CodeSandbox.d.ts.map +1 -0
- package/dist/core/sandbox/CodeSandbox.js +475 -0
- package/dist/core/sandbox/CodeSandbox.js.map +1 -0
- package/dist/core/sandbox/ICodeSandbox.d.ts +249 -0
- package/dist/core/sandbox/ICodeSandbox.d.ts.map +1 -0
- package/dist/core/sandbox/ICodeSandbox.js +24 -0
- package/dist/core/sandbox/ICodeSandbox.js.map +1 -0
- package/dist/core/sandbox/index.d.ts +9 -0
- package/dist/core/sandbox/index.d.ts.map +1 -0
- package/dist/core/sandbox/index.js +8 -0
- package/dist/core/sandbox/index.js.map +1 -0
- package/dist/core/storage/IStorageAdapter.d.ts +483 -0
- package/dist/core/storage/IStorageAdapter.d.ts.map +1 -0
- package/dist/core/storage/IStorageAdapter.js +19 -0
- package/dist/core/storage/IStorageAdapter.js.map +1 -0
- package/dist/core/storage/InMemoryStorageAdapter.d.ts +192 -0
- package/dist/core/storage/InMemoryStorageAdapter.d.ts.map +1 -0
- package/dist/core/storage/InMemoryStorageAdapter.js +343 -0
- package/dist/core/storage/InMemoryStorageAdapter.js.map +1 -0
- package/dist/core/storage/SqlStorageAdapter.d.ts +262 -0
- package/dist/core/storage/SqlStorageAdapter.d.ts.map +1 -0
- package/dist/core/storage/SqlStorageAdapter.js +485 -0
- package/dist/core/storage/SqlStorageAdapter.js.map +1 -0
- package/dist/core/storage/index.d.ts +14 -0
- package/dist/core/storage/index.d.ts.map +1 -0
- package/dist/core/storage/index.js +14 -0
- package/dist/core/storage/index.js.map +1 -0
- package/dist/core/streaming/IStreamClient.d.ts +72 -0
- package/dist/core/streaming/IStreamClient.d.ts.map +1 -0
- package/dist/core/streaming/IStreamClient.js +12 -0
- package/dist/core/streaming/IStreamClient.js.map +1 -0
- package/dist/core/streaming/StreamingManager.d.ts +242 -0
- package/dist/core/streaming/StreamingManager.d.ts.map +1 -0
- package/dist/core/streaming/StreamingManager.js +282 -0
- package/dist/core/streaming/StreamingManager.js.map +1 -0
- package/dist/core/structured/IStructuredOutputManager.d.ts +701 -0
- package/dist/core/structured/IStructuredOutputManager.d.ts.map +1 -0
- package/dist/core/structured/IStructuredOutputManager.js +74 -0
- package/dist/core/structured/IStructuredOutputManager.js.map +1 -0
- package/dist/core/structured/StructuredOutputManager.d.ts +140 -0
- package/dist/core/structured/StructuredOutputManager.d.ts.map +1 -0
- package/dist/core/structured/StructuredOutputManager.js +1015 -0
- package/dist/core/structured/StructuredOutputManager.js.map +1 -0
- package/dist/core/structured/index.d.ts +34 -0
- package/dist/core/structured/index.d.ts.map +1 -0
- package/dist/core/structured/index.js +34 -0
- package/dist/core/structured/index.js.map +1 -0
- package/dist/core/tools/ITool.d.ts +228 -0
- package/dist/core/tools/ITool.d.ts.map +1 -0
- package/dist/core/tools/ITool.js +11 -0
- package/dist/core/tools/ITool.js.map +1 -0
- package/dist/core/tools/IToolOrchestrator.d.ts +131 -0
- package/dist/core/tools/IToolOrchestrator.d.ts.map +1 -0
- package/dist/core/tools/IToolOrchestrator.js +14 -0
- package/dist/core/tools/IToolOrchestrator.js.map +1 -0
- package/dist/core/tools/ToolExecutor.d.ts +143 -0
- package/dist/core/tools/ToolExecutor.d.ts.map +1 -0
- package/dist/core/tools/ToolExecutor.js +364 -0
- package/dist/core/tools/ToolExecutor.js.map +1 -0
- package/dist/core/tools/ToolOrchestrator.d.ts +142 -0
- package/dist/core/tools/ToolOrchestrator.d.ts.map +1 -0
- package/dist/core/tools/ToolOrchestrator.js +373 -0
- package/dist/core/tools/ToolOrchestrator.js.map +1 -0
- package/dist/core/tools/permissions/IToolPermissionManager.d.ts +195 -0
- package/dist/core/tools/permissions/IToolPermissionManager.d.ts.map +1 -0
- package/dist/core/tools/permissions/IToolPermissionManager.js +14 -0
- package/dist/core/tools/permissions/IToolPermissionManager.js.map +1 -0
- package/dist/core/tools/permissions/ToolPermissionManager.d.ts +203 -0
- package/dist/core/tools/permissions/ToolPermissionManager.d.ts.map +1 -0
- package/dist/core/tools/permissions/ToolPermissionManager.js +298 -0
- package/dist/core/tools/permissions/ToolPermissionManager.js.map +1 -0
- package/dist/core/ui/IUIComponent.d.ts +11 -0
- package/dist/core/ui/IUIComponent.d.ts.map +1 -0
- package/dist/core/ui/IUIComponent.js +2 -0
- package/dist/core/ui/IUIComponent.js.map +1 -0
- package/dist/core/usage/UsageLedger.d.ts +81 -0
- package/dist/core/usage/UsageLedger.d.ts.map +1 -0
- package/dist/core/usage/UsageLedger.js +135 -0
- package/dist/core/usage/UsageLedger.js.map +1 -0
- package/dist/core/workflows/IWorkflowEngine.d.ts +42 -0
- package/dist/core/workflows/IWorkflowEngine.d.ts.map +1 -0
- package/dist/core/workflows/IWorkflowEngine.js +2 -0
- package/dist/core/workflows/IWorkflowEngine.js.map +1 -0
- package/dist/core/workflows/WorkflowEngine.d.ts +28 -0
- package/dist/core/workflows/WorkflowEngine.d.ts.map +1 -0
- package/dist/core/workflows/WorkflowEngine.js +309 -0
- package/dist/core/workflows/WorkflowEngine.js.map +1 -0
- package/dist/core/workflows/WorkflowTypes.d.ts +180 -0
- package/dist/core/workflows/WorkflowTypes.d.ts.map +1 -0
- package/dist/core/workflows/WorkflowTypes.js +26 -0
- package/dist/core/workflows/WorkflowTypes.js.map +1 -0
- package/dist/core/workflows/runtime/WorkflowRuntime.d.ts +70 -0
- package/dist/core/workflows/runtime/WorkflowRuntime.d.ts.map +1 -0
- package/dist/core/workflows/runtime/WorkflowRuntime.js +566 -0
- package/dist/core/workflows/runtime/WorkflowRuntime.js.map +1 -0
- package/dist/core/workflows/storage/IWorkflowStore.d.ts +75 -0
- package/dist/core/workflows/storage/IWorkflowStore.d.ts.map +1 -0
- package/dist/core/workflows/storage/IWorkflowStore.js +2 -0
- package/dist/core/workflows/storage/IWorkflowStore.js.map +1 -0
- package/dist/core/workflows/storage/InMemoryWorkflowStore.d.ts +14 -0
- package/dist/core/workflows/storage/InMemoryWorkflowStore.d.ts.map +1 -0
- package/dist/core/workflows/storage/InMemoryWorkflowStore.js +130 -0
- package/dist/core/workflows/storage/InMemoryWorkflowStore.js.map +1 -0
- package/dist/extensions/ExtensionLoader.d.ts +119 -0
- package/dist/extensions/ExtensionLoader.d.ts.map +1 -0
- package/dist/extensions/ExtensionLoader.js +297 -0
- package/dist/extensions/ExtensionLoader.js.map +1 -0
- package/dist/extensions/ExtensionManager.d.ts +49 -0
- package/dist/extensions/ExtensionManager.d.ts.map +1 -0
- package/dist/extensions/ExtensionManager.js +197 -0
- package/dist/extensions/ExtensionManager.js.map +1 -0
- package/dist/extensions/ExtensionRegistry.d.ts +39 -0
- package/dist/extensions/ExtensionRegistry.d.ts.map +1 -0
- package/dist/extensions/ExtensionRegistry.js +103 -0
- package/dist/extensions/ExtensionRegistry.js.map +1 -0
- package/dist/extensions/MultiRegistryLoader.d.ts +61 -0
- package/dist/extensions/MultiRegistryLoader.d.ts.map +1 -0
- package/dist/extensions/MultiRegistryLoader.js +169 -0
- package/dist/extensions/MultiRegistryLoader.js.map +1 -0
- package/dist/extensions/RegistryConfig.d.ts +86 -0
- package/dist/extensions/RegistryConfig.d.ts.map +1 -0
- package/dist/extensions/RegistryConfig.js +99 -0
- package/dist/extensions/RegistryConfig.js.map +1 -0
- package/dist/extensions/events.d.ts +19 -0
- package/dist/extensions/events.d.ts.map +1 -0
- package/dist/extensions/events.js +2 -0
- package/dist/extensions/events.js.map +1 -0
- package/dist/extensions/index.d.ts +9 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +9 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/manifest.d.ts +52 -0
- package/dist/extensions/manifest.d.ts.map +1 -0
- package/dist/extensions/manifest.js +2 -0
- package/dist/extensions/manifest.js.map +1 -0
- package/dist/extensions/types.d.ts +294 -0
- package/dist/extensions/types.d.ts.map +1 -0
- package/dist/extensions/types.js +12 -0
- package/dist/extensions/types.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/ILogger.d.ts +8 -0
- package/dist/logging/ILogger.d.ts.map +1 -0
- package/dist/logging/ILogger.js +2 -0
- package/dist/logging/ILogger.js.map +1 -0
- package/dist/logging/PinoLogger.d.ts +12 -0
- package/dist/logging/PinoLogger.d.ts.map +1 -0
- package/dist/logging/PinoLogger.js +22 -0
- package/dist/logging/PinoLogger.js.map +1 -0
- package/dist/logging/loggerFactory.d.ts +6 -0
- package/dist/logging/loggerFactory.d.ts.map +1 -0
- package/dist/logging/loggerFactory.js +14 -0
- package/dist/logging/loggerFactory.js.map +1 -0
- package/dist/rag/EmbeddingManager.d.ts +81 -0
- package/dist/rag/EmbeddingManager.d.ts.map +1 -0
- package/dist/rag/EmbeddingManager.js +412 -0
- package/dist/rag/EmbeddingManager.js.map +1 -0
- package/dist/rag/IEmbeddingManager.d.ts +277 -0
- package/dist/rag/IEmbeddingManager.d.ts.map +1 -0
- package/dist/rag/IEmbeddingManager.js +19 -0
- package/dist/rag/IEmbeddingManager.js.map +1 -0
- package/dist/rag/IRetrievalAugmentor.d.ts +208 -0
- package/dist/rag/IRetrievalAugmentor.d.ts.map +1 -0
- package/dist/rag/IRetrievalAugmentor.js +21 -0
- package/dist/rag/IRetrievalAugmentor.js.map +1 -0
- package/dist/rag/IVectorStore.d.ts +351 -0
- package/dist/rag/IVectorStore.d.ts.map +1 -0
- package/dist/rag/IVectorStore.js +15 -0
- package/dist/rag/IVectorStore.js.map +1 -0
- package/dist/rag/IVectorStoreManager.d.ts +121 -0
- package/dist/rag/IVectorStoreManager.d.ts.map +1 -0
- package/dist/rag/IVectorStoreManager.js +13 -0
- package/dist/rag/IVectorStoreManager.js.map +1 -0
- package/dist/rag/RetrievalAugmentor.d.ts +99 -0
- package/dist/rag/RetrievalAugmentor.d.ts.map +1 -0
- package/dist/rag/RetrievalAugmentor.js +674 -0
- package/dist/rag/RetrievalAugmentor.js.map +1 -0
- package/dist/rag/VectorStoreManager.d.ts +90 -0
- package/dist/rag/VectorStoreManager.d.ts.map +1 -0
- package/dist/rag/VectorStoreManager.js +283 -0
- package/dist/rag/VectorStoreManager.js.map +1 -0
- package/dist/rag/implementations/index.d.ts +9 -0
- package/dist/rag/implementations/index.d.ts.map +1 -0
- package/dist/rag/implementations/index.js +9 -0
- package/dist/rag/implementations/index.js.map +1 -0
- package/dist/rag/implementations/vector_stores/InMemoryVectorStore.d.ts +132 -0
- package/dist/rag/implementations/vector_stores/InMemoryVectorStore.d.ts.map +1 -0
- package/dist/rag/implementations/vector_stores/InMemoryVectorStore.js +539 -0
- package/dist/rag/implementations/vector_stores/InMemoryVectorStore.js.map +1 -0
- package/dist/rag/implementations/vector_stores/SqlVectorStore.d.ts +265 -0
- package/dist/rag/implementations/vector_stores/SqlVectorStore.d.ts.map +1 -0
- package/dist/rag/implementations/vector_stores/SqlVectorStore.js +755 -0
- package/dist/rag/implementations/vector_stores/SqlVectorStore.js.map +1 -0
- package/dist/rag/implementations/vector_stores/index.d.ts +10 -0
- package/dist/rag/implementations/vector_stores/index.d.ts.map +1 -0
- package/dist/rag/implementations/vector_stores/index.js +12 -0
- package/dist/rag/implementations/vector_stores/index.js.map +1 -0
- package/dist/rag/index.d.ts +95 -0
- package/dist/rag/index.d.ts.map +1 -0
- package/dist/rag/index.js +97 -0
- package/dist/rag/index.js.map +1 -0
- package/dist/services/user_auth/AuthService.d.ts +13 -0
- package/dist/services/user_auth/AuthService.d.ts.map +1 -0
- package/dist/services/user_auth/AuthService.js +24 -0
- package/dist/services/user_auth/AuthService.js.map +1 -0
- package/dist/services/user_auth/SubscriptionService.d.ts +14 -0
- package/dist/services/user_auth/SubscriptionService.d.ts.map +1 -0
- package/dist/services/user_auth/SubscriptionService.js +34 -0
- package/dist/services/user_auth/SubscriptionService.js.map +1 -0
- package/dist/services/user_auth/types.d.ts +30 -0
- package/dist/services/user_auth/types.d.ts.map +1 -0
- package/dist/services/user_auth/types.js +2 -0
- package/dist/services/user_auth/types.js.map +1 -0
- package/dist/stubs/prismaClient.d.ts +35 -0
- package/dist/stubs/prismaClient.d.ts.map +1 -0
- package/dist/stubs/prismaClient.js +47 -0
- package/dist/stubs/prismaClient.js.map +1 -0
- package/dist/types/rateLimitTypes.d.ts +70 -0
- package/dist/types/rateLimitTypes.d.ts.map +1 -0
- package/dist/types/rateLimitTypes.js +55 -0
- package/dist/types/rateLimitTypes.js.map +1 -0
- package/dist/utils/errors.d.ts +80 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +201 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/uuid.d.ts +11 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/uuid.js +64 -0
- package/dist/utils/uuid.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,701 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file IStructuredOutputManager.ts
|
|
3
|
+
* @description Interface for the Structured Output Manager in AgentOS.
|
|
4
|
+
*
|
|
5
|
+
* The Structured Output Manager ensures LLM outputs conform to predefined
|
|
6
|
+
* schemas, enabling reliable parsing, validation, and type-safe consumption
|
|
7
|
+
* of agent responses. This is critical for:
|
|
8
|
+
*
|
|
9
|
+
* - **Tool Calls**: Ensuring function arguments match expected types
|
|
10
|
+
* - **Data Extraction**: Pulling structured data from unstructured text
|
|
11
|
+
* - **API Responses**: Generating responses that match API contracts
|
|
12
|
+
* - **Multi-step Workflows**: Reliable data flow between pipeline stages
|
|
13
|
+
*
|
|
14
|
+
* Supports multiple output strategies:
|
|
15
|
+
* - JSON Mode (OpenAI, Anthropic)
|
|
16
|
+
* - Function Calling / Tool Use
|
|
17
|
+
* - Grammar-constrained generation (local models)
|
|
18
|
+
* - Post-hoc parsing with retry
|
|
19
|
+
*
|
|
20
|
+
* @module AgentOS/Structured
|
|
21
|
+
* @version 1.0.0
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const manager = new StructuredOutputManager(llmProvider);
|
|
26
|
+
*
|
|
27
|
+
* // Define a schema for extraction
|
|
28
|
+
* const personSchema: JSONSchema = {
|
|
29
|
+
* type: 'object',
|
|
30
|
+
* properties: {
|
|
31
|
+
* name: { type: 'string' },
|
|
32
|
+
* age: { type: 'integer', minimum: 0 },
|
|
33
|
+
* email: { type: 'string', format: 'email' },
|
|
34
|
+
* },
|
|
35
|
+
* required: ['name', 'email'],
|
|
36
|
+
* };
|
|
37
|
+
*
|
|
38
|
+
* // Extract structured data
|
|
39
|
+
* const result = await manager.generate({
|
|
40
|
+
* prompt: 'Extract person info from: John Doe, 30 years old, john@example.com',
|
|
41
|
+
* schema: personSchema,
|
|
42
|
+
* schemaName: 'Person',
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* console.log(result.data); // { name: 'John Doe', age: 30, email: 'john@example.com' }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
import type { ILogger } from '../../logging/ILogger';
|
|
49
|
+
/**
|
|
50
|
+
* JSON Schema type definitions for structured output validation.
|
|
51
|
+
* Follows JSON Schema Draft 2020-12 specification.
|
|
52
|
+
*
|
|
53
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core
|
|
54
|
+
*/
|
|
55
|
+
export type JSONSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'null';
|
|
56
|
+
/**
|
|
57
|
+
* String format validators supported by the schema.
|
|
58
|
+
*/
|
|
59
|
+
export type JSONSchemaStringFormat = 'date-time' | 'date' | 'time' | 'email' | 'uri' | 'uri-reference' | 'uuid' | 'hostname' | 'ipv4' | 'ipv6' | 'regex';
|
|
60
|
+
/**
|
|
61
|
+
* Complete JSON Schema definition for structured outputs.
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* This interface supports the commonly used JSON Schema keywords
|
|
65
|
+
* for defining structured LLM outputs. It's designed to be compatible
|
|
66
|
+
* with OpenAI's structured output API and similar implementations.
|
|
67
|
+
*/
|
|
68
|
+
export interface JSONSchema {
|
|
69
|
+
/** The data type of the schema */
|
|
70
|
+
type?: JSONSchemaType | JSONSchemaType[];
|
|
71
|
+
/** Human-readable title for the schema */
|
|
72
|
+
title?: string;
|
|
73
|
+
/** Description of what the schema represents */
|
|
74
|
+
description?: string;
|
|
75
|
+
/** Default value if not provided */
|
|
76
|
+
default?: unknown;
|
|
77
|
+
/** Enumeration of allowed values */
|
|
78
|
+
enum?: unknown[];
|
|
79
|
+
/** Constant value (must be exactly this) */
|
|
80
|
+
const?: unknown;
|
|
81
|
+
/** Minimum string length */
|
|
82
|
+
minLength?: number;
|
|
83
|
+
/** Maximum string length */
|
|
84
|
+
maxLength?: number;
|
|
85
|
+
/** Regex pattern the string must match */
|
|
86
|
+
pattern?: string;
|
|
87
|
+
/** String format validator */
|
|
88
|
+
format?: JSONSchemaStringFormat;
|
|
89
|
+
/** Minimum value (inclusive) */
|
|
90
|
+
minimum?: number;
|
|
91
|
+
/** Maximum value (inclusive) */
|
|
92
|
+
maximum?: number;
|
|
93
|
+
/** Minimum value (exclusive) */
|
|
94
|
+
exclusiveMinimum?: number;
|
|
95
|
+
/** Maximum value (exclusive) */
|
|
96
|
+
exclusiveMaximum?: number;
|
|
97
|
+
/** Value must be a multiple of this number */
|
|
98
|
+
multipleOf?: number;
|
|
99
|
+
/** Schema for array items */
|
|
100
|
+
items?: JSONSchema | JSONSchema[];
|
|
101
|
+
/** Minimum number of items */
|
|
102
|
+
minItems?: number;
|
|
103
|
+
/** Maximum number of items */
|
|
104
|
+
maxItems?: number;
|
|
105
|
+
/** All items must be unique */
|
|
106
|
+
uniqueItems?: boolean;
|
|
107
|
+
/** Schema for items after `items` tuple schemas */
|
|
108
|
+
additionalItems?: boolean | JSONSchema;
|
|
109
|
+
/** Prefix items (for tuple validation) */
|
|
110
|
+
prefixItems?: JSONSchema[];
|
|
111
|
+
/** Schema that must validate at least one item */
|
|
112
|
+
contains?: JSONSchema;
|
|
113
|
+
/** Property definitions for object */
|
|
114
|
+
properties?: Record<string, JSONSchema>;
|
|
115
|
+
/** Required property names */
|
|
116
|
+
required?: string[];
|
|
117
|
+
/** Schema for properties not in `properties` */
|
|
118
|
+
additionalProperties?: boolean | JSONSchema;
|
|
119
|
+
/** Pattern-based property schemas */
|
|
120
|
+
patternProperties?: Record<string, JSONSchema>;
|
|
121
|
+
/** Minimum number of properties */
|
|
122
|
+
minProperties?: number;
|
|
123
|
+
/** Maximum number of properties */
|
|
124
|
+
maxProperties?: number;
|
|
125
|
+
/** Property names must match this schema */
|
|
126
|
+
propertyNames?: JSONSchema;
|
|
127
|
+
/** Dependencies between properties */
|
|
128
|
+
dependentRequired?: Record<string, string[]>;
|
|
129
|
+
/** Schema dependencies */
|
|
130
|
+
dependentSchemas?: Record<string, JSONSchema>;
|
|
131
|
+
/** Must match all schemas */
|
|
132
|
+
allOf?: JSONSchema[];
|
|
133
|
+
/** Must match at least one schema */
|
|
134
|
+
anyOf?: JSONSchema[];
|
|
135
|
+
/** Must match exactly one schema */
|
|
136
|
+
oneOf?: JSONSchema[];
|
|
137
|
+
/** Must not match this schema */
|
|
138
|
+
not?: JSONSchema;
|
|
139
|
+
/** Conditional schema application */
|
|
140
|
+
if?: JSONSchema;
|
|
141
|
+
/** Schema if `if` passes */
|
|
142
|
+
then?: JSONSchema;
|
|
143
|
+
/** Schema if `if` fails */
|
|
144
|
+
else?: JSONSchema;
|
|
145
|
+
/** Reference to another schema */
|
|
146
|
+
$ref?: string;
|
|
147
|
+
/** Schema definitions for $ref */
|
|
148
|
+
$defs?: Record<string, JSONSchema>;
|
|
149
|
+
/** Examples of valid values */
|
|
150
|
+
examples?: unknown[];
|
|
151
|
+
/** Whether this value is read-only */
|
|
152
|
+
readOnly?: boolean;
|
|
153
|
+
/** Whether this value is write-only */
|
|
154
|
+
writeOnly?: boolean;
|
|
155
|
+
/** Deprecation flag */
|
|
156
|
+
deprecated?: boolean;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Strategy for enforcing structured output.
|
|
160
|
+
*/
|
|
161
|
+
export type StructuredOutputStrategy = 'json_mode' | 'function_calling' | 'grammar' | 'prompt_engineering' | 'auto';
|
|
162
|
+
/**
|
|
163
|
+
* Options for structured output generation.
|
|
164
|
+
*/
|
|
165
|
+
export interface StructuredGenerationOptions {
|
|
166
|
+
/** The prompt or messages to send to the LLM */
|
|
167
|
+
prompt: string | Array<{
|
|
168
|
+
role: string;
|
|
169
|
+
content: string;
|
|
170
|
+
}>;
|
|
171
|
+
/** JSON Schema the output must conform to */
|
|
172
|
+
schema: JSONSchema;
|
|
173
|
+
/** Human-readable name for the schema (used in function calling) */
|
|
174
|
+
schemaName: string;
|
|
175
|
+
/** Description of what output is expected */
|
|
176
|
+
schemaDescription?: string;
|
|
177
|
+
/** Strategy for enforcing structure */
|
|
178
|
+
strategy?: StructuredOutputStrategy;
|
|
179
|
+
/** LLM provider to use */
|
|
180
|
+
providerId?: string;
|
|
181
|
+
/** Model ID to use */
|
|
182
|
+
modelId?: string;
|
|
183
|
+
/** Temperature for generation (0-2) */
|
|
184
|
+
temperature?: number;
|
|
185
|
+
/** Maximum tokens to generate */
|
|
186
|
+
maxTokens?: number;
|
|
187
|
+
/** Number of retry attempts on validation failure */
|
|
188
|
+
maxRetries?: number;
|
|
189
|
+
/** Whether to include reasoning/chain-of-thought before output */
|
|
190
|
+
includeReasoning?: boolean;
|
|
191
|
+
/** Custom system prompt to prepend */
|
|
192
|
+
systemPrompt?: string;
|
|
193
|
+
/** Timeout in milliseconds */
|
|
194
|
+
timeoutMs?: number;
|
|
195
|
+
/** Whether to strictly enforce schema (fail on extra properties) */
|
|
196
|
+
strict?: boolean;
|
|
197
|
+
/** Custom validation function for additional checks */
|
|
198
|
+
customValidator?: (data: unknown) => ValidationIssue[];
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Options for parallel function/tool calls.
|
|
202
|
+
*/
|
|
203
|
+
export interface ParallelFunctionCallOptions {
|
|
204
|
+
/** The prompt requesting actions */
|
|
205
|
+
prompt: string | Array<{
|
|
206
|
+
role: string;
|
|
207
|
+
content: string;
|
|
208
|
+
}>;
|
|
209
|
+
/** Available functions/tools the model can call */
|
|
210
|
+
functions: FunctionDefinition[];
|
|
211
|
+
/** Maximum number of parallel calls allowed */
|
|
212
|
+
maxParallelCalls?: number;
|
|
213
|
+
/** Whether functions are required or optional */
|
|
214
|
+
toolChoice?: 'auto' | 'required' | 'none' | {
|
|
215
|
+
type: 'function';
|
|
216
|
+
function: {
|
|
217
|
+
name: string;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
/** LLM provider to use */
|
|
221
|
+
providerId?: string;
|
|
222
|
+
/** Model ID to use */
|
|
223
|
+
modelId?: string;
|
|
224
|
+
/** Temperature for generation */
|
|
225
|
+
temperature?: number;
|
|
226
|
+
/** Timeout in milliseconds */
|
|
227
|
+
timeoutMs?: number;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Definition of a callable function/tool.
|
|
231
|
+
*/
|
|
232
|
+
export interface FunctionDefinition {
|
|
233
|
+
/** Unique function name */
|
|
234
|
+
name: string;
|
|
235
|
+
/** Human-readable description */
|
|
236
|
+
description: string;
|
|
237
|
+
/** JSON Schema for function parameters */
|
|
238
|
+
parameters: JSONSchema;
|
|
239
|
+
/** Whether this function is required */
|
|
240
|
+
required?: boolean;
|
|
241
|
+
/** Function handler (for execution) */
|
|
242
|
+
handler?: (args: Record<string, unknown>) => Promise<unknown> | unknown;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Result of structured output generation.
|
|
246
|
+
*
|
|
247
|
+
* @typeParam T - The expected type of the parsed data
|
|
248
|
+
*/
|
|
249
|
+
export interface StructuredGenerationResult<T = unknown> {
|
|
250
|
+
/** Whether generation and validation succeeded */
|
|
251
|
+
success: boolean;
|
|
252
|
+
/** The parsed, validated data (if successful) */
|
|
253
|
+
data?: T;
|
|
254
|
+
/** Raw string output from the LLM */
|
|
255
|
+
rawOutput: string;
|
|
256
|
+
/** Validation errors if any */
|
|
257
|
+
validationErrors?: ValidationIssue[];
|
|
258
|
+
/** The strategy that was used */
|
|
259
|
+
strategyUsed: StructuredOutputStrategy;
|
|
260
|
+
/** Number of retry attempts made */
|
|
261
|
+
retryCount: number;
|
|
262
|
+
/** Token usage statistics */
|
|
263
|
+
tokenUsage?: {
|
|
264
|
+
promptTokens: number;
|
|
265
|
+
completionTokens: number;
|
|
266
|
+
totalTokens: number;
|
|
267
|
+
};
|
|
268
|
+
/** Generation latency in milliseconds */
|
|
269
|
+
latencyMs: number;
|
|
270
|
+
/** Reasoning/chain-of-thought if requested */
|
|
271
|
+
reasoning?: string;
|
|
272
|
+
/** Model that was used */
|
|
273
|
+
modelId: string;
|
|
274
|
+
/** Provider that was used */
|
|
275
|
+
providerId: string;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* A single validation issue found during schema validation.
|
|
279
|
+
*/
|
|
280
|
+
export interface ValidationIssue {
|
|
281
|
+
/** JSON Pointer path to the invalid value */
|
|
282
|
+
path: string;
|
|
283
|
+
/** Error message describing the issue */
|
|
284
|
+
message: string;
|
|
285
|
+
/** The keyword that failed validation */
|
|
286
|
+
keyword: string;
|
|
287
|
+
/** Expected value or constraint */
|
|
288
|
+
expected?: unknown;
|
|
289
|
+
/** Actual value that was found */
|
|
290
|
+
actual?: unknown;
|
|
291
|
+
/** Severity of the issue */
|
|
292
|
+
severity: 'error' | 'warning';
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Result of parallel function calls.
|
|
296
|
+
*/
|
|
297
|
+
export interface ParallelFunctionCallResult {
|
|
298
|
+
/** Whether all function calls were successful */
|
|
299
|
+
success: boolean;
|
|
300
|
+
/** Individual function call results */
|
|
301
|
+
calls: FunctionCallResult[];
|
|
302
|
+
/** Any content output alongside function calls */
|
|
303
|
+
textContent?: string;
|
|
304
|
+
/** Token usage statistics */
|
|
305
|
+
tokenUsage?: {
|
|
306
|
+
promptTokens: number;
|
|
307
|
+
completionTokens: number;
|
|
308
|
+
totalTokens: number;
|
|
309
|
+
};
|
|
310
|
+
/** Generation latency in milliseconds */
|
|
311
|
+
latencyMs: number;
|
|
312
|
+
/** Model that was used */
|
|
313
|
+
modelId: string;
|
|
314
|
+
/** Provider that was used */
|
|
315
|
+
providerId: string;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Result of a single function call.
|
|
319
|
+
*/
|
|
320
|
+
export interface FunctionCallResult {
|
|
321
|
+
/** Function that was called */
|
|
322
|
+
functionName: string;
|
|
323
|
+
/** Arguments passed to the function */
|
|
324
|
+
arguments: Record<string, unknown>;
|
|
325
|
+
/** Whether arguments validated against schema */
|
|
326
|
+
argumentsValid: boolean;
|
|
327
|
+
/** Validation errors for arguments */
|
|
328
|
+
validationErrors?: ValidationIssue[];
|
|
329
|
+
/** Result of executing the function (if handler provided) */
|
|
330
|
+
executionResult?: unknown;
|
|
331
|
+
/** Error during execution (if any) */
|
|
332
|
+
executionError?: string;
|
|
333
|
+
/** Unique ID for this call (for multi-turn conversations) */
|
|
334
|
+
callId: string;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Options for entity extraction from text.
|
|
338
|
+
*/
|
|
339
|
+
export interface EntityExtractionOptions {
|
|
340
|
+
/** Text to extract entities from */
|
|
341
|
+
text: string;
|
|
342
|
+
/** Schema defining the entities to extract */
|
|
343
|
+
entitySchema: JSONSchema;
|
|
344
|
+
/** Name for the extraction task */
|
|
345
|
+
taskName: string;
|
|
346
|
+
/** Additional context or instructions */
|
|
347
|
+
instructions?: string;
|
|
348
|
+
/** Examples of expected extractions */
|
|
349
|
+
examples?: Array<{
|
|
350
|
+
input: string;
|
|
351
|
+
output: unknown;
|
|
352
|
+
}>;
|
|
353
|
+
/** LLM provider to use */
|
|
354
|
+
providerId?: string;
|
|
355
|
+
/** Model ID to use */
|
|
356
|
+
modelId?: string;
|
|
357
|
+
/** Whether to extract all occurrences or just first */
|
|
358
|
+
extractAll?: boolean;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Result of entity extraction.
|
|
362
|
+
*/
|
|
363
|
+
export interface EntityExtractionResult<T = unknown> {
|
|
364
|
+
/** Whether extraction succeeded */
|
|
365
|
+
success: boolean;
|
|
366
|
+
/** Extracted entities */
|
|
367
|
+
entities: T[];
|
|
368
|
+
/** Confidence scores for each entity (0-1) */
|
|
369
|
+
confidenceScores?: number[];
|
|
370
|
+
/** Source text spans for each entity */
|
|
371
|
+
sourceSpans?: Array<{
|
|
372
|
+
start: number;
|
|
373
|
+
end: number;
|
|
374
|
+
text: string;
|
|
375
|
+
}>;
|
|
376
|
+
/** Any extraction issues */
|
|
377
|
+
issues?: string[];
|
|
378
|
+
/** Token usage */
|
|
379
|
+
tokenUsage?: {
|
|
380
|
+
promptTokens: number;
|
|
381
|
+
completionTokens: number;
|
|
382
|
+
totalTokens: number;
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Statistics about structured output operations.
|
|
387
|
+
*/
|
|
388
|
+
export interface StructuredOutputStats {
|
|
389
|
+
/** Total generation attempts */
|
|
390
|
+
totalGenerations: number;
|
|
391
|
+
/** Successful generations */
|
|
392
|
+
successfulGenerations: number;
|
|
393
|
+
/** Success rate (0-1) */
|
|
394
|
+
successRate: number;
|
|
395
|
+
/** Average retries per generation */
|
|
396
|
+
avgRetries: number;
|
|
397
|
+
/** Average latency in ms */
|
|
398
|
+
avgLatencyMs: number;
|
|
399
|
+
/** Generations by strategy */
|
|
400
|
+
byStrategy: Record<StructuredOutputStrategy, number>;
|
|
401
|
+
/** Most common validation errors */
|
|
402
|
+
topValidationErrors: Array<{
|
|
403
|
+
keyword: string;
|
|
404
|
+
count: number;
|
|
405
|
+
}>;
|
|
406
|
+
/** Total tokens used */
|
|
407
|
+
totalTokensUsed: number;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Interface for the Structured Output Manager.
|
|
411
|
+
*
|
|
412
|
+
* The Structured Output Manager provides a unified API for generating
|
|
413
|
+
* LLM outputs that conform to predefined JSON Schemas. It handles:
|
|
414
|
+
*
|
|
415
|
+
* - **Strategy Selection**: Choosing the best approach for the provider/model
|
|
416
|
+
* - **Schema Validation**: Ensuring outputs match the schema
|
|
417
|
+
* - **Retry Logic**: Automatic retries with feedback on validation failures
|
|
418
|
+
* - **Function Calling**: Parallel tool use with argument validation
|
|
419
|
+
* - **Entity Extraction**: Pulling structured data from unstructured text
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```typescript
|
|
423
|
+
* // Simple structured generation
|
|
424
|
+
* const result = await manager.generate({
|
|
425
|
+
* prompt: 'List the top 3 programming languages',
|
|
426
|
+
* schema: {
|
|
427
|
+
* type: 'object',
|
|
428
|
+
* properties: {
|
|
429
|
+
* languages: {
|
|
430
|
+
* type: 'array',
|
|
431
|
+
* items: {
|
|
432
|
+
* type: 'object',
|
|
433
|
+
* properties: {
|
|
434
|
+
* name: { type: 'string' },
|
|
435
|
+
* popularity: { type: 'integer', minimum: 1, maximum: 100 },
|
|
436
|
+
* },
|
|
437
|
+
* required: ['name', 'popularity'],
|
|
438
|
+
* },
|
|
439
|
+
* minItems: 3,
|
|
440
|
+
* maxItems: 3,
|
|
441
|
+
* },
|
|
442
|
+
* },
|
|
443
|
+
* required: ['languages'],
|
|
444
|
+
* },
|
|
445
|
+
* schemaName: 'ProgrammingLanguages',
|
|
446
|
+
* });
|
|
447
|
+
*
|
|
448
|
+
* if (result.success) {
|
|
449
|
+
* result.data.languages.forEach(lang => {
|
|
450
|
+
* console.log(`${lang.name}: ${lang.popularity}%`);
|
|
451
|
+
* });
|
|
452
|
+
* }
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* ```typescript
|
|
457
|
+
* // Parallel function calling
|
|
458
|
+
* const result = await manager.generateFunctionCalls({
|
|
459
|
+
* prompt: 'Search for weather in NYC and stock price of AAPL',
|
|
460
|
+
* functions: [
|
|
461
|
+
* {
|
|
462
|
+
* name: 'get_weather',
|
|
463
|
+
* description: 'Get current weather for a city',
|
|
464
|
+
* parameters: {
|
|
465
|
+
* type: 'object',
|
|
466
|
+
* properties: {
|
|
467
|
+
* city: { type: 'string' },
|
|
468
|
+
* units: { type: 'string', enum: ['celsius', 'fahrenheit'] },
|
|
469
|
+
* },
|
|
470
|
+
* required: ['city'],
|
|
471
|
+
* },
|
|
472
|
+
* handler: async (args) => fetchWeather(args.city, args.units),
|
|
473
|
+
* },
|
|
474
|
+
* {
|
|
475
|
+
* name: 'get_stock_price',
|
|
476
|
+
* description: 'Get current stock price',
|
|
477
|
+
* parameters: {
|
|
478
|
+
* type: 'object',
|
|
479
|
+
* properties: {
|
|
480
|
+
* symbol: { type: 'string' },
|
|
481
|
+
* },
|
|
482
|
+
* required: ['symbol'],
|
|
483
|
+
* },
|
|
484
|
+
* handler: async (args) => fetchStockPrice(args.symbol),
|
|
485
|
+
* },
|
|
486
|
+
* ],
|
|
487
|
+
* maxParallelCalls: 5,
|
|
488
|
+
* });
|
|
489
|
+
*
|
|
490
|
+
* // Both functions called in parallel
|
|
491
|
+
* result.calls.forEach(call => {
|
|
492
|
+
* console.log(`${call.functionName}: ${JSON.stringify(call.executionResult)}`);
|
|
493
|
+
* });
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
496
|
+
export interface IStructuredOutputManager {
|
|
497
|
+
/**
|
|
498
|
+
* Initializes the manager with optional configuration.
|
|
499
|
+
*
|
|
500
|
+
* @param logger - Logger instance for debugging
|
|
501
|
+
*/
|
|
502
|
+
initialize(logger?: ILogger): Promise<void>;
|
|
503
|
+
/**
|
|
504
|
+
* Generates structured output conforming to the given schema.
|
|
505
|
+
*
|
|
506
|
+
* @typeParam T - Expected type of the output data
|
|
507
|
+
* @param options - Generation options including prompt and schema
|
|
508
|
+
* @returns Promise resolving to the generation result
|
|
509
|
+
*
|
|
510
|
+
* @throws {StructuredOutputError} If generation fails after all retries
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* ```typescript
|
|
514
|
+
* const result = await manager.generate<Person>({
|
|
515
|
+
* prompt: 'Extract person info from: John Doe, 30, john@example.com',
|
|
516
|
+
* schema: personSchema,
|
|
517
|
+
* schemaName: 'Person',
|
|
518
|
+
* strict: true,
|
|
519
|
+
* });
|
|
520
|
+
*
|
|
521
|
+
* if (result.success) {
|
|
522
|
+
* console.log(result.data.name); // Type-safe access
|
|
523
|
+
* }
|
|
524
|
+
* ```
|
|
525
|
+
*/
|
|
526
|
+
generate<T = unknown>(options: StructuredGenerationOptions): Promise<StructuredGenerationResult<T>>;
|
|
527
|
+
/**
|
|
528
|
+
* Generates parallel function/tool calls.
|
|
529
|
+
*
|
|
530
|
+
* This method enables the LLM to call multiple functions in a single
|
|
531
|
+
* response, useful for parallel data fetching or multi-step operations.
|
|
532
|
+
*
|
|
533
|
+
* @param options - Function call options
|
|
534
|
+
* @returns Promise resolving to function call results
|
|
535
|
+
*
|
|
536
|
+
* @example
|
|
537
|
+
* ```typescript
|
|
538
|
+
* const result = await manager.generateFunctionCalls({
|
|
539
|
+
* prompt: 'Get the weather in Paris and London',
|
|
540
|
+
* functions: [weatherFunction],
|
|
541
|
+
* maxParallelCalls: 10,
|
|
542
|
+
* });
|
|
543
|
+
*
|
|
544
|
+
* // Execute all calls in parallel
|
|
545
|
+
* await Promise.all(result.calls.map(async call => {
|
|
546
|
+
* const fn = functions.find(f => f.name === call.functionName);
|
|
547
|
+
* if (fn?.handler) {
|
|
548
|
+
* call.executionResult = await fn.handler(call.arguments);
|
|
549
|
+
* }
|
|
550
|
+
* }));
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
generateFunctionCalls(options: ParallelFunctionCallOptions): Promise<ParallelFunctionCallResult>;
|
|
554
|
+
/**
|
|
555
|
+
* Extracts structured entities from unstructured text.
|
|
556
|
+
*
|
|
557
|
+
* Useful for NER, data extraction, and information retrieval tasks.
|
|
558
|
+
*
|
|
559
|
+
* @typeParam T - Expected type of extracted entities
|
|
560
|
+
* @param options - Extraction options
|
|
561
|
+
* @returns Promise resolving to extraction results
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```typescript
|
|
565
|
+
* const result = await manager.extractEntities<Person>({
|
|
566
|
+
* text: 'John Doe (john@example.com) met Jane Smith (jane@example.com)',
|
|
567
|
+
* entitySchema: personSchema,
|
|
568
|
+
* taskName: 'PersonExtraction',
|
|
569
|
+
* extractAll: true,
|
|
570
|
+
* });
|
|
571
|
+
*
|
|
572
|
+
* result.entities.forEach(person => {
|
|
573
|
+
* console.log(`Found: ${person.name} - ${person.email}`);
|
|
574
|
+
* });
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
extractEntities<T = unknown>(options: EntityExtractionOptions): Promise<EntityExtractionResult<T>>;
|
|
578
|
+
/**
|
|
579
|
+
* Validates data against a JSON Schema.
|
|
580
|
+
*
|
|
581
|
+
* @param data - Data to validate
|
|
582
|
+
* @param schema - Schema to validate against
|
|
583
|
+
* @param strict - Whether to fail on additional properties
|
|
584
|
+
* @returns Array of validation issues (empty if valid)
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```typescript
|
|
588
|
+
* const issues = manager.validate(
|
|
589
|
+
* { name: 'John', age: -5 },
|
|
590
|
+
* personSchema,
|
|
591
|
+
* true
|
|
592
|
+
* );
|
|
593
|
+
*
|
|
594
|
+
* if (issues.length > 0) {
|
|
595
|
+
* issues.forEach(issue => {
|
|
596
|
+
* console.log(`${issue.path}: ${issue.message}`);
|
|
597
|
+
* });
|
|
598
|
+
* }
|
|
599
|
+
* ```
|
|
600
|
+
*/
|
|
601
|
+
validate(data: unknown, schema: JSONSchema, strict?: boolean): ValidationIssue[];
|
|
602
|
+
/**
|
|
603
|
+
* Parses JSON string with error recovery.
|
|
604
|
+
*
|
|
605
|
+
* Attempts to extract valid JSON from potentially malformed output,
|
|
606
|
+
* handling common LLM output issues like:
|
|
607
|
+
* - Markdown code blocks
|
|
608
|
+
* - Trailing commas
|
|
609
|
+
* - Unquoted keys
|
|
610
|
+
* - Single quotes
|
|
611
|
+
*
|
|
612
|
+
* @param jsonString - String to parse
|
|
613
|
+
* @returns Parsed object or null if parsing fails
|
|
614
|
+
*
|
|
615
|
+
* @example
|
|
616
|
+
* ```typescript
|
|
617
|
+
* // Handles markdown-wrapped JSON
|
|
618
|
+
* const data = manager.parseJSON('```json\n{"name": "John"}\n```');
|
|
619
|
+
* // Returns: { name: 'John' }
|
|
620
|
+
*
|
|
621
|
+
* // Handles trailing commas
|
|
622
|
+
* const data2 = manager.parseJSON('{"a": 1, "b": 2,}');
|
|
623
|
+
* // Returns: { a: 1, b: 2 }
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
parseJSON(jsonString: string): unknown | null;
|
|
627
|
+
/**
|
|
628
|
+
* Determines the best strategy for a given provider/model.
|
|
629
|
+
*
|
|
630
|
+
* @param providerId - LLM provider ID
|
|
631
|
+
* @param modelId - Model ID
|
|
632
|
+
* @param schema - Schema to generate for
|
|
633
|
+
* @returns Recommended strategy
|
|
634
|
+
*/
|
|
635
|
+
recommendStrategy(providerId: string, modelId: string, schema: JSONSchema): StructuredOutputStrategy;
|
|
636
|
+
/**
|
|
637
|
+
* Registers a custom schema for reuse.
|
|
638
|
+
*
|
|
639
|
+
* @param name - Schema name for reference
|
|
640
|
+
* @param schema - Schema definition
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* ```typescript
|
|
644
|
+
* manager.registerSchema('Address', {
|
|
645
|
+
* type: 'object',
|
|
646
|
+
* properties: {
|
|
647
|
+
* street: { type: 'string' },
|
|
648
|
+
* city: { type: 'string' },
|
|
649
|
+
* country: { type: 'string' },
|
|
650
|
+
* postalCode: { type: 'string' },
|
|
651
|
+
* },
|
|
652
|
+
* required: ['street', 'city', 'country'],
|
|
653
|
+
* });
|
|
654
|
+
*
|
|
655
|
+
* // Use in other schemas via $ref
|
|
656
|
+
* const orderSchema = {
|
|
657
|
+
* type: 'object',
|
|
658
|
+
* properties: {
|
|
659
|
+
* shippingAddress: { $ref: '#/$defs/Address' },
|
|
660
|
+
* },
|
|
661
|
+
* };
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
664
|
+
registerSchema(name: string, schema: JSONSchema): void;
|
|
665
|
+
/**
|
|
666
|
+
* Gets a registered schema by name.
|
|
667
|
+
*
|
|
668
|
+
* @param name - Schema name
|
|
669
|
+
* @returns Schema or undefined if not found
|
|
670
|
+
*/
|
|
671
|
+
getSchema(name: string): JSONSchema | undefined;
|
|
672
|
+
/**
|
|
673
|
+
* Gets statistics about structured output operations.
|
|
674
|
+
*
|
|
675
|
+
* @returns Current statistics
|
|
676
|
+
*/
|
|
677
|
+
getStatistics(): StructuredOutputStats;
|
|
678
|
+
/**
|
|
679
|
+
* Resets statistics counters.
|
|
680
|
+
*/
|
|
681
|
+
resetStatistics(): void;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Error thrown when structured output generation fails.
|
|
685
|
+
*/
|
|
686
|
+
export declare class StructuredOutputError extends Error {
|
|
687
|
+
/** Validation issues that caused the failure */
|
|
688
|
+
readonly validationErrors: ValidationIssue[];
|
|
689
|
+
/** Raw output that failed validation */
|
|
690
|
+
readonly rawOutput: string;
|
|
691
|
+
/** Number of retries attempted */
|
|
692
|
+
readonly retryCount: number;
|
|
693
|
+
/** Strategy that was used */
|
|
694
|
+
readonly strategy: StructuredOutputStrategy;
|
|
695
|
+
constructor(message: string, validationErrors: ValidationIssue[], rawOutput: string, retryCount: number, strategy: StructuredOutputStrategy);
|
|
696
|
+
/**
|
|
697
|
+
* Converts error to a plain object for serialization.
|
|
698
|
+
*/
|
|
699
|
+
toPlainObject(): Record<string, unknown>;
|
|
700
|
+
}
|
|
701
|
+
//# sourceMappingURL=IStructuredOutputManager.d.ts.map
|