feat: tf code

This commit is contained in:
Gab
2026-03-24 15:40:48 +11:00
parent 1539afc803
commit 1c0c0e6a50
5 changed files with 105 additions and 4 deletions

View File

@@ -24,8 +24,13 @@ class SyncedTool(BaseModel):
description: Optional[str] = None
tool_type: ToolType
is_mcp_server: bool = False
is_agent_skill: bool = False
is_database_script: bool = False
request_type: Optional[FunctionRequestType] = None
url: Optional[str] = None
tools: list[str] = []
authorisation_type: Optional[str] = None
@@ -96,10 +101,34 @@ def parse_function(func: AgentFunction) -> SyncedTool:
)
def parse_agent(agent) -> SyncedTool:
"""
Parse Agent from SDK into SyncedTool.
Args:
agent: Agent from TF SDK
Returns:
SyncedTool instance
"""
return SyncedTool(
id=agent.id,
name=agent.label or f"agent_{agent.id[:8]}",
description=agent.description,
tool_type=ToolType.AGENT_SKILL,
is_agent_skill=True,
auth_via="tf_agent",
)
def sync_tools(config: TFConfig) -> ToolSyncResult:
"""
Sync all tools from ToothFairyAI workspace using SDK.
Includes:
- Agent Functions (API Functions)
- Coder Agents (agents with mode='coder')
Args:
config: TFConfig instance
@@ -108,9 +137,19 @@ def sync_tools(config: TFConfig) -> ToolSyncResult:
"""
try:
client = config.get_client()
result = client.agent_functions.list()
tools = [parse_function(f) for f in result.items]
# Sync agent functions
func_result = client.agent_functions.list()
tools = [parse_function(f) for f in func_result.items]
# Sync coder agents
try:
agents_result = client.agents.list()
for agent in agents_result.items:
if getattr(agent, 'mode', None) == 'coder':
tools.append(parse_agent(agent))
except Exception as e:
pass
by_type = {}
for tool in tools: