| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- from typing import TYPE_CHECKING
- from pydantic import BaseModel, Field
- from core_domain import (
- SkillDefinitionContract,
- SkillInstallationContract,
- SkillInstallStatus,
- SkillRunContract,
- SkillStatus,
- SkillVersionContract,
- SkillVersionStatus,
- )
- from core_shared import JSONValue
- if TYPE_CHECKING:
- from app.db.models import SkillDefinition, SkillInstallation, SkillRun, SkillVersion
- class SkillCreateRequest(BaseModel):
- tenant_id: str
- code: str
- name: str
- skill_type: str = "template"
- description: str | None = None
- owner_user_id: str | None = None
- metadata_json: dict[str, JSONValue] = Field(default_factory=dict)
- class SkillStatusUpdateRequest(BaseModel):
- tenant_id: str
- status: SkillStatus
- class SkillResponse(SkillDefinitionContract):
- @classmethod
- def from_entity(cls, entity: "SkillDefinition") -> "SkillResponse":
- return cls.model_validate(entity, from_attributes=True)
- class SkillVersionCreateRequest(BaseModel):
- tenant_id: str
- skill_id: str
- status: SkillVersionStatus = "draft"
- runtime_type: str = "template"
- entrypoint: str | None = None
- parameter_schema_json: dict[str, JSONValue] = Field(default_factory=dict)
- output_schema_json: dict[str, JSONValue] = Field(default_factory=dict)
- implementation_json: dict[str, JSONValue] = Field(default_factory=dict)
- class SkillVersionResponse(SkillVersionContract):
- @classmethod
- def from_entity(cls, entity: "SkillVersion") -> "SkillVersionResponse":
- return cls.model_validate(entity, from_attributes=True)
- class SkillInstallRequest(BaseModel):
- tenant_id: str
- skill_id: str
- skill_version_id: str | None = None
- install_scope: str = "tenant"
- scope_id: str
- config_json: dict[str, JSONValue] = Field(default_factory=dict)
- installed_by: str | None = None
- class SkillInstallationStatusUpdateRequest(BaseModel):
- tenant_id: str
- status: SkillInstallStatus
- class SkillInstallationResponse(SkillInstallationContract):
- @classmethod
- def from_entity(cls, entity: "SkillInstallation") -> "SkillInstallationResponse":
- return cls.model_validate(entity, from_attributes=True)
- class SkillRunCreateRequest(BaseModel):
- tenant_id: str
- skill_id: str
- skill_version_id: str | None = None
- installation_id: str | None = None
- input_json: dict[str, JSONValue] = Field(default_factory=dict)
- class SkillRunExecuteRequest(BaseModel):
- tenant_id: str
- worker_key: str | None = None
- class SkillRunResponse(SkillRunContract):
- @classmethod
- def from_entity(cls, entity: "SkillRun") -> "SkillRunResponse":
- return cls.model_validate(entity, from_attributes=True)
|