feat(tools): Phase T.1-T.4 complete - manifest system, registry, implementations, runtime, collaboration, scheduler
This commit is contained in:
70
backend/app/tools/schemas/manifest.py
Normal file
70
backend/app/tools/schemas/manifest.py
Normal file
@@ -0,0 +1,70 @@
|
||||
"""
|
||||
Tool Manifest Schema
|
||||
|
||||
Defines the structure for tool manifest declarations following VCPToolBox plugin patterns.
|
||||
"""
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, List, Dict, Any
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ToolType(str, Enum):
|
||||
"""Tool execution type"""
|
||||
|
||||
SYNC = "sync" # Synchronous execution
|
||||
ASYNC = "async" # Asynchronous execution
|
||||
SERVICE = "service" # Continuous running service
|
||||
|
||||
|
||||
class RuntimeType(str, Enum):
|
||||
"""Runtime type for tool execution"""
|
||||
|
||||
PYTHON = "python"
|
||||
JAVASCRIPT = "javascript"
|
||||
NATIVE = "native"
|
||||
|
||||
|
||||
class InvocationCommand(BaseModel):
|
||||
"""Command definition for tool invocation"""
|
||||
|
||||
name: str = Field(..., description="Command name")
|
||||
description: str = Field(..., description="Command description (for AI)")
|
||||
parameters: Optional[Dict[str, Any]] = Field(default=None, description="Parameters JSON Schema")
|
||||
required: Optional[List[str]] = Field(default=None, description="Required parameter list")
|
||||
example: Optional[str] = Field(default=None, description="Invocation example")
|
||||
|
||||
|
||||
class ToolManifest(BaseModel):
|
||||
"""Tool Manifest - declarative tool definition"""
|
||||
|
||||
manifest_version: str = Field(default="1.0.0", description="Manifest version")
|
||||
name: str = Field(..., description="Tool name (English, unique)")
|
||||
display_name: str = Field(..., description="Display name (Chinese)")
|
||||
description: str = Field(..., description="Tool description")
|
||||
author: Optional[str] = Field(default=None, description="Author")
|
||||
version: str = Field(default="1.0.0", description="Version number")
|
||||
|
||||
# Execution configuration
|
||||
type: ToolType = Field(default=ToolType.SYNC, description="Tool type")
|
||||
runtime: RuntimeType = Field(default=RuntimeType.PYTHON, description="Runtime")
|
||||
entry: str = Field(..., description="Execution entry (file path or command)")
|
||||
timeout: int = Field(default=30000, description="Timeout (milliseconds)")
|
||||
|
||||
# Configuration
|
||||
config_schema: Optional[Dict[str, Any]] = Field(
|
||||
default=None, description="Configuration schema"
|
||||
)
|
||||
|
||||
# Capabilities
|
||||
commands: List[InvocationCommand] = Field(
|
||||
default_factory=list, description="Available commands"
|
||||
)
|
||||
|
||||
# Metadata
|
||||
tags: Optional[List[str]] = Field(default=None, description="Tags")
|
||||
dependencies: Optional[List[str]] = Field(default=None, description="Dependency tools")
|
||||
enabled: bool = Field(default=True, description="Whether enabled")
|
||||
|
||||
class Config:
|
||||
use_enum_values = True
|
||||
Reference in New Issue
Block a user