mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-11 12:17:45 +02:00
Multi-provider support (WIP - not fully tested): - Owned agent loop replacing claude_agent_sdk (agent_loop.py, mcp_client.py) - Provider adapters: Anthropic (native), OpenAI-compat (any endpoint), Gemini (native + schema cleaning) - 19 models across 9 providers (Anthropic, OpenAI, Google, xAI, Meta, DeepSeek, Mistral, Qwen, Cohere) - OpenRouter integration for 300+ models via single API key - Builtin tool reimplementations (Read, Write, Edit, Glob, Grep, Bash, WebSearch, WebFetch, AskUserQuestion) - Standalone MCP client manager (stdio/sse/http) - Frontend: grouped model dropdown, provider selection, dynamic context windows Analytics (tested): - PostHog integration as single analytics source - Tracks: app.opened, session.started/completed, tool.called, tool.approval_resolved, error.occurred - Rich session data: user messages, assistant messages, session titles, tools used, MCP servers, task categories - PostHog dashboard with 14 insights created via API - Usage stats in Settings (Usage tab) with pixel-art bars Settings (tested): - 4 tabs: General, Models, Usage, Commands - Model Providers tab with OpenRouter (recommended), Anthropic, OpenAI, Google key fields - "Get key" links for each provider - Usage tab with session/cost/tool stats + analytics opt-in toggle - analytics_opt_in defaults to true, installation_id auto-generated Merged haik/updates-v1 (tested): - Sub-agent spawning, chat branching, browser control improvements - Settings: auto_select_mode, expand_new_chats, auto_reveal_sub_agents, dev_mode Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
"""Base classes for builtin tool implementations."""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from dataclasses import dataclass
|
|
from typing import Any
|
|
|
|
|
|
@dataclass
|
|
class ToolContext:
|
|
"""Runtime context passed to every tool execution."""
|
|
cwd: str
|
|
session_id: str
|
|
|
|
|
|
class BaseTool(ABC):
|
|
"""Abstract base for all builtin tools.
|
|
|
|
Subclasses must set ``name`` and ``description`` as class attributes and
|
|
implement ``get_schema`` (JSON Schema for tool input) and ``execute``.
|
|
"""
|
|
|
|
name: str
|
|
description: str
|
|
|
|
@abstractmethod
|
|
def get_schema(self) -> dict:
|
|
"""Return JSON Schema for this tool's input parameters."""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def execute(self, input_data: dict, context: ToolContext) -> list[dict]:
|
|
"""Execute the tool.
|
|
|
|
Returns a list of content blocks, e.g.
|
|
``[{"type": "text", "text": "..."}]``.
|
|
"""
|
|
...
|
|
|
|
def to_tool_schema(self):
|
|
"""Convert to the provider-agnostic ``ToolSchema`` used everywhere."""
|
|
from backend.apps.agents.providers.base import ToolSchema
|
|
|
|
return ToolSchema(
|
|
name=self.name,
|
|
description=self.description,
|
|
input_schema=self.get_schema(),
|
|
)
|