feat(tools): Phase T.1-T.4 complete - manifest system, registry, implementations, runtime, collaboration, scheduler
This commit is contained in:
37
backend/app/tools/schemas/validator.py
Normal file
37
backend/app/tools/schemas/validator.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
Schema Validator
|
||||
|
||||
Validates tool manifests and tool calls against their schemas.
|
||||
"""
|
||||
|
||||
from pydantic import ValidationError
|
||||
from tools.schemas.manifest import ToolManifest
|
||||
from tools.schemas.tool_call import ToolCallRequest
|
||||
|
||||
|
||||
class ManifestValidationError(Exception):
|
||||
"""Manifest validation error"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class ToolCallValidationError(Exception):
|
||||
"""Tool call validation error"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
def validate_manifest(data: dict) -> ToolManifest:
|
||||
"""Validate manifest data against ToolManifest schema"""
|
||||
try:
|
||||
return ToolManifest(**data)
|
||||
except ValidationError as e:
|
||||
raise ManifestValidationError(str(e))
|
||||
|
||||
|
||||
def validate_tool_call(data: dict) -> ToolCallRequest:
|
||||
"""Validate tool call request against ToolCallRequest schema"""
|
||||
try:
|
||||
return ToolCallRequest(**data)
|
||||
except ValidationError as e:
|
||||
raise ToolCallValidationError(str(e))
|
||||
Reference in New Issue
Block a user