22 lines
711 B
Python
22 lines
711 B
Python
"""Shared serialization helpers for reusable tool resources."""
|
|
|
|
from db.models import Tool
|
|
from schemas import ToolOut
|
|
from services.masking import mask_secrets
|
|
|
|
|
|
def tool_to_out(tool: Tool) -> ToolOut:
|
|
return ToolOut(
|
|
id=tool.id,
|
|
name=tool.name,
|
|
function_name=tool.function_name,
|
|
type=tool.type, # type: ignore[arg-type]
|
|
description=tool.description,
|
|
definition=tool.definition,
|
|
secrets=mask_secrets(tool.secrets or {}),
|
|
status=tool.status, # type: ignore[arg-type]
|
|
mcp_server_id=tool.mcp_server_id,
|
|
remote_tool_name=tool.remote_tool_name,
|
|
updated_at=tool.updated_at.isoformat() if tool.updated_at else None,
|
|
)
|