feat: backend servis iskeletini ve yönetim uçlarını ekle
This commit is contained in:
1
backend/app/tools/__init__.py
Normal file
1
backend/app/tools/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
18
backend/app/tools/apple_notes.py
Normal file
18
backend/app/tools/apple_notes.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import Any
|
||||
|
||||
from app.tools.base import Tool
|
||||
|
||||
|
||||
class AppleNotesTool(Tool):
|
||||
name = "apple_notes"
|
||||
description = "Create notes in Apple Notes through AppleScript."
|
||||
|
||||
async def run(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
title = str(payload.get("title", "")).strip()
|
||||
return {
|
||||
"tool": self.name,
|
||||
"status": "stub",
|
||||
"title": title,
|
||||
"message": "Apple Notes integration is not wired yet.",
|
||||
}
|
||||
|
||||
12
backend/app/tools/base.py
Normal file
12
backend/app/tools/base.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Tool(ABC):
|
||||
name: str
|
||||
description: str
|
||||
|
||||
@abstractmethod
|
||||
async def run(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
raise NotImplementedError
|
||||
|
||||
18
backend/app/tools/brave_search.py
Normal file
18
backend/app/tools/brave_search.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import Any
|
||||
|
||||
from app.tools.base import Tool
|
||||
|
||||
|
||||
class BraveSearchTool(Tool):
|
||||
name = "brave_search"
|
||||
description = "Search the web with Brave Search."
|
||||
|
||||
async def run(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
query = str(payload.get("query", "")).strip()
|
||||
return {
|
||||
"tool": self.name,
|
||||
"status": "stub",
|
||||
"query": query,
|
||||
"message": "Brave Search integration is not wired yet.",
|
||||
}
|
||||
|
||||
21
backend/app/tools/files.py
Normal file
21
backend/app/tools/files.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from app.tools.base import Tool
|
||||
|
||||
|
||||
class FilesTool(Tool):
|
||||
name = "files"
|
||||
description = "Read and write files within allowed paths."
|
||||
|
||||
async def run(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
action = str(payload.get("action", "read")).strip()
|
||||
path = Path(str(payload.get("path", "")).strip()).expanduser()
|
||||
return {
|
||||
"tool": self.name,
|
||||
"status": "stub",
|
||||
"action": action,
|
||||
"path": str(path),
|
||||
"message": "File integration is not wired yet.",
|
||||
}
|
||||
|
||||
18
backend/app/tools/searxng_search.py
Normal file
18
backend/app/tools/searxng_search.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import Any
|
||||
|
||||
from app.tools.base import Tool
|
||||
|
||||
|
||||
class SearXNGSearchTool(Tool):
|
||||
name = "searxng_search"
|
||||
description = "Search the web through a SearXNG instance."
|
||||
|
||||
async def run(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
query = str(payload.get("query", "")).strip()
|
||||
return {
|
||||
"tool": self.name,
|
||||
"status": "stub",
|
||||
"query": query,
|
||||
"message": "SearXNG integration is not wired yet.",
|
||||
}
|
||||
|
||||
24
backend/app/tools/terminal.py
Normal file
24
backend/app/tools/terminal.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from typing import Any
|
||||
|
||||
from app.security import evaluate_terminal_command
|
||||
from app.tools.base import Tool
|
||||
|
||||
|
||||
class TerminalTool(Tool):
|
||||
name = "terminal"
|
||||
description = "Run terminal commands under WiseClaw policy."
|
||||
|
||||
def __init__(self, terminal_mode: int) -> None:
|
||||
self.terminal_mode = terminal_mode
|
||||
|
||||
async def run(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
command = str(payload.get("command", "")).strip()
|
||||
decision = evaluate_terminal_command(command, self.terminal_mode)
|
||||
return {
|
||||
"tool": self.name,
|
||||
"status": "stub",
|
||||
"command": command,
|
||||
"decision": decision.decision,
|
||||
"reason": decision.reason,
|
||||
}
|
||||
|
||||
18
backend/app/tools/web_fetch.py
Normal file
18
backend/app/tools/web_fetch.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import Any
|
||||
|
||||
from app.tools.base import Tool
|
||||
|
||||
|
||||
class WebFetchTool(Tool):
|
||||
name = "web_fetch"
|
||||
description = "Fetch a webpage and return simplified content."
|
||||
|
||||
async def run(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
url = str(payload.get("url", "")).strip()
|
||||
return {
|
||||
"tool": self.name,
|
||||
"status": "stub",
|
||||
"url": url,
|
||||
"message": "Web fetch integration is not wired yet.",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user